link_with [‘TestApp’,‘TestAppFramework’] platform :ios,'8.0' source 'https://github.com/CocoaPods/Specs.git' pod 'google-plus-ios-sdk','~> 1.7'
https://developers.google.com/+/mobile/ios/sign-in
一切都没有问题.如果我然后运行应用程序,它将启动并显示一个谷歌加登录按钮,但我收到很多关于在两个地方定义谷歌类的警告,例如:
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.
如果我然后单击登录按钮,我会收到一条错误消息,说我没有设置谷歌客户端ID – 我有,但因为GPPSignIn类依赖于共享实例,所以看起来重复的类混淆了一些事情:
2014-11-24 20:54:25.557 TestApp[6727:155282] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’,reason: ‘You must specify |clientID| for |GPPSignIn|’
查看堆栈跟踪,我们从TestApp范围转换到TestAppFramework,尽管此时框架中没有代码
… 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
我用其他一些可可豆荚来解决这个问题,例如mailcore2-ios,但其他一些豆荚似乎没有提出相同的警告.
有没有办法设置我的podfile,以便我的框架和我的应用程序可以访问相同的依赖项,但没有在运行时发生冲突?或者我不应该像这样设置我的依赖项?
解决方法
您真正想要做的是将依赖项添加到嵌入式框架,如:
source 'https://github.com/CocoaPods/Specs.git' workspace 'TestApp.xcworkspace' def import_pods pod 'google-plus-ios-sdk','~> 1.7' end target : TestAppFramework do xcodeproj 'TestAppFramework.xcodeproj' platform :ios,'8.0' link_with 'TestAppFramework','TestAppFrameworkTests' import_pods end target : TestApp do xcodeproj 'TestApp.xcodeproj' platform :ios,'8.0' link_with 'TestApp','TestAppTests' import_pods end