我希望从AppCode切换到Xcode并继续在同一行上编辑文件。
基于UI Automation的解决方案似乎有效。
没有UI自动化是如何做到这一点的任何解决方案;无需显示Open Quickly
对话框并输入FileName:LineNumber
?
谢谢!
基于UI自动化的解决方案
下面的代码会打开File -> Open Quickly ...
对话框,然后会输入File or Symbol
搜索字段,最后会点击Enter
:
//
// File: openFileInXcode.scpt
//
function run(argv) {
locationToOpen = argv[0]
if (locationToOpen == undefined) {
doSysLog("Nothing to do. Exiting...")
return
}
openFileinXcode(locationToOpen)
}
function openFileinXcode(location) {
var appXcode = Application('Xcode')
appXcode.activate()
doSysLog("Opening file: " + location)
delay(0.2)
var appSysEvents = Application('System Events')
appSysEvents.keystroke('o', { using: ['command down', 'shift down'] })
appSysEvents.keystroke(location)
appSysEvents.keyCode(36)
}
function doSysLog(message) {
app = Application.currentApplication()
app.includeStandardAdditions = true
app.doShellScript('syslog -s -l W "WaveLabs Automation: ' + message + '"')
console.log(message)
}
从命令行使用:
osascript -l JavaScript "/path/to/openFileInXcode.scpt" "AppDelegate.swift:11"
AppCode的用法:
File -> Preferences -> Tools -> External Tools
$FileName$:$LineNumber$
) 更新07.06.2016 :External Tool
设置的详细说明:
/bin/bash
-c "[[ -r ~/.bashrc ]] && . ~/.bashrc; osascript -l JavaScript \"$PATH_TO_YOUR_SCRIPTS_DIR/OpenFileInXcode.scpt\" \"$FileName$:$LineNumber$\""
$ProjectFileDir$