gpt4 book ai didi

ios - cocoa 足类 1.0 : same pods for multiple targets

转载 作者:行者123 更新时间:2023-12-02 05:54:28 25 4
gpt4 key购买 nike

我的 Xcode 项目使用自定义 .xcconfig 文件进行build设置。我有 debug.xcconfig、beta.xcconfig 和release.xcconfig。它们被添加到相同的 3 个构建配置的每个目标中:

enter image description here

我需要为所有目标集成所有 pod。但是,在进行 pod 安装时,Cocoapods 会为每个目标生成 3 个 .xcconfig 文件,并期望将这些文件添加到每个目标,或包含在我的自定义 .xcconfig 文件中。消息内容如下:

CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target 'Target1' to 'Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig' or include the 'Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig' in your build configuration ('MyProject/Configuration/Debug.xcconfig').

我无法将基本配置设置为 Cocoapods 生成的 xcconfig 文件。我需要将自定义 xcconfig 文件设置为基础,以便将我的build设置应用于目标。所以我必须走包含路线。在 Cocoapods 0.x 中,我可以将其包含在我的自定义 .xcconfig 文件中:

#include "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"

但是对于 Cocoapods 1.0,我预计会做这样的事情(对于我的每个 xcconfig):

#include "../Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target2/Pods-Target2.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target3/Pods-Target3.debug.xcconfig"
#include "../Pods/Target Support Files/Pods-Target4/Pods-Target4.debug.xcconfig"

这不太好。我的项目有 12 个目标,这意味着我必须在 3 个自定义 .xcconfig 中的每一个中放置 12 个包含文件,总共 36 个包含文件。一定有更好的方法。

我在 Podfile 中尝试了几种不同的方法,包括抽象目标,但结果始终相同。有谁知道如何解决这个问题吗?

这是我的 Podfile 代码:

platform :ios, '8.4'
use_frameworks!


def myPods

pod 'SplunkMint'
pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON', :git => 'https://github.com/SwiftyJSON/SwiftyJSON.git'

end

target 'target1' do
myPods
end

target 'target2' do
myPods
end

target 'target3' do
myPods
end

target 'target4' do
myPods
end

最佳答案

您不应在每个自定义目标配置中包含所有 pod 配置。每个目标配置应仅包含其自己的引用 pod 配置:

目标1

#include "../Pods/Target Support Files/Pods-Target1/Pods-Target1.debug.xcconfig"

目标2

#include "../Pods/Target Support Files/Pods-Target2/Pods-Target2.debug.xcconfig"

您的PodFile似乎是正确的,您还可以在“myPods”定义之前添加显式目标类型

xcodeproj 'YourProjectName', {
'Target1' => :release,
'Target2' => :debug,
'Target3' => :debug
'Target4' => :debug
}

您的 xCode 配置(图像)似乎也正确,与我的工作项目的唯一区别是我在项目级别选择了“无”而不是“应用程序”。

尝试关闭 xCode,删除所有 pod,然后再次运行 pod install

关于ios - cocoa 足类 1.0 : same pods for multiple targets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37320194/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com