【问题标题】:Xcode Run from Other App / Command Line / Apple ScriptXcode 从其他应用程序/命令行/Apple 脚本运行
【发布时间】:2017-09-01 13:01:58
【问题描述】:

是否可以让 Xcode 在后台但通过脚本编译和运行当前项目?

我主要使用 AppCode 进行开发,但想通过热键从 Xcode 运行。 AppCode 没有正确显示编译进度条(第二个屏幕上的 Xcode 可以),而且 AppCode 的调试能力不如 Xcode 先进。否则 AppCode 会更快更好。

【问题讨论】:

    标签: xcode bash applescript appcode app-code


    【解决方案1】:

    这可能来自 AppleScript,这是一个示例脚本(在 Sierra 和 Xcode 版本 8.3.3 上测试):

    tell application "Xcode"
        tell active workspace document to if exists then
            repeat until (loaded) -- Whether the workspace document has finished loading after being opened
                delay 1
            end repeat
            run -- Invoke the "run" scheme action
        end if
    end tell
    

    在特定设备上运行:我没有要测试的设备,但我使用模拟器,试试这个脚本:

    tell application "Xcode"
        tell active workspace document to if exists then
            repeat until (loaded) -- Whether the workspace document has finished loading after being opened
                delay 1
            end repeat
            --**** run on a specific device ****
            set active run destination to run destination "iPad Pro (12.9 inch)" -- *** change it to the name of your device  ***
    
            set schAction to run -- Invoke the "run" scheme action
            repeat while (get status of schAction) is in {not yet started, running} -- exit the loop when the status is (‌cancelled, failed, ‌error occurred or ‌succeeded), so I press the stop button in Xcode, or I delete the application in the simulator or I quit the simulator.
                delay 3
            end repeat
    
            --**** run on another specific device ****
            set active run destination to run destination "iPhone 7" -- *** change it to the name of your device  ***
            run
        end if
    end tell
    

    【讨论】:

    • 哇,速度太快了,太棒了!谢谢!您是否也知道在特定设备上运行?我正在制作一款实时多人游戏,我经常需要在两台设备上运行。在一台设备上运行会很酷,等它完成后再在另一台设备上运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-19
    • 1970-01-01
    • 1970-01-01
    • 2014-07-24
    • 1970-01-01
    • 2017-01-12
    相关资源
    最近更新 更多