Xcode 10 Build Phase Shell Script

后端 未结 4 1189
甜味超标
甜味超标 2021-02-10 02:54

In our project we derive our release version from git tag etc then write it to the built folder\'s Info.plist with a shell script like:

GIT_RELEASE_VERSION=$(some

相关标签:
4条回答
  • 2021-02-10 02:57

    It seems like the problem is that sometimes your Run Script Phase will execute before Xcode creates the Info.plist. If you’d like to ensure that your script phase runs after a specific step, you need use the inputs to mark your dependencies.

    For instance, adding:

    $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)

    As an input to your script phase should enforce the ordering you are looking for: Xcode will create the Info.plist and sometime after, your script will execute and modify the Info.plist.

    0 讨论(0)
  • 2021-02-10 03:10

    Similar to the answers above (can't comment yet) but slightly changed.

    Scripts input files:

    $(PROJECT_DIR)/$(INFOPLIST_FILE)      
    $(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)
    

    Output files:

    $(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
    

    I created a gist with a script I use to set the bundle version and some extra info like tag, date, branch.

    https://gist.github.com/JoeMatt/aedd459c54a383373231719e508a2a36

    0 讨论(0)
  • 2021-02-10 03:15

    (Xcode 11.2)

    • In the New Build System, any custom build steps will run before the New Build System's Process .../Info.plist step:

    • To run a shell script after Xcode finishes building, you can add it to your scheme(s) as a build post-action:

    Product > Scheme > Edit Scheme... > Build > Post-actions

    • If you're going to reference any build system environment variables (e.g. BUILT_PRODUCTS_DIR or INFOPLIST_PATH), make sure you change the Provide build settings from selection.

    • Add your shell script, but remember that if you edit any file in the app bundle (i.e. Info.plist), you'll need to re-sign the app. Add this to your post build step:

    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
    /usr/bin/codesign --force --sign - --entitlements "${TARGET_TEMP_DIR}/${FULL_PRODUCT_NAME}.xcent" --timestamp=none "${CODESIGNING_FOLDER_PATH}"
    
    0 讨论(0)
  • 2021-02-10 03:24

    Same issue here... one work-around is to clean and then perform full-build.

    The new build system in Xcode 10 runs the Process Info.plist step differently in full and incremental builds:

    • Full-build: after processing assets, before linking storyboards (link step)
    • Incremental: after embedding frameworks, before signing.

    The actual problem is the script that runs as a build step & updates the processed Info.plist file needs to always run after the the file is processed but before signing.

    0 讨论(0)
提交回复
热议问题