preface

Learning is like rowing upstream; not to advance is to drop back. Mutual encouragement!!

Now that the project is finished, I have nothing to do. Share a guide for writing xcConfig. I hope to offer a little help to those in need. Don’t forget to like and follow. Hey hey!! Cut the crap and get to work.

Xcconfig guide

The syntax of the XCConfig file is very simple. Each configuration file consists of a series of key assignments with the following syntax:

1.BUILD_SETTING_NAME = value
Copy the code

annotation

The xcconfig file has only one comment method \.

Include Imports other Settings

As you create the XCConfig file, you can create as many as you need. This means that you can import configuration from other XCConfig using the include keyword. Enclose double quotes after the include keyword:

1.#include "Debug.xcconfig"

Copy the code

When searching for imported files, a slash is the absolute path, for example:

2#include "/Users/ws/Desktop/VIP course / 1st lesson, symbols and links / 1st lesson information/complete code /LoginApp- conflict /Pods/Target Support Files/Pods-LoginApp/Pods LoginApp.debug.xcconfig"Copy the code

Or through relative paths, starting with the ${SRCROOT} path:

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

Copy the code

variable

Let’s take a look at variables in a very simple way.

First variable definition, according to the OC naming rules, consists only of uppercase letters, digits, and underscore (_) groups, uppercase in principle, but not optional. The string can be either “or”. There are three special cases of variables:

1. If the variables defined in xcConfig match those in Build Settings, overwriting will occur. Inherited can be inherited using $(Inherited). Such as:

1.OTHER_LDFLAGS = -framework SDWebImage
2.OTHER_LDFLAGS = $(inherited) -framework AFNetworking
3.// OTHER_LDFLAGS = -framework SDWebImage -framework AFNetworking
Copy the code

Special note ⚠ : some variables cannot be configured to Build Settings via xcConfig. For example, PRODUCT_BUNDLE_IDENTIFIER does not work.

2. Reference variables () and () and () () and {} can be either written:

1.VALUE=Cat
2.TEACHER=$(VALUE)-${VALUE}
Copy the code

3. Conditional variables: conditional Settings according to SDK, Arch, and Configration, for example:

1// Specify 'Configration' is' Debug '2// specify' SDK 'is emulator, OTHER_LDFLAGS[config=Debug][SDK =iphonesimulator*][arch=x86_64]= $(inherited) -framework "Cat"Copy the code

Note in particular ⚠ : in Xcode 11.4 and later, you can use default to specify the default value for null variables:

1$(BUILD_SETTING_NAME:default=value)
Copy the code

Priority (from highest to lowest) :

  1. Manually configure Target Build Settings
  2. The xcConfig file configured in Target
  3. Manually configure Project Build Settings
  4. The xcConfig file configured in Project

The last

Xcode Build Settings corresponds to the xcConfig variable: Xcode Build Settings

Now I don’t know if you can understand me. I have tried my best. Get a wave of attention and likes at the end. I have been working in iOS development for many years. If you still need iOS information, please click below to get it. I hope I can help you in a small way.

The iOS data | download address