多个目标取决于相同的cocoapods [英] Multiple targets depending on same cocoapods

查看:84
本文介绍了多个目标取决于相同的cocoapods的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Xcode项目中有多个目标,这些目标必须取决于相同的Pod列表。
我可以这样写Podfile:

  target:target1做
pod'pod1'
pod'pod2'
...
结束
target:target2做
pod'pod1'
pod'pod2'
...
end

但这显然不酷。



我希望我可以这样写:

  target:target1,:target2 do 
pod'pod1 '
pod'pod2'
end

但不幸的是,它不起作用。 (请注意,我的主要目标不需要需要这些吊舱)。
是否可以使多个目标依赖于相同的Pod列表(当然不进行复制粘贴)?

解决方案

我刚刚经历了这种可怕的情况,并进行了修复-我现在有一个可以通过命令行或具有4个不同目标(具有不同包ID)的xcode。上面方法的问题在于,由于每个目标都将构建豆荚,因此最终会导致疯狂。我所做的是:


  1. 创建具有一个目标和配置的pod的项目。

  2. 复制目标3次并使用此链接更改包ID等。 http://swwritings.com/post/2013-05-20-concurrent-debug-beta-app-store-builds

  3. 为每个创建工作区级别方案

  4. 为您的Pod构建创建工作区级别方案。

  5. 编辑方案并关闭查找隐式依赖项。
  6. li>
  7. 使方案取决于您的pod方案(编辑方案中的 build选项卡)。

我的podfile看起来像这样-与开始时一样:

  target'test-target'做
pod 'HockeySDK'
pod'RestKit','〜> 0.23.1'
pod'RKXMLReaderSerialization',:git => ‘https://github.com/RestKit/RKXMLReaderSerialization.git’,:branch => 'master'
pod'NSLogger'
pod'Parse-iOS-SDK'
end

我在构建时确实遇到了很多问题,它一直告诉我无法链接到Pod构建,我通过将构建设置中的库搜索路径更改为以下方式解决了此问题:

  $(PROJECT_DIR)/ Build / Products / $(CONFIGURATION)-$(PLATFORM_NAME)

/ Build / Products有点奇怪,但这似乎是Pods开箱即用的功能,如果您与之抗争,事情会变得很丑陋



很难写出详细的操作方法,因为我花了5天的实验才能使魔术版本在Xcode,xcodebuild和Teamcity CI服务器上正常工作。 / p>

I have multiple targets in Xcode project, which must depend on the same list of pods. I could write Podfile like this:

target :target1 do
    pod 'pod1'
    pod 'pod2'
    ...
end
target :target2 do
    pod 'pod1'
    pod 'pod2'
    ...
end

but it's obviously not cool.

I wish I could write something like this:

target :target1, :target2 do
    pod 'pod1'
    pod 'pod2'
end

but unfortunately it doesn't work. (Note that my main target do not need these pods). Is it possible to make multiple targets to depend on same list of pods (without copy-pasting of course)?

解决方案

I have just been through this horrible situation and fixed it up - I now have a workspace that will build via command line or xcode that has 4 different targets with different bundle ID's. The problem with your approach above is that you end up with linking madness as each target will build the pods. What I did was:

  1. Create project with one target and pods configured.
  2. Copy the target 3 times and change bundle id's etc. using this link: http://swwritings.com/post/2013-05-20-concurrent-debug-beta-app-store-builds
  3. Create a workspace level scheme for each of your targets.
  4. Create a workspace level scheme for your pods build.
  5. Edit your schemes and turn off 'Find Implicit Dependencies'.
  6. Make your schemes depend on your pods scheme (build tab in edit schemes).

My podfile looks like this - just the same as it was at the start:

target 'test-target' do
    pod 'HockeySDK'
    pod 'RestKit', '~> 0.23.1'
    pod 'RKXMLReaderSerialization', :git => 'https://github.com/RestKit/RKXMLReaderSerialization.git', :branch => 'master'
    pod 'NSLogger'
    pod 'Parse-iOS-SDK'
end

I did have quite a few problems when building where it kept telling me it couldn't link to the pods build which I resolved by changing the 'Library Search Paths' in build settings to:

$(PROJECT_DIR)/Build/Products/$(CONFIGURATION)-$(PLATFORM_NAME)

It's a bit of a strange path with /Build/Products but that seems to be what Pods does out of the box and if you fight against it things get ugly.

It's hard to write a detailed how-to as it's taken me 5 days of experimentation to get the magic build working in Xcode, xcodebuild and our Teamcity CI server.

这篇关于多个目标取决于相同的cocoapods的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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