我明白,这个问题已经有问题了,但是阅读了我能找到的东西(特别是这个: Tell AppleScript To Build XCode Project),他们似乎都是几岁,答案似乎不适用于当前版本Xcode中. 与链接的问题类似,我试图
与链接的问题类似,我试图自动打开Xcode项目,构建它,然后在iPhone模拟器(v4.3)中运行应用程序.该项目是Selenium项目的iPhoneDriver(详见这里:http://code.google.com/p/selenium/wiki/IPhoneDriver)
根据另一个问题的答案,我写了以下脚本:
tell application "Xcode" open "/Users/<username>/Documents/Code/Selenium/iphone/iWebDriver.xcodeproj" tell project "iWebDriver" clean build try debug end try end tell end tell
不幸的是,当我运行这个我得到以下内容:
tell application "Xcode" open "/Users/ben.adderson/Documents/Code/Selenium/iphone/iWebDriver.xcodeproj" --> project document "iWebDriver.xcodeproj" clean project "iWebDriver" --> missing value build project "iWebDriver" --> missing value debug project "iWebDriver" --> error number -1708 end tell
如果我只运行打开的命令,Xcode打开项目没有问题.但是,一旦我包含脚本的其余部分,Dock中的Xcode图标就会弹出,但是除了AppleScript编辑器之外,还有这一点.
有人建议我做错了什么?这是我第一次使用AppleScript或Xcode,所以我很努力地诊断问题.
我试过看Xcode AppleScript字典,但没有工作的例子,我无法确定我需要的语法.
提前感谢任何帮助!
使用AppleScript和命令行工具(xcodebuild)的混合,我想出了这一点:-- This script will clean, build then run the project at the path below. -- You will need to slightly modify this script if you have more than one xcodeproject at this path set pathOfXcodeProject to "/Users/<username>/Documents/Code/Selenium/iphone/iWebDriver.xcodeproj" -- End of configuration do shell script "cd " & pathOfXcodeProject & " && /usr/bin/xcodebuild clean build " tell application "Xcode" open pathOfXcodeProject activate end tell tell application "System Events" get system attribute "sysv" if result is greater than or equal to 4144 then -- Mac OS X 10.3.0 if UI elements enabled then tell application process "Xcode" click menu item "Run" of menu 1 of menu bar item "Product" of menu bar 1 end tell else beep display dialog "GUI Scripting is not enabled" & return & return & "Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again." with icon stop if button returned of result is "OK" then tell application "System Preferences" activate set current pane to pane "com.apple.preference.universalaccess" end tell end if end if else beep display dialog "This computer cannot run this script" & return & return & "The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer." with icon caution buttons {"Quit"} default button "Quit" end if end tell
让我知道,如果这适用于你.我在Lion的Xcode 4.2.1测试了一个iPhone项目.