This is the 18th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021.

The syntax of the XCConfig file is relatively simple, each configuration file consists of a series of key-value assignments with the following syntax:

BUILD_SETTING_NAME = value
Copy the code

annotation

The xcConfig file has only one comment method, which is //.

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 quotation marks after the include keyword, as shown in the following example:

#include "Debug.xcconfig"
Copy the code

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

#include "/Users/ws/Desktop/VIP course/lesson 1, symbols and links/strong class lesson 1 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:

#include "Pods/Target Support Files/Pods-LoginApp/Pods-LoginApp.debug.xcconfig"
Copy the code

variable

Variable definitions, according to the OC naming rules, consist 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. inxcconfigThe variables defined inBuild SettingsIs consistent, then coverage will occur. Can be achieved by$(inherited), the current variable inherits the original value of the variable. Such as:
OTHER_LDFLAGS = -framework SDWebImage OTHER_LDFLAGS = $(inherited) -framework AFNetworking // OTHER_LDFLAGS = -framework  SDWebImage -framework AFNetworkingCopy the code

Note ⚠️ : Some variables cannot be configured to Build Settings via xcConfig. For example, PRODUCT_BUNDLE_IDENTIFIER does not work.

  1. Reference variable,The $()andThe ${}Either way you can write it:
VALUE=Cat
TEACHER=$(VALUE)-${VALUE}
Copy the code
  1. The conditional variable, according toSDK,ArchandConfigrationConditionalize Settings, for example:
// Specify 'Configration' is' Debug '// specify' SDK 'is emulator, // Inherited =iphonesimulator* // inherited =iphonesimulator* / -framework "Cat"Copy the code

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

$(BUILD_SETTING_NAME:default=value)
Copy the code

Priority (from highest to lowest)

  1. Manual configurationTarget Build Settings
  2. TargetConfigured inxcconfigfile
  3. Manual configurationProject Build Settings
  4. ProjectConfigured inxcconfigfile