Search code examples
iosswiftxcodeauto-generate

How to generate Settings.bundle during the build process?


I have an iOS app and want to generate Settings.bundle/Root.plist dynamically, as a part of build process. Right now I’ve created the “Settings Builder” command-line-tool target in the project and share to it a common source and resource files from the main target. Also at the main target I’ve added the “Run Settings Builder” build phase with following script:

xcodebuild -configuration ${CONFIGURATION} -target "Settings Builder"
"build/${CONFIGURATION}/Settings Builder"

Xcode warning me that “Building targets in manual order is deprecated”, but it works! Settings are generated. But sometimes the “Run Settings Builder” build phase crashes at compile time with strange error: compile error

What I’m doing wrong? And what is the best way to automatically, at build time, generate the resources that depends on source files?


Solution

  • Correct solution is to remove direct xcodebuild calling from the “Run Settings Builder” build phase:

    ${BUILD_DIR}/${CONFIGURATION}/Settings\ Builder
    

    and setup explicit dependency of main app target from "Settings Builder" target (add "Settings Builder" target in "Dependencies" build phase of main target).

    To exclude new binary from the Archive set Skip Install flag in the "Settings Builder" target configuration. This will allow you to make the correct Archive ready to publish in AppStore