steprescott / SCPStoreKitManager

Block based store kit manager for In-App Purchase on iOS 7, 8 & 9 with receipt validation.
MIT License
68 stars 29 forks source link

Can't use SCPStoreKitManager through cocoapods #8

Closed masaniparesh closed 10 years ago

masaniparesh commented 10 years ago

Hi, I have added SCPStoreKitManager using cocoapods. I can include SCPStoreKitManager.h or SCPStoreKitReceiptValidator.h and project build successfully but when I use [SCPStoreKitManager sharedInstance] in the code I get following errors. Can you please let me know what is it about? I have many cocoapods libraries and they worked fine. I am having trouble with only SCPStoreKitManager library.

Undefined symbols for architecture arm64: "_OBJCCLASS$_SCPStoreKitManager", referenced from: objc-class-ref in libCommon.a(IAPHelper.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

steprescott commented 10 years ago

Thanks for letting me know. Looking into this now.

steprescott commented 10 years ago

I have been able to get the example App working, there was a few changes needed for iOS8 and the fact the Apple Root Cert wasn't even bundled. I am currently having issues pushing to the trunk for CocoaPods so will let you know when I can.

masaniparesh commented 10 years ago

Thank you very much. Glad you found the issue and I am happy to know that I wasn't stupid to report this :-) I have checked almost everything - it was able to find headers and .a file was also part of linked libraries but somehow I wasn't able to use it!

masaniparesh commented 10 years ago

BTW your library is fantastic :+1: I never thanked you for that :-)

steprescott commented 10 years ago

Thanks for the support. In the meantime if you specify the git URL you can use the latest 1.1.2 version.

pod 'SCPStoreKitManager/SCPStoreKitReceiptValidator', :git => 'https://github.com/steprescott/SCPStoreKitManager.git'

I have tested it in a fresh project and it builds fine.

steprescott commented 10 years ago

I will be waiting on this issue to be solved in an upcoming CocoaPods release until I can update the spec in the CocoaPods spec repo.

https://github.com/CocoaPods/CocoaPods/issues/2674#issuecomment-59276881

steprescott commented 10 years ago

@micpringle This has now been sorted and you no longer need to specify the git URL

masaniparesh commented 10 years ago

Thanks but it still messing my pods when I add following in my Podfile and do "pod update". It seems OpenSSL is failing and as a result it removes all my existing pods too! You can see it has never tried to install SCPStoreKitManager libraries

pod 'SCPStoreKitManager'
pod 'SCPStoreKitManager/SCPStoreKitReceiptValidator'

$ pod update Analyzing dependencies Downloading dependencies ...... Installing OpenSSL (1.0.109) [!] /bin/bash set -e VERSION="1.0.1i" SDKVERSION=/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep SDKVersion | tail -n 1 | awk '{ print $2 }'

CURRENTPATH=pwd ARCHS="i386 x86_64 armv7 armv7s arm64" DEVELOPER=xcode-select -print-path

mkdir -p "${CURRENTPATH}/bin" mkdir -p "${CURRENTPATH}/lib" mkdir -p "${CURRENTPATH}/opensslIncludes" mkdir -p "${CURRENTPATH}/opensslIncludes/openssl"

tar -xzf file.tgz

cd openssl-${VERSION} cd include/openssl

for link in $(find . -type l) do dir=$(readlink $link) cp $dir ../../../opensslIncludes/openssl done

cd ../.. for ARCH in ${ARCHS} do CONFIGURE_FOR="iphoneos-cross"

if [ "${ARCH}" == "i386" ] || [ "${ARCH}" == "x86_64" ] ; then PLATFORM="iPhoneSimulator" if [ "${ARCH}" == "x86_64" ] ; then CONFIGURE_FOR="darwin64-x86_64-cc" fi else sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c" PLATFORM="iPhoneOS" fi

export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer" export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"

echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}" echo "Please stand by..."

export CC="${DEVELOPER}/usr/bin/gcc -arch ${ARCH} -miphoneos-version-min=${SDKVERSION}" mkdir -p "${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" LOG="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk/build-openssl-${VERSION}.log"

./Configure ${CONFIGURE_FOR} --openssldir="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk" > "${LOG}" 2>&1 sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"

make >> "${LOG}" 2>&1 make install >> "${LOG}" 2>&1 make clean >> "${LOG}" 2>&1 done

