CocoaPods' Pods.xcconfig conflicts with existing ones
Asked Answered
B

1

9

I've a project with several targets. There is a xcconfig file associated to the project and several xcconfig files associated to the targets.

Now I want to incorporate a third party library via 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. 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). Hence, the project ended up screwed.

For example, Cocoapods defines the following in its Pods.xcconfig which is associated to each target:

GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1

I have different configs for each configuration, for example for Debug the config file osx.debug.xcconfig defines

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. There seems to be a large number of issues related to xcconfig files, some of them more than 2 years old. 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. Then, one wants to include a third party library via CocoaPods. After executing pod install, the project is screwed up.

So, what's up with this?

Blasted answered 25/9, 2013 at 16:3 Comment(0)
T
2

You can still have your cake and (partly) eat it. Your targets' xcconfig file can include the cocoapods one:

#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. I can't find a way to add to paths that Cocoapods already set in the included file, e.g. you'd want this:

HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) MyOtherIncludes

However this line simply drops the Cocoapods header search path, leaving only MyOtherIncludes :-(

One workaround for this should be to move MyOtherIncludes to the project's xcconfig files, which Cocoapods doesn't touch. Unfortunately this didn't work for me, YMMV.

Treacherous answered 17/3, 2014 at 14:15 Comment(1)
Unfortunately, the build settings that cannot be extended or modified are the essential one: GCC_PREPROCESSOR_DEFINITIONS, HEADER_SEARCH_PATHS, OTHER_CFLAGS and OTHER_LDFLAGS. The culprit could also be Xcode since the xcconfig file cannot handle such declarations: HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) MyOtherIncludes. In order to make that work would probably break the current behavior how Xcode's xcconfig file settings modify the underlying build settings.Blasted

© 2022 - 2024 — McMap. All rights reserved.