为什么在此构建脚本中“找不到xcodebuild:command”?

时间:2014-06-27 06:22:23

标签: xcode bash sh xcodebuild

您好我的xcode项目的根目录中有以下内容:

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

但是,这只会执行第一行xcodebuild -scheme target1 clean;,然后产生

...
** CLEAN SUCCEEDED **

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

免责声明:我是一名绝对的Mac OS X / Unix新手。

编辑:根据kranteg的建议,我将pwd添加到脚本中:

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

输出:

/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

编辑2 :用echo $ PATH替换pwd产生更好的结果,现在脚本在失败之前执行前三个xcodebuild命令。但是,PATH变量似乎不受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

3 个答案:

答案 0 :(得分:3)

在kranteg&amp;的帮助下蛋白石我想出了一个有效的解决方案:

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

再次感谢社区的无情支持,否则我会放弃: - )

注意:我发现每个方案都有“存档”操作的后期操作步骤,我忘记了这一步骤:

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

这会自动为Ad-Hoc部署创建.ipa文件。也许这会通过更改工作目录来干扰原始构建脚本。但是,我不明白为什么不会在pwdecho $PATH日志记录中注册。

答案 1 :(得分:1)

确保您已安装Xcode的命令行工具。转到Xcode-&gt; Preferences ...命令,然后查找允许您下载其他软件包和文档的面板。 IIRC,可以从那里安装命令行工具。

答案 2 :(得分:1)

如果未为xcode设置命令行工具,则

xcodebuild命令将不起作用。

确保已选择最新的命令行工具(在Xcode> Preferences> Locations下)

enter image description here