echo "Build library..." lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libssl.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libssl.a -output ${CURRENTPATH}/lib/libssl.a lipo -create ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-i386.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneSimulator${SDKVERSION}-x86_64.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-armv7s.sdk/lib/libcrypto.a ${CURRENTPATH}/bin/iPhoneOS${SDKVERSION}-arm64.sdk/lib/libcrypto.a -output ${CURRENTPATH}/lib/libcrypto.a

echo "Building done." echo "Cleaning up..." rm -rf ${CURRENTPATH}/openssl-${VERSION} rm -R ${CURRENTPATH}/bin rm -rf file.tgz echo "Done."

Building openssl-1.0.1i for iPhoneSimulator 8.0 i386

Please stand by...

steprescott commented 10 years ago

@masaniparesh What version of OS X and Xcode are you using?

masaniparesh commented 10 years ago

Xcode 6.0.1 OSX 10.9.5

steprescott commented 10 years ago

@masaniparesh What is outputted when you enter the command xcode-select -p

Also xcodebuild -version

masaniparesh commented 10 years ago

Paresh$ xcode-select -p /Applications/Xcode.app/Contents/Developer

steprescott commented 10 years ago

@masaniparesh And what about xcodebuild -version

masaniparesh commented 10 years ago

Paresh$ xcodebuild -version Xcode 6.0.1 Build version 6A317

steprescott commented 10 years ago

@masaniparesh Strange, the only way I can replicate this issue is by using the Xcode 6.1 beta 2 command line tool.

Can I ask what other pods you have in the pod file?

masaniparesh commented 10 years ago
pod 'MMDrawerController'            , '~> 0.5.6'
pod 'iRate'                         , '~> 1.10.3'
pod 'MBProgressHUD'                 , '~> 0.8'
pod 'Reachability'                  , '~> 3.1.1'
pod 'skpsmtpmessage'                , '~> 0.0.1'
pod 'PBYouTubeVideoViewController'  , '~> 1.0.1'
pod 'XCDYouTubeKit'                 , '~> 2.0.2'
pod 'Masonry'                       , '~> 0.5.3'
pod 'AFNetworking'                  , '~> 2.0'
pod 'UICKeyChainStore'
pod 'FXBlurView'                    , '~> 1.6'
pod 'Facebook-iOS-SDK'
steprescott commented 10 years ago

@masaniparesh I have added all these into an example project and they all build fine.

screen shot 2014-10-16 at 00 43 28

I would suggest running sudo gem update in terminal to make sure you have the latest gems.

steprescott commented 10 years ago

@masaniparesh As you can see I have built it using Xcode 6 and 6.1 ensuring that the command line tools are that of Xcode 6.

All pods installed correctly and I am now happy to conclude that is an issue with your set up. Maybe out of date gems/brews.

screen shot 2014-10-16 at 00 56 59 screen shot 2014-10-16 at 00 59 25

masaniparesh commented 10 years ago

My Mac wasn't restarted quite a while so I have restarted Mac and updated gems but still see the same issue! :( I get following warning when try to run pod install or update. Do you think it has anything to do with this error?

Paresh$ pod install /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:213: warning: Insecure world writable dir /usr/local in PATH, mode 040777 Analyzing dependencies Downloading dependencies Using AFNetworking (2.4.1) Using Bolts (1.1.3) Using FXBlurView (1.6.2) Using Facebook-iOS-SDK (3.19.0) Using MBProgressHUD (0.9) Using MMDrawerController (0.5.7) Using Masonry (0.5.3) Installing OpenSSL (1.0.109) [!] /bin/bash set -e VERSION="1.0.1i" SDKVERSION=/usr/bin/xcodebuild -version -sdk 2> /dev/null | grep SDKVersion | tail -n 1 | awk '{ print $2 }' ....


Only following gem was failed to install.

Fetching: nokogiri-1.6.3.1.gem (100%) Building native extensions. This could take a while... Building nokogiri using packaged libraries. ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13/rbconfig.rb:213: warning: Insecure world writable dir /usr/local in PATH, mode 040777

Building nokogiri using packaged libraries.

libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.

* extconf.rb failed * Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir --without-zlib-dir --with-zlib-include --without-zlib-include=${zlib-dir}/include --with-zlib-lib --without-zlib-lib=${zlib-dir}/lib --enable-cross-build --disable-cross-build

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.3.1 for inspection. Results logged to /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.3.1/ext/nokogiri/gem_make.out

