Xcode scheme pre-action script not running

前端 未结 2 1831
难免孤独
难免孤独 2021-02-01 02:18

Hit build and nothing gets printed in build log. What gives?

Xcode Version 8.2.1 (8C1002)

2条回答
  •  梦谈多话
    2021-02-01 02:41

    To add to the answer, https://stackoverflow.com/a/42497746/1058199, it's important to not clutter up the project.pbxproj (where build scripts go) or your scheme file (where these scripts go) as much as possible.

    With this in mind, I create a Build-Scripts folder in the project root where I put the app build scripts and pre-action scripts. This folder is dragged into the root of the project as a folder so that any script I add to it is automatically added to project.

    Assuming that your pre-action script is called That_pre-action_script.sh, this is what I put in Pre-actions script based on the approved answer.

    say "Pre build scripts running."
    exec > "${PROJECT_DIR}/prebuild.log" 2>&1
    echo "Starting build scheme Pre-actions"
    "${PROJECT_DIR}/Build-Phases/That_pre-action_script.sh"
    

    As a test, make sure to echo some message from your script so you can see it in the prebuild.log file.

    Hope this helps.

    And don't forget to chmod u+x your script so that it will run.

    The important part is if you can't make sure if your build script is running or not. This is where the say command us useful so that you know it's actually being issued before a build.

    It's a good idea to put quotes around the path to the script in case there are any space characters (or otherwise) in the path to your project.

提交回复
热议问题