为每个Xcode目标指定可可豆荚

时间:2015-02-13 00:48:24

标签: ios objective-c xcode cocoapods

我想在我的Xcode项目中为每个目标使用特定的podfile。

在我的Xcode项目中,我有四个目标:

  • 生产
  • 预览
  • 分期
  • dev的

生产预览和暂存我想使用Podfile来声明依赖关系相同,对于私有可可pod我想使用特定标签来发布版本。

但是在dev中我想使用本地目录或可可pod的dev分支。

我该怎么做?我会声明第二个具有不同依赖关系的podfile吗?

编辑: 使用答案。

target :MyProject-Dev, :exclusive => true do
    xcodeproj 'MyProject/MyProject.xcodeproj' # Or if you have multiple      implicit project dependencies, change here.
    pod 'privatepod' :git => "<giturl>", :branch => 'dev'

    link_with 'MyProjectDevTarget' # Your Xcode Project target.
end

target :MyProject-Staging, :exclusive => true do
    xcodeproj 'MyProject/MyProject.xcodeproj' # Or if you have multiple implicit project dependencies, change here.
    pod 'privatepod' :git => "<giturl>", :tag => '1.0.9'

    link_with 'MyProjectStagingTarget'
end

我遇到一个问题,即pod更新抱怨“privatepod”的不同来源的多个依赖关系

1 个答案:

答案 0 :(得分:0)

您只需要单个Podfile,但声明独有的Podfile-Target(s)以链接多个Xcode Project目标。例如,您的Podfile可能如下所示:

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

workspace 'MyProject'
xcodeproj 'MyProject/MyProject'

############################
# Dev Exclusive Target
############################

target :MyProject-Dev, :exclusive => true do
    xcodeproj 'MyProject/MyProject.xcodeproj' # Or if you have multiple implicit project dependencies, change here.

    pod AFNetworking
    # More pods here.

    link_with 'MyProjectDevTarget' # Your Xcode Project target.
end

############################
# Staging Exclusive Target
############################

target :MyProject-Staging, :exclusive => true do
    xcodeproj 'MyProject/MyProject.xcodeproj' # Or if you have multiple implicit project dependencies, change here.

    pod SomeDifferentPod

    link_with 'MyProjectStagingTarget'
end

&#34; MyProject的-DEV&#34;和&#34; MyProject-Staging&#34;是Podfile目标,它将Pods编译成单个库(.a文件)并链接到指定的Xcode Project目标。

希望这有帮助。

相关问题