简体   繁体   English

CocoaPods的Pods.xcconfig与现有的冲突

[英]CocoaPods' Pods.xcconfig conflicts with existing ones

I've a project with several targets. 我有一个有几个目标的项目。 There is a xcconfig file associated to the project and several xcconfig files associated to the targets. 有一个与项目关联的xcconfig文件和几个与目标关联的xcconfig文件。

Now I want to incorporate a third party library via CocoaPods. 现在我想通过CocoaPods整合第三方库。 After $ pod install CocoaPods screwed the original project since it associates its own xcconfig file Pds.xcconfig to the target of the original project. $ pod install CocoaPods搞砸了原始项目,因为它将自己的xcconfig文件Pds.xcconfig与原始项目的目标相关联。 This completely ignores and overwrites the settings defined in the original xcconfig associated to the project, and switched out the original xcconfig file associated to the target(s). 这完全忽略并覆盖与项目关联的原始xcconfig中定义的设置,并切换出与目标关联的原始xcconfig文件。 Hence, the project ended up screwed. 因此,该项目最终搞砸了。

For example, Cocoapods defines the following in its Pods.xcconfig which is associated to each target: 例如,的CocoaPods限定在其下面Pods.xcconfig其被关联到每个目标:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1

I have different configs for each configuration, for example for Debug the config file osx.debug.xcconfig defines 我对每个配置都有不同的配置,例如对于调试配置文件osx.debug.xcconfig定义

GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 DEBUG_LOG=2 __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0

What's a reasonable and viable approach to solve such conflicts? 什么是解决此类冲突的合理可行的方法?

Edit: 编辑:

I've searched through the CocoaPods issues list on GitHub. 我在GitHub上搜索了CocoaPods问题列表。 There seems to be a large number of issues related to xcconfig files, some of them more than 2 years old. 似乎存在大量与xcconfig文件相关的问题,其中一些问题已超过2年。 They are discussed, and then closed, but - as it occurred to me - the issue has not yet been solved. 他们被讨论,然后关闭,但是 - 正如我发生的那样 - 问题尚未解决。

IMHO, this is a fundamental and a basic problem: there is a project which uses xcconfig files. 恕我直言,这是一个基本问题和一个基本问题:有一个项目使用xcconfig文件。 Then, one wants to include a third party library via CocoaPods. 然后,想要通过CocoaPods包含第三方库。 After executing pod install , the project is screwed up. 执行pod install ,项目搞砸了。

So, what's up with this? 那么,这有什么用呢?

You can still have your cake and (partly) eat it. 你仍然可以吃蛋糕和(部分)吃它。 Your targets' xcconfig file can include the cocoapods one: 您的目标的xcconfig文件可以包含一个cocoapods:

#include "../Pods/Pods.xcconfig"
MY_SETTING = YES
...

However, the part you still can't eat is when you want to specify the flags already set in Pods.xcconfig. 但是,您仍然无法进食的部分是您想要指定已在Pods.xcconfig中设置的标志。 I can't find a way to add to paths that Cocoapods already set in the included file, eg you'd want this: 我找不到添加到Cocoapods已经在包含文件中设置的路径的方法,例如你想要这个:

HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) MyOtherIncludes

However this line simply drops the Cocoapods header search path, leaving only MyOtherIncludes :-( 然而,这一行简单地删除了Cocoapods头部搜索路径,只留下MyOtherIncludes :-(

One workaround for this should be to move MyOtherIncludes to the project's xcconfig files, which Cocoapods doesn't touch. 解决此问题的一种方法是将MyOtherIncludes移动到项目的xcconfig文件中,Cocoapods不会触摸它们。 Unfortunately this didn't work for me, YMMV. 不幸的是,这对我不起作用,YMMV。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM