如何在Xcode中一次在多个目的地"构建和运行"?

Bla*_*laz 18 iphone build ipad ios-simulator xcode5

如何多个目的地(例如,iPhone,iPad和iSimulator)上同时运行项目Xcode产品选项Xcode多个目的地


有2个相关问题:

  1. Xcode 4 - 一键构建到多个设备?
  2. 只需单击一下即可在模拟器和手机上运行

1ˢᵗ问题(据说)有一个答案,但我无法弄清楚究竟应该如何使用Aggregate目标(如果这是正确的方向),显然也不是Josh Kahane,OP; "答案"仍以某种方式得到/仍被接受.

2ⁿᵈ问题被关闭为"重复",好像1ˢᵗ提供了一个(可行的)答案.


添加了赏金:(如何)可以Aggregate同时使用多个目标Build & Run?或许可以Build & Run通过一些.sh脚本使用同时实现多个xcodebuild?还有其他可能解决方案

kit*_*rol 15

我遇到了同样的问题,所以我写了一个Xcode插件来帮助解决这个问题.我发现它比AppleScript选项更强大,更容易调用.

该插件被称为KPRunEverywhereXcodePlugin,并可通过恶魔或在GitHub上:https://github.com/kitschpatrol/KPRunEverywhereXcodePlugin

新菜单项

希望这可以帮助!


Bla*_*laz 11

它实际上比我想象的要简单.这会AppleScript带来一些痛苦Xcode:

tell application "Xcode"
    activate
end tell

tell application "System Events"
    tell application process "Xcode"
        click menu item "1st iDevice Name" of menu 1 of menu item "Destination" of menu 1 of menu bar item "Product" of menu bar 1
        click menu item "Run" of menu 1 of menu bar item "Product" of menu bar 1
        delay 5
        click menu item "2nd iDevice Name" of menu 1 of menu item "Destination" of menu 1 of menu bar item "Product" of menu bar 1
        click menu item "Run" of menu 1 of menu bar item "Product" of menu bar 1
        delay 5
        click menu item "iPhone 6.1 Simulator" of menu 1 of menu item "Destination" of menu 1 of menu bar item "Product" of menu bar 1            
        click menu item "Run" of menu 1 of menu bar item "Product" of menu bar 1
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)
  1. 将上面保存AppleScript.app.(自定义delay您的机器.)
  2. 创建新ServiceAutomator:选择Launch Application.app从上一步中选择.
  3. 保存Service上一步并为其指定键盘快捷键.提示:避免使用快捷方式^,因为它会显示此对话框: 在此输入图像描述

当然,这不是严格意义上的同时 "构建和运行",但它肯定会在目的地之间手动琐事.


Iva*_*son 5

这是一个将在所有连接的 iOS 设备上构建和运行的脚本。使用方法:

  1. 打开“自动化器”。
  2. 创建一个新的“快速操作”。
  3. 为“工作流程接收”选择“无输入”。
  4. 为应用程序选择 Xcode。
  5. 添加“运行 JavaScript”操作并粘贴脚本。
  6. 另存为“Run on All”,您现在可以从 Xcode 的 Xcode -> Services 菜单访问它。

JavaScript:

function run(input, parameters)
{
    var xcode = Application("Xcode");
    var ws = xcode.activeWorkspaceDocument();
    var genericDest = null;
    var devices = [];
    ws.runDestinations().forEach(function(runDest)
    {
        if (runDest.platform() != "iphoneos")
            return;
        if (runDest.device().generic())
        {
            genericDest = runDest;
        }
        else
        {
            devices.push(runDest);
        }
    });
    devices.forEach(function(device)
    {
        ws.activeRunDestination = device;
        var buildResult = ws.run();
        while (true)
        {
            if (buildResult.completed())
                break;
            if (buildResult.buildLog() && buildResult.buildLog().endsWith("Build succeeded\n"))
                break;
            delay(1);
        }
        delay(1);
    });
}
Run Code Online (Sandbox Code Playgroud)