Skip to content

Instantly share code, notes, and snippets.

@binho
Last active May 23, 2017 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binho/9ed5b57de8579426c1cb to your computer and use it in GitHub Desktop.
Save binho/9ed5b57de8579426c1cb to your computer and use it in GitHub Desktop.
Xcode Build Phase for checking targets

Note: This build phase script should be added in all targets!

TARGET_NAMES=( ShowMe ShowMeDev ShowMeEnterprise )
PREV_TOTAL=0

for TARGET_NAME in "${TARGET_NAMES[@]}"; do
    TOTAL=`XcodeProjectTargetCheck -xcproj ${SRCROOT}/ShowMe.xcodeproj -targets ${TARGET_NAME} | wc -l`
    echo 'Target Name: '${TARGET_NAME} '- Total Files: '${TOTAL}

    if [ "$PREV_TOTAL" -gt 0 ]; then
        if [ "$TOTAL" != "$PREV_TOTAL" ]; then
            echo "error: Target with name \"${TARGET_NAME}\" has a different number of files!"
            exit 1
        fi
    fi

    PREV_TOTAL=$TOTAL
done

This option should be checked to only run in archive mode: https://www.dropbox.com/s/lhryblvomfmbhmk/xcode_run_only_archive.png?dl=0

Download the Xcode project structure reader (XcodeProjectTargetCheck) https://www.dropbox.com/s/trk5wkvb4dy9t0t/XcodeProjectTargetCheck?dl=1

XcodeProjectTargetCheck binary is generated from https://github.com/ConfusedVorlon/ProjectFileTool

Place it in the /usr/bin folder and give execution permission if needed (chmod +x XcodeProjectTargetCheck)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment