31

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
  • 42,755
  • 26
  • 247
  • 253
  • 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

14

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
  • 8,276
  • 4
  • 58
  • 91
  • 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
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
  • 20,913
  • 15
  • 90
  • 122
  • 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