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 ?

onmyway133
  • 45,645
  • 31
  • 257
  • 263
  • Isn't the cocoapods config file at the project-level? If so just yours at the target-level. – trojanfoe Jun 16 '14 at 04:22
  • @trojanfoe by target level you mean go to the target build setting panel and manually specify the settings? I don't want that way – onmyway133 Jun 16 '14 at 04:29
  • You don't want that way? Why is that? – trojanfoe Jun 16 '14 at 04:30
  • 1
    @trojanfoe I'm afraid of merging conflict, so using xcconfig I don't have to manually go the the build setting panel – onmyway133 Jun 16 '14 at 04:31
  • 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! – trojanfoe Jun 16 '14 at 04:33
  • 1
    @trojanfoe 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. – skywinder Jul 07 '14 at 10:55

2 Answers2

17

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.

Raphael
  • 9,779
  • 5
  • 63
  • 94
  • 4
    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. – Yonat Feb 28 '18 at 17:38
  • @Yonat 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. – Raphael Feb 28 '18 at 18:45
  • @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! – Raphael Oct 30 '19 at 17:52
  • @Raphael If i don't want to add #include file path in my xcconfig file, how can i do that? – Arshad Shaik Apr 12 '23 at 11:31
  • @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. – Raphael Apr 12 '23 at 14:38
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.

Community
  • 1
  • 1
skywinder
  • 21,291
  • 15
  • 93
  • 123
  • 3
    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"`. – Collin Allen Jan 11 '15 at 15:38
  • This answer is outdated and must be avoided, check Raphael's answer for a more accurate answer. – Roger Oba May 15 '21 at 20:17