Search code examples
xcodebashshxcodebuild

Why is "xcodebuild: command not found" in this build script?


Hi I have the following in the root of my xcode project:

#!/bin/bash
xcodebuild -scheme target1 clean;
xcodebuild -scheme target1 archive;
xcodebuild -scheme target2 clean;
xcodebuild -scheme target2 archive;

However, this only executes the first line xcodebuild -scheme target1 clean; and then yields

...
** CLEAN SUCCEEDED **

xcodebuild: command not found
xcodebuild: command not found
xcodebuild: command not found

Disclaimer: I'm an absolute Mac OS X / Unix greenhorn.

Edit: Following kranteg's suggestion I added pwd to the script:

#!/bin/bash
pwd;
xcodebuild -scheme target1 clean;
pwd;
xcodebuild -scheme target1 archive;
pwd;
xcodebuild -scheme target2 clean;
pwd;
xcodebuild -scheme target2 archive;
pwd;

The output:

/Users/CKU/Programme/uraClient
=== CLEAN TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Debug ===

Check dependencies

<... lots of compiler messages about the clean ...>

** CLEAN SUCCEEDED **

/Users/CKU/Programme/uraClient
xcodebuild: command not found
/Users/CKU/Programme/uraClient
xcodebuild: command not found
/Users/CKU/Programme/uraClient
xcodebuild: command not found
/Users/CKU/Programme/uraClient

Edit 2: Replacing the pwd with echo $PATH yields a better result, now the script performs the first three xcodebuild commands before failing. However, the PATH variable seems to be unaffected by xcodebuild:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
=== CLEAN TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Debug ===

<... log messages ...>

** CLEAN SUCCEEDED **

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
=== BUILD TARGET uraClient OF PROJECT uraClient WITH CONFIGURATION Release ===

<... log messages ...>

** ARCHIVE SUCCEEDED **


The following commands produced analyzer issues:
    AnalyzeShallow uraClient/SQLiteLibrary/SQLiteManager.m
    AnalyzeShallow uraClient/URA/NSString+UrlEncoding.m
    AnalyzeShallow uraClient/Services/UraTripPredictionsProvider.m
    AnalyzeShallow uraClient/UtilityAppViewController/ViewController.m
    AnalyzeShallow uraClient/RNCryptor/RNDecryptor.m
    AnalyzeShallow uraClient/RNCryptor/RNEncryptor.m
    AnalyzeShallow uraClient/RNCryptor/RNOpenSSLCryptor.m
    AnalyzeShallow uraClient/RNCryptor/RNOpenSSLDecryptor.m
    AnalyzeShallow uraClient/RNCryptor/RNOpenSSLEncryptor.m
(9 commands with analyzer issues)
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
=== CLEAN TARGET uraAseag OF PROJECT uraClient WITH CONFIGURATION Debug ===

<... log messages ..>

** CLEAN SUCCEEDED **

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools
xcodebuild: command not found
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Desktop/adt-bundle-mac-x86_64-20130522/sdk/platform-tools

Solution

  • With the help of kranteg & Opal I've come up with a working solution:

    #!/bin/bash
    /usr/bin/xcodebuild -scheme target1 clean archive;
    /usr/bin/xcodebuild -scheme target2 clean archive;
    /usr/bin/xcodebuild -scheme target3 clean archive;
    <...>
    

    Thanks again for the relentless community support, I would have given up otherwise :-)

    Note: I've found that each scheme has a post-action step for the "Archive" action, that I had forgotten about:

    xcrun -sdk iphoneos PackageApplication "$ARCHIVE_PRODUCTS_PATH/$INSTALL_PATH/$WRAPPER_NAME" -o "${HOME}/Desktop/${PRODUCT_NAME}.ipa"
    

    This automatically creates .ipa files for Ad-Hoc deployment. Maybe this interfered with the original build script by changing a working directory. However, I don't understand why that would not register with the pwd and echo $PATH logging.