Howard
Howard

Reputation: 19815

Auto switch Xcode Config when testing simulator and devices

I managed to use Xcconfig to build my app, but as in the config itself, I need to specify such as...

ARCHS = $(ARCHS_STANDARD_32_BIT)
SDKROOT = iphoneos

So I have two files, such as Debug-Simulator.xcconfig and Debug-Device.xcconfig.

But in the XCode, I can only attach one Debug and one Release XCodeConfig, so how to auto change the configuration automatically without I change the Debug configuration manually?

Upvotes: 3

Views: 1190

Answers (2)

ipmcc
ipmcc

Reputation: 29916

You can conditionalize lines of your .xcconfig file based on the SDK name. For instance...

ARCHS[sdk=iphoneos*] = armv7
ARCHS[sdk=iphonesimulator*] = $(ARCHS_STANDARD_32_BIT)

I think that's what you're looking for here, right? I'm not sure the full extent of these predicates' syntax, but the above works for me when trying to change build settings beteen Simulator and Device.

You can even use this to conditionalize for multiple versions of SDK, like they do here: Base.xcconfig

Upvotes: 6

mr.pppoe
mr.pppoe

Reputation: 3945

Are you using Command-line?

xcodebuild -configuration Debug ...
xcodebuild -configuration Release ..

You can refer to the usage of xcodebuild.

Options:
    -usage                print full usage
    -verbose              provide additional status output
    -project NAME         build the project NAME
    -target NAME          build the target NAME
    -alltargets           build all targets
    -workspace NAME       build the workspace NAME
    -scheme NAME          build the scheme NAME
    -configuration NAME   use the build configuration NAME for building each target
    -xcconfig PATH        apply the build settings defined in the file at PATH as overrides
    -arch ARCH            build each target for the architecture ARCH; this will override architectures defined in the project
    -sdk SDK              use SDK as the name or path of the base SDK when building the project
    -parallelizeTargets   build independent targets in parallel
    -jobs NUMBER          specify the maximum number of concurrent build operations
    -showsdks             display a compact list of the installed SDKs
    -list                 lists the targets and configurations in a project, or the schemes in a workspace
    -find BINARY          display the full path to BINARY in the provided SDK
    -version              display the version of Xcode; with -sdk will display info about one or all installed SDKs

Upvotes: 1

Related Questions