我想爲iPhone模擬器應用程序相關的Xcode項目設置命令行參數。如何通過AppleScript將命令行參數傳遞給Xcode項目?
當我嘗試運行下面的腳本行 「做出新的發射參數與性能{名:」文件:///Users/aakash/Desktop/sample_h.html「活動:是}」
給出錯誤: 執行錯誤:Xcode出現錯誤:無法將該元素製作或移動到該容器中。 (-10024)
這裏的腳本:
!/bin/zsh
BUILD_PATH=$(dirname $0)
while [[ -z $BUILD_FILE && $BUILD_PATH != "/" ]]; do
BUILD_FILE=$(find $BUILD_PATH -name '*.xcodeproj' -maxdepth 1)
BUILD_PATH=$(dirname $BUILD_PATH)
done
if [[ -z $BUILD_FILE ]]; then
echo "Couldn't find an xcode project file in directory"
exit 1
fi
open -a Xcode "$BUILD_FILE"
BUILD_FILE=${BUILD_FILE//\//:}
SIMULATOR_SDKS=(/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/*.sdk)
SIMULATOR_SDK=${SIMULATOR_SDKS[-1]}
SIMULATOR_SDK_STRING=$(basename ${(L)SIMULATOR_SDK%.[a-z]*})
if [[ -z $SIMULATOR_SDK ]]; then
echo "Couldn't find a simulator SDK"
exit 1
fi
echo $BUILD_FILE
echo $BUILD_PATH
osascript <<SCRIPT
application "iPhone Simulator" quit
application "iPhone Simulator" activate
tell application "Xcode"
open "$BUILD_FILE"
set targetProject to project of active project document
tell targetProject
set active build configuration type to build configuration type "Debug"
set active SDK to "$SIMULATOR_SDK_STRING"
set value of build setting "SDKROOT" of build configuration "Debug" of active target to "$SIMULATOR_SDK"
make new launch argument with properties{name:"file:///Users/aakash/Desktop/sample_h.html",active:no}
if (build targetProject) is equal to "Build succeeded" then
launch targetProject
else
application "iPhone Simulator" quit
end if
end tell
end tell
SCRIPT
任何線索??? 是否有任何其他方式來設置Xcode項目的參數還是我做錯了? 請幫忙。
xcodebuild聯編不與iPhone合作模擬器應用程序。您必須在Xcode中啓動「build and go」來運行應用程序。 – Freakotrotter 2010-10-20 15:56:40