steprescott commented 10 years ago

@masaniparesh Install RVM \curl -sSL https://get.rvm.io | bash and install Ruby version 2.1 rvm install 2.1 then close all terminal windows and try again.

masaniparesh commented 10 years ago

Hi, I have created Test project and installed all pods successfully. That means there must be something to do with my Podfile in original project. Following pod file in my original project doesn't work where I have all pods integrated to Common library, and this library has been used by all my projects in workspace.

source 'https://github.com/CocoaPods/Specs.git' workspace 'MyWorkSpace' platform :ios, '7.1'

xcodeproj 'Project1/Project1' xcodeproj 'Project2/Project2'

target :Common do xcodeproj 'Common/Common' pod 'MMDrawerController' , '~> 0.5.6' pod 'iRate' , '~> 1.10.3' pod 'MBProgressHUD' , '~> 0.8' pod 'Reachability' , '~> 3.1.1' pod 'skpsmtpmessage' , '~> 0.0.1' pod 'PBYouTubeVideoViewController' , '~> 1.0.1' pod 'XCDYouTubeKit' , '~> 2.0.2' pod 'Masonry' , '~> 0.5.3' pod 'AFNetworking' , '~> 2.0' pod 'UICKeyChainStore' pod 'FXBlurView' , '~> 1.6' pod 'Facebook-iOS-SDK' pod 'SCPStoreKitManager' pod 'SCPStoreKitManager/SCPStoreKitReceiptValidator' end

Following Podfile in test project worked:

source 'https://github.com/CocoaPods/Specs.git' workspace 'MyWorkSpace' platform :ios, '7.1'

pod 'MMDrawerController' , '~> 0.5.6' pod 'iRate' , '~> 1.10.3' pod 'MBProgressHUD' , '~> 0.8' pod 'Reachability' , '~> 3.1.1' pod 'skpsmtpmessage' , '~> 0.0.1' pod 'PBYouTubeVideoViewController' , '~> 1.0.1' pod 'XCDYouTubeKit' , '~> 2.0.2' pod 'Masonry' , '~> 0.5.3' pod 'AFNetworking' , '~> 2.0' pod 'UICKeyChainStore' pod 'FXBlurView' , '~> 1.6' pod 'Facebook-iOS-SDK' pod 'SCPStoreKitManager' pod 'SCPStoreKitManager/SCPStoreKitReceiptValidator'

steprescott commented 10 years ago

So all is fine now then?

masaniparesh commented 10 years ago

No. It doesn't work in my original project when Podfile is like below. I am trying to create that in Test project.

source 'https://github.com/CocoaPods/Specs.git' workspace 'MyWorkSpace' platform :ios, '7.1'

xcodeproj 'Project1/Project1' xcodeproj 'Project2/Project2'

target :Common do xcodeproj 'Common/Common' pod 'MMDrawerController' , '~> 0.5.6' pod 'iRate' , '~> 1.10.3' pod 'MBProgressHUD' , '~> 0.8' pod 'Reachability' , '~> 3.1.1' pod 'skpsmtpmessage' , '~> 0.0.1' pod 'PBYouTubeVideoViewController' , '~> 1.0.1' pod 'XCDYouTubeKit' , '~> 2.0.2' pod 'Masonry' , '~> 0.5.3' pod 'AFNetworking' , '~> 2.0' pod 'UICKeyChainStore' pod 'FXBlurView' , '~> 1.6' pod 'Facebook-iOS-SDK' pod 'SCPStoreKitManager' pod 'SCPStoreKitManager/SCPStoreKitReceiptValidator' end

masaniparesh commented 10 years ago

I think the problem is, I had created Library and Projects using old Xcode after that I updated Xcode. I have just created same structure on new Xcode and it works fine. I will need to recreate my projects and libraries structure using new Xcode! Thanks for your help.

masaniparesh commented 10 years ago

Hi, I have tried recreating my project structure but it still gives me same error. Can you please have a look at https://dl.dropboxusercontent.com/u/72253873/Source.zip ? It contains Podfile and workspace with empty projects. If you do pod install, can you see if you get that error too please? Thanks.

masaniparesh commented 10 years ago

I think it's better you put some instructions on compiling and adding Open-SSL library like https://github.com/rmaddy/VerifyStoreReceiptiOS - adding dependency to cocoapods might not be the best option. I have compiled open-ssl library and linked statically.