How can one run a project on multiple destinations (say, iPhone, iPad and iSimulator) at once?
There are 2 related questions:
The 1ˢᵗ question (supposedly) has an answer, but I can't figure out how exactly should you use the Aggregate
target (if this is the right direction at all), and apparently neither could Josh Kahane, the OP; the "answer" still somehow got/remained accepted.
The 2ⁿᵈ question was closed down as a "duplicate", as if the 1ˢᵗ one provided a (workable) answer.
Added a bounty: (how) can one use Aggregate
target for simultaneous, multiple Build & Run
? Perhaps one can achieve simultaneous, multiple Build & Run
via some .sh
script using xcodebuild
? Any other possible solution?
I ran into the same issue, so I wrote an Xcode plugin to help out with this. I found it to be more robust and easier to invoke than the AppleScript options.
The plugin is called KPRunEverywhereXcodePlugin and is available via Alcatraz or on GitHub: https://github.com/kitschpatrol/KPRunEverywhereXcodePlugin
Hope this helps!
It's actually simpler than I thought. This AppleScript
puts some pain out of 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
AppleScript
as an .app
. (Customize delay
s to your machine.)Service
in Automator
: choose Launch Application
and select the .app
from previous step.Service
from previous step and give it a keyboard shortcut. Tip: avoid shortcuts with ^, since it will bring up this dialog:
Granted, this isn't strictly a simultaneous 'Build & Run', but it sure beats manually trifling between destinations.
Here is a script that will build and run on all connected iOS devices. To use:
Javscript:
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);
});
}
It would indeed be nice to have multiple uploads at once with Xcode. However as I understand it, aggregate
only allows you to compile multiple targets, not run them.
Given the second part of you question (after the edit) I can point you to another way to do it. You won't have xcode attached (but gdb in console mode) and you should be able to make it simultaneous on several device, although this was not the primary goal. This particular solution doesn't work with simulator, but there are other methods for those.
launching iOS App from Mac OS X console
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With