Working With Custom “xcconfigs” and Cocoapods | by Nikhil Vinod | Mar, 2022

Maintaining a customized configuration alongside pods configuration in iOS

Have you ever ever needed to have your customized and cocoa pod configurations work collectively? Like ever!

Let me assist you.

Earlier than beginning we are going to ensure you are on the proper place to resolve your drawback. Please undergo the guidelines to make sure we all know the difficulty we need to resolve.

Guidelines

  1. You need to introduce customized configurations to your challenge
  2. You have got cocoa pods arrange in your challenge
  3. You’ll be able to see Pods-ProjectName.launch in your launch configuration set one thing like this:
Configurations with Pods

Extra Information

Cocoapods mechanically generates its config recordsdata primarily based on challenge configurations and mechanically provides them to the targets.
There was an possibility --no-integrate to keep away from attaching the respective pod config file with our configuration units which now now not exist.
If we needed it, we might add :integrate_targets => false as choice to set up! within the Podfile.

Okay! As you’re studying this half, I’m certain there’s a very good likelihood you’re targeted on this text, and the above-listed points are exactly the set of issues you need to resolve.

Lets dive-in.

We’ll first create a .xcconfig file after which we are going to add it in our challenge folder.

1. CMD + N after which on filter subject sort Config -> Create the .xcconfig file with a reputation -> That is how the folder construction will appear to be

As soon as this setup is finished. You simply must open your Customized Configuration file which you could have created, on this case right here will probably be CustomReleaseConfig.xcconfig

As soon as step 1 is accomplished we are going to open our created .xcconfig file after which we are going to embrace the pod config file to it.

Enter the next header :

#embrace "Pods/Goal Help Recordsdata/Pods-ProjectName/Pods-Pods-ProjectName.debug.xcconfig"

Extra Information:

If you’re having one other set of CustomConfig recordsdata that are optionally available to your mother or father config to work you’ll be able to at all times set or mark it like this:

#embrace? "ChildConfig.xcconfig"

This may optionally embrace "ChildConfig.xcconfig" that features native overrides if it exists
Additionally #embrace? is supported as of Xcode 8

As soon as step 2 is finished, simply open your challenge information -> Configurations and Change the App’s configuration to the Customized configuration which you could have created.
That is the way it will appear to be now:

After setting the configuration to Customized Configuration

I hope this could resolve your drawback of maintaining a customized configuration together with pods configuration.

More Posts