将可可贴的依赖性添加到可可接触框架 [英] adding cocoapod dependencies to a cocoa touch framework

查看:261
本文介绍了将可可贴的依赖性添加到可可接触框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将可可豆依赖项添加到具有嵌入可可触摸框架的iOS应用程序。我的podfile设置如下:

  link_with ['TestApp','TestAppFramework'] 
platform:ios ,'8.0'
source'https://github.com/CocoaPods/Specs.git'
pod'google-plus-ios-sdk','〜> 1.7'

然后我根据这里的说明添加一个带有登录按钮的视图控制器: p>

https://developers.google.com/+ / mobile / ios / sign-in



,一切都没有问题。如果我然后运行应用程序,它会启动并显示一个谷歌加号登录按钮,但我收到很多关于谷歌类定义在两个地方的警告,例如:


objc [6727]:GPPSignIn类在/Users/jamesburke/Library/Developer/Xcode/DerivedData/TestApp-eiqrhcijoqplxgaoodgtwzncvhjk/Build/Products/Debug-iphonesimulator/TestAppFramework.framework中实现/ TestAppFramework和/Users/jamesburke/Library/Developer/CoreSimulator/Devices/730A1805-D46F-4D11-9F9E-DA37C1147F9A/data/Containers/Bundle/Application/EB7EE52A-7FB6-45CE-81B4-1E9A45875E69/TestApp.app/TestApp。将使用两者之一。


如果我点击登录按钮,我会得到一个错误,说我没有设置google客户端ID - 我有,但是因为GPPSignIn类依赖于一个共享实例,它看起来像重复的类已经困惑的事情:


-11-24 20:54:25.557 TestApp [6727:155282] ***由于未捕获异常NSInvalidArgumentException终止应用程序,原因:'您必须指定| clientID |对于| 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,但一些其他pod似乎不提出相同的警告。



有一种方法设置我的podfile向上,使我的框架和我的应用程序可以访问相同的依赖,但没有在运行时冲突?

解决方案

我不知道pod'google-plus-ios -sdk','〜> 1.7'支持Framework。
在您的podfile中


  target'YourProjectName'do 
pod'google -plus-ios-sdk','〜> 1.7'
end

尝试使用它。



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?

解决方案

I am not sure that pod 'google-plus-ios-sdk', '~> 1.7' supports Framework. In your podfile

target 'YourProjectName' do
pod 'google-plus-ios-sdk', '~> 1.7'
end

Try to use it like this.

这篇关于将可可贴的依赖性添加到可可接触框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