Edit Xcode xcconfig file and Cocoapods
Asked Answered
S

2

32

I want to edit the xcconfig file, but unfortunately Xcode only allows 1 xcconfig file per configuration, and that is Pods.xcconfig because I'm using Cocoapods

So how can I edit the xcconfig without hurting Cocoapods

I can think of several ways

  1. Make Xcode use multiple xcconfig files
  2. Use my own xcconfig file that includes Pods.xcconfig file

So how to deal with this ?

Silurian answered 16/6, 2014 at 4:17 Comment(6)
Isn't the cocoapods config file at the project-level? If so just yours at the target-level.Smoko
@Smoko by target level you mean go to the target build setting panel and manually specify the settings? I don't want that waySilurian
You don't want that way? Why is that?Smoko
@Smoko I'm afraid of merging conflict, so using xcconfig I don't have to manually go the the build setting panelSilurian
What "merging conflict"? Any changes to the Xcode project or source files is a potential merge conflict so if you're afraid of them then you cannot do anything!Smoko
@Smoko during pod install command Pods.xcconfig automatically placed at Target configuration. If you change this - you should also manually change this after each pods update. So, the question how to avoid it.Skeptic
S
6

Here is a issue in CocoaPods Tracker. A workaround is described here: #1736.

As kylef (owner of CocoaPods repo) mentioned:

Manual Workaround: Use pod install --no-integrate then add #include "Pods/Pods-GCE.xcconfig" from your custom xcconfig files.

I don't think there is a clear solution to automatically fix it, but maybe it would be nice if cocoa pods detected this and told the user. Took me a while to figure out what happened after I did pod install and the projects xcconfig files wasn't being included.

Skeptic answered 7/7, 2014 at 11:9 Comment(2)
This almost worked, but it seems like CococaPods has changed. I had to #include "Pods/Target Support Files/Pods/Pods.debug.xcconfig" instead of the GCE path. Similarly, in my AppName.release.xcconfig, I did #include "Pods/Target Support Files/Pods/Pods.release.xcconfig".Parliament
This answer is outdated and must be avoided, check Raphael's answer for a more accurate answer.Revolting
G
18

Nowadays (XCode 9.x, CocoaPods 1.4.0) you just add

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

to your custom xcconfig. pod install will complain but automatically do the right thing (nothing); it'll even tell us to do exactly the above.


It's not necessary anymore to prevent integration (which would leave us without a workspace, too). FWIW, option --no-integrate no longer exists; if we wanted it, we'd add :integrate_targets => false as option to install! in the Podfile.

Godesberg answered 23/2, 2018 at 9:8 Comment(5)
Actually, it seems this is unnecessary: if you set your own xcconfig file for the project, and leave the CocoaPods xcconfig for each target, then both config files get used and all is well.Harbor
@Harbor Sounds reasonable. My use case (not stated above) is using a SwiftPM-generated XC project with pods in an automated fashion; I don't really want to touch the project or workspace manually. And since I can tell SwiftPM only to "use this one config!" without further detail, no luck there I think.Godesberg
@KarenAnne I don't work on/with Macs anymore (thank god!) so I have no way to check. I recommend you open a new question. Good luck!Godesberg
@Godesberg If i don't want to add #include file path in my xcconfig file, how can i do that?Epicarp
@ArshadShaik As I wrote above, I haven't worked with this stack in years, so I can't tell you. I suggest you open a new question, linking to this one for reference.Godesberg
S
6

Here is a issue in CocoaPods Tracker. A workaround is described here: #1736.

As kylef (owner of CocoaPods repo) mentioned:

Manual Workaround: Use pod install --no-integrate then add #include "Pods/Pods-GCE.xcconfig" from your custom xcconfig files.

I don't think there is a clear solution to automatically fix it, but maybe it would be nice if cocoa pods detected this and told the user. Took me a while to figure out what happened after I did pod install and the projects xcconfig files wasn't being included.

Skeptic answered 7/7, 2014 at 11:9 Comment(2)
This almost worked, but it seems like CococaPods has changed. I had to #include "Pods/Target Support Files/Pods/Pods.debug.xcconfig" instead of the GCE path. Similarly, in my AppName.release.xcconfig, I did #include "Pods/Target Support Files/Pods/Pods.release.xcconfig".Parliament
This answer is outdated and must be avoided, check Raphael's answer for a more accurate answer.Revolting

© 2022 - 2024 — McMap. All rights reserved.