Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edit Xcode xcconfig file and Cocoapods

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 ?

like image 733
onmyway133 Avatar asked Jun 16 '14 04:06

onmyway133


People also ask

How do I use Xcconfig files?

Creating and using your xcconfig file To create an xcconfig file, choose File -> New -> File... in your project. In the new file dialog, scroll down until you see the Configuration Settings File in the Other section. You can add configurations for pretty much anything you want.

How do I install dependency on CocoaPods?

After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.

What is configuration in xcode?

If you don't know what an Xcode Configuration file ( . xcconfig ) is, it is actually a key/value based file. You can store your build settings in the form of key/value pairs, similar to what you did in dictionaries. By using a . xcconfig file, it is very easy to define build parameters for each build.

What is POD file in Swift?

<What is a Podfile? The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. The file should simply be named Podfile . All the examples in the guides are based on CocoaPods version 1.0 and onwards.


2 Answers

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.

like image 94
Raphael Avatar answered Sep 21 '22 00:09

Raphael


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.

like image 21
skywinder Avatar answered Sep 21 '22 00:09

skywinder