I’m trying to work out how to add cocoa pod dependencies to an iOS app that has an embedded cocoa touch framework. I have my podfile set up like this:
link_with [‘TestApp’, ‘TestAppFramework’]
platform :ios, '8.0'
source 'https://github.com/CocoaPods/Specs.git'
pod 'google-plus-ios-sdk', '~> 1.7'
Then I add a view controller with a sign in button as per the instructions here:
https://developers.google.com/+/mobile/ios/sign-in
and everything compiles with no problems. If I then run the app it will start up and display a google plus sign in button, but I get a lot of warnings about the google classes being defined in two places, for example:
objc[6727]: Class GPPSignIn is implemented in both /Users/jamesburke/Library/Developer/Xcode/DerivedData/TestApp-eiqrhcijoqplxgaoodgtwzncvhjk/Build/Products/Debug-iphonesimulator/TestAppFramework.framework/TestAppFramework and /Users/jamesburke/Library/Developer/CoreSimulator/Devices/730A1805-D46F-4D11-9F9E-DA37C1147F9A/data/Containers/Bundle/Application/EB7EE52A-7FB6-45CE-81B4-1E9A45875E69/TestApp.app/TestApp. One of the two will be used. Which one is undefined.
If I then click on the sign in button I get an error saying that I haven’t set the google client id - which I have, but because the GPPSignIn class relies on a shared instance it looks like the duplicate classes have confused things:
2014-11-24 20:54:25.557 TestApp[6727:155282] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GPPSignIn|'
Looking in the stack trace we flip from the TestApp scope to the TestAppFramework one, even though there’s no code in the framework at this point
…
3 TestAppFramework 0x000000010c7f1a9c -[GPPSignIn assertValidParameters] + 77
4 TestAppFramework 0x000000010c7f35e7 -[GPPSignIn authenticateMaybeInteractively:withParams:] + 118
5 TestAppFramework 0x000000010c7f5ac8 -[GPPSignInButton buttonPressed] + 164
6 UIKit 0x000000010b4c38be -[UIApplication sendAction:to:from:forEvent:] + 75
…
19 UIKit 0x000000010b4c2420 UIApplicationMain + 1282
20 TestApp 0x000000010a25e9f3 main + 115
I get this problem with some other cocoa pods, for example mailcore2-ios, but some other pods don’t seem to raise the same warnings.
Is there a way to set my podfile up so that both my framework and my app have access to the same dependencies, but without clashing at runtime? Or should I just not be setting my dependencies up like this?