Skip to content

Commit 4187c48

Browse files
committed
[iOS export] Restore one-click deploy device enumeration using Xcode.
1 parent 1753893 commit 4187c48

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

platform/ios/export/export_plugin.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,42 @@ void EditorExportPlatformIOS::_check_for_changes_poll_thread(void *ud) {
27352735
}
27362736
}
27372737

2738+
// Enum devices (via Xcode).
2739+
if (ea->has_runnable_preset.is_set() && _check_xcode_install() && (FileAccess::exists("/usr/bin/xcrun") || FileAccess::exists("/bin/xcrun"))) {
2740+
String devices;
2741+
List<String> args;
2742+
args.push_back("devicectl");
2743+
args.push_back("list");
2744+
args.push_back("devices");
2745+
args.push_back("-j");
2746+
args.push_back("-");
2747+
args.push_back("-q");
2748+
int ec = 0;
2749+
Error err = OS::get_singleton()->execute("xcrun", args, &devices, &ec, true);
2750+
if (err == OK && ec == 0) {
2751+
Ref<JSON> json;
2752+
json.instantiate();
2753+
err = json->parse(devices);
2754+
if (err == OK) {
2755+
const Dictionary &data = json->get_data();
2756+
const Dictionary &result = data["result"];
2757+
const Array &devices = result["devices"];
2758+
for (int i = 0; i < devices.size(); i++) {
2759+
const Dictionary &device_info = devices[i];
2760+
const Dictionary &conn_props = device_info["connectionProperties"];
2761+
const Dictionary &dev_props = device_info["deviceProperties"];
2762+
if (conn_props["pairingState"] == "paired" && dev_props["developerModeStatus"] == "enabled") {
2763+
Device nd;
2764+
nd.id = device_info["identifier"];
2765+
nd.name = dev_props["name"].operator String() + " (devicectl, " + ((conn_props["transportType"] == "localNetwork") ? "network" : "wired") + ")";
2766+
nd.wifi = conn_props["transportType"] == "localNetwork";
2767+
ldevices.push_back(nd);
2768+
}
2769+
}
2770+
}
2771+
}
2772+
}
2773+
27382774
// Update device list.
27392775
{
27402776
MutexLock lock(ea->device_lock);
@@ -2922,7 +2958,7 @@ Error EditorExportPlatformIOS::run(const Ref<EditorExportPreset> &p_preset, int
29222958
}
29232959
}
29242960
} else {
2925-
// Deploy and run on real device.
2961+
// Deploy and run on real device (via Xcode).
29262962
if (ep.step("Installing to device...", 3)) {
29272963
CLEANUP_AND_RETURN(ERR_SKIP);
29282964
} else {

0 commit comments

Comments
 (0)