Comments (17)
xcrun devicectl device install app --device 00008110-001XXXXXXXXXX ./xgen/Build/Products/Release-iphoneos/nilo.app xcrun devicectl device process launch --device 00008110-001XXXXXXXXXX file:///private/var/containers/Bundle/Application/1604D2D5-35F3-4E43-8B47-1DEF5D778480/nilo.app
devicectl
is not as simple to use, we print some results to std::out and it seems like there is no way to capture this data like ios-deploy used to do. Also, we are stuck installing, launching, and then continuously polling the device to see if the application ran, as there is no way to attach to process launchIn addition with
ios-deploy
I was able to easily upload files to the bundle and it seems like withdevicectl
I keep getting errors
With the latest pymobiledevice3 version from https://github.com/doronz88/pymobiledevice3 I have found a method how to establish remote debugging with an iPhone with iOS 17:
Create a rsd-Tunnel:
sudo python3 -m pymobiledevice3 remote start-tunnel --script-mode
-> will output the rsd data ($rsd_output)
Start debugserver on iPhone
python3 -m pymobiledevice3 developer debugserver start-server --rsd $rsd_output
(e.g. python3 -m pymobiledevice3 developer debugserver start-server --rsd fdf0:721a:e29b::1 57537
)
This will print something like this:
(lldb) platform select remote-ios
(lldb) target create /path/to/local/application.app
(lldb) script lldb.target.module[0].SetPlatformFileSpec(lldb.SBFileSpec('/private/var/containers/Bundle/Application/<APP-UUID>/application.app'))
(lldb) process connect connect://[fdf0:721a:e29b::1]:54437 <-- ACTUAL CONNECTION DETAILS!
(lldb) process launch
Using xcrun devicectl device install app
command to install the App from an archive will let us parse out the data which is needed to setup lldb:
install@DE011-CMXXXX Scripts % xcrun devicectl device install app --device 00008110-xxxxxxx /Users/install/Projects/build_http_communication_Qt/Release-iphoneos/QtTest.app
12:04:26 Acquired tunnel connection to device.
12:04:26 Enabling developer disk image services.
12:04:26 Acquired usage assertion.
42%... 57%... 60%... 62%... 66%... 68%... 72%... 74%... 76%... 80%... 84%... 88%... 92%... 96%... Complete!
App installed:
? bundleID: de.bender.qtcomponenttest
? installationURL: file:///private/var/containers/Bundle/Application/8D43DD90-B138-4C42-8BE8-2752CAB6A259/QtTest.app/
? launchServicesIdentifier: unknown
? databaseUUID: 5D6368B1-5A96-462B-B5AD-B9F12163FEEA
? databaseSequenceNumber: 1508
? options:
With this output we can setup lldb:
$ lldb
(lldb) platform select remote-ios
(lldb) target create /Users/install/Projects/build_http_communication_Qt/Release-iphoneos/QtTest.app
(lldb) script lldb.target.module[0].SetPlatformFileSpec(lldb.SBFileSpec('/private/var/containers/Bundle/Application/8D43DD90-B138-4C42-8BE8-2752CAB6A259/QtTest.app'))
(lldb) process connect connect://[fdf0:721a:e29b::1]:54437
(lldb) process launch
Will result in an starting iOS app with debug output to lldb.
Next step is to pipe this output to a file, std_out or something else.
Maybe someone how knows ios-deploy is able to integrate this stuff.
I end up in creating a zsh script which is creating and parsing all the stuff to get the steps above automated.
from ios-deploy.
@gabebear Nice! Maybe worth adding to the readme 🙂
Summary of install & just launch with devicectl:
xcrun devicectl device install app --device 00008110-001XXXXXXXXXX ./xgen/Build/Products/Release-iphoneos/nilo.app
xcrun devicectl device process launch --device 00008110-001XXXXXXXXXX file:///private/var/containers/Bundle/Application/1604D2D5-35F3-4E43-8B47-1DEF5D778480/nilo.app
You get the second path from the output from the install command, or just use the bundle ID (sadly the app name isn't enough, unlike for xctrace)
from ios-deploy.
I'm not sure if we want to have ios-deploy work with Xcode15; it's possible Xcode14 will be the final version supported. Apple has FINALLY created a non-hack mechanism with devicectl
(e.g. try running xcrun devicectl --help
). https://developer.apple.com/documentation/Updates/Xcode
from ios-deploy.
Ideally Apple will add a way to connect to lldb to devicectl.
Yep. That'd be pretty nice. With CoreDevice there are IPv6 tunnels created to each device. You can point lldb directly at one of those and connect to it. The filehandle/socket forwarder is no longer required. The trick is figuring out the port that the debugserver is running on. That seems a tad convoluted currently. Doable but convoluted. I did take your advice and submit a feedback suggestion.
from ios-deploy.
For anyone still wanting to deploy and debug from the command line, Apple added support natively to LLDB in Xcode 16 Beta. See my comment on the flutter repo here: flutter/flutter#133465 (comment)
Hope this helps!
from ios-deploy.
@megabitsenmzq sure, but it is nothing special. Just some quick and dirty bash parsing. Feel free to improve.
#!/bin/bash
set -x
###############################################################################
function show_help()
{
cat <<EOF
Usage:
$(basename $0) [options]
options
-h - show help and exit
example:
./ios-ebee-deploy.sh -b "/home/user/Projects/app_project/build_app/Release-iPhoneOS/iPhoneApp.app"
-i "iPhone UUID"
-p 'password' !!! <-- PLEASE KEEP CARE TO USE '' if password contains special chars --> !!!
-l "/home/user/logfile.out"
EOF
}
###############################################################################
while getopts b:i:p:l:h arg; do
case $arg in
h)
show_help
exit 0
;;
b)
app_path=${OPTARG}
;;
i)
device_id=${OPTARG}
;;
p)
sudo_pw=${OPTARG}
;;
l)
log_output=${OPTARG}
;;
*)
if [ $arg == ":" ]; then
echo "ERROR: Option \"-$OPTARG\" requires an argument."
else
echo "ERROR: $arg Unknown option \"-$OPTARG\"."
fi
show_help
exit 1
;;
esac
done
if [ -z "$app_path" ]; then
echo "Parameter -b is required. See -h for help."
exit 1
fi
if [ -z "$device_id" ]; then
echo "Parameter -i was not provided. Use devicectl to find first available iOS device."
device_id=$(echo `xcrun devicectl list devices | awk '/available \(/ {print($6)}'`)
if [ "$device_id" != "" ]; then
echo "Using device id: $device_id"
else
echo "Warning: Cannot detect device id! Maybe XCode is running?"
fi
fi
rm -rf tmp.o
rm -rf lldb.o
rm -rf install.o
rm -rf dynamic_data.sh
rm -rf lldb.commands
device_connected=$(echo `xcrun devicectl list devices | awk '/connected / {print($5)}' | awk -F'.' '{print($1)}'`)
if [ "$device_connected" != "" ]; then
echo "ERROR: Possible opened XCode instance detected. Please close XCode an restart this script! Make sure selected iPhone is not in 'connected' state (xcrun devicectl list devices)."
exit 1
fi
curl -sS "127.0.0.1:5555"
exit_code=$?
echo ""
if [ $exit_code -ne 0 ]; then
if [ $exit_code -eq 56 ]; then
echo "Tunnel-Server for getting rsd info is running but not reachable! Killing..."
process_id=$(echo `echo ${sudo_pw} | sudo -S lsof -i:5555 | tail -n1 | awk -F' ' '{print ($2)}'`)
echo ${sudo_pw} | sudo -S kill -9 ${process_id}
sleep 5
fi
fi
server_started=$(echo `nc -vz 127.0.0.1 5555 2>&1 | awk -F ' ' '{print $7}'`)
if [ ${server_started} == "succeeded!" ]; then
echo "Server already running! Try to get rsd info string."
else
echo ${sudo_pw} | sudo -S python3 -m pymobiledevice3 remote tunneld > server_start.o &
sleep 10
fi
device_hostname=$(echo `xcrun devicectl list devices | awk '/available \(/ {print($5)}' | awk -F'.' '{print($1)}'`)
rsd_output="$(echo `curl -s -H "Accept: application/json" 127.0.0.1:5555 | jq -r --arg var "$device_hostname" '.[$var][0]'`) $(echo `curl -s -H "Accept: application/json" 127.0.0.1:5555 | jq -r --arg var "$device_hostname" '.[$var][1]'`)"
echo "Using $rsd_output for --rsd option"
xcrun devicectl device install app --device ${device_id} ${app_path} > install.o
installation_url=$(cat install.o | grep 'installationURL' | awk -F 'file://' '{print $2}' | tr -d '\r\n' | sed 's/\/$//')
python3 -m pymobiledevice3 developer debugserver start-server --rsd ${rsd_output} > lldb.o &
sleep 5
connection_details=$(cat lldb.o | grep -o 'connect://\[.*\]:[0-9]*')
echo "app_path=${app_path}" >> dynamic_data.sh
echo "remote_app_path=${installation_url}" >> dynamic_data.sh
echo "connection_details=${connection_details}" >> dynamic_data.sh
source $(dirname $0)/lldb.sh
if [ -z "$log_output" ]; then
lldb -s lldb.commands
# | grep -v "\(lldb\)" &> ${app_path}/../../output.log
else
lldb -s lldb.commands | grep -v "\(lldb\)" &> ${log_output}
fi
lldb.sh:
source dynamic_data.sh
rm -rf lldb.commands
echo "platform select remote-ios" >> lldb.commands
echo "target create $app_path" >> lldb.commands
echo "script lldb.target.module[0].SetPlatformFileSpec(lldb.SBFileSpec('$remote_app_path'))" >> lldb.commands
echo "script old_debug = lldb.debugger.GetAsync()" >> lldb.commands
echo "script lldb.debugger.SetAsync(True)" >> lldb.commands
echo "process connect $connection_details" >> lldb.commands
echo "script lldb.debugger.SetAsync(old_debug)" >> lldb.commands
echo "process launch" >> lldb.commands
echo "exit" >> lldb.commands
from ios-deploy.
Even using xcrun to install/launch there's still the issue of connecting to lldb and managing stderr/stdout. That's the majority of what I use ios-deploy for. I think that purpose is still legit in xcode15-land
unless there's a simple command for that as well that should go in the readme?
from ios-deploy.
Ideally Apple will add a way to connect to lldb to devicectl.
Apple tracks feedback/radar reports to gauge interest in products. People who need iOS device debugging scripting support should file requests via https://feedbackassistant.apple.com/ . This could possibly get Apple to add this before the team that created devicectl moves to other things.
from ios-deploy.
xcrun devicectl device install app --device 00008110-001XXXXXXXXXX ./xgen/Build/Products/Release-iphoneos/nilo.app crun devicectl device process launch --device 00008110-001XXXXXXXXXX file:///private/var/containers/Bundle/Application/1604D2D5-35F3-4E43-8B47-1DEF5D778480/nilo.app
Seems Apple's devicectl is not easy to use, can we wrap it under the hood after Xcode 15?
from ios-deploy.
xcrun devicectl device install app --device 00008110-001XXXXXXXXXX ./xgen/Build/Products/Release-iphoneos/nilo.app
xcrun devicectl device process launch --device 00008110-001XXXXXXXXXX file:///private/var/containers/Bundle/Application/1604D2D5-35F3-4E43-8B47-1DEF5D778480/nilo.app
devicectl
is not as simple to use, we print some results to std::out and it seems like there is no way to capture this data like ios-deploy used to do. Also, we are stuck installing, launching, and then continuously polling the device to see if the application ran, as there is no way to attach to process launch
In addition with ios-deploy
I was able to easily upload files to the bundle and it seems like with devicectl
I keep getting errors
from ios-deploy.
I end up in creating a zsh script which is creating and parsing all the stuff to get the steps above automated.
Could you share your script? It will be so helpful.
from ios-deploy.
hi, sk2212,
I have some questions about your script.
I don't understand the code "curl -sS "127.0.0.1:5555"" for . On my mac, failed to connect . where is 5555 coming from ?
`
++ echo
- device_connected=
- '[' '' '!=' '' ']'
- curl -sS 127.0.0.1:5555
curl: (7) Failed to connect to 127.0.0.1 port 5555 after 0 ms: Couldn't connect to server - exit_code=
`
- echo ${sudo_pw} | sudo -S python3 -m pymobiledevice3 remote tunneld > server_start.o
On my mac , there is nothing output to server_start.o . On the other hand , I found server_start.o have no further using in the whole script .how do you get the rst output ?
I am the first time to use mac real machine debugging, please forgive my little white.
from ios-deploy.
Can anyone knows "127.0.0.1:5555" in sk2212's script? I really don't understand it's purpose. If someone knows,please share with me . I really appreciate.
from ios-deploy.
Can anyone knows "127.0.0.1:5555" in sk2212's script? I really don't understand it's purpose. If someone knows,please share with me . I really appreciate.
curl -sS "127.0.0.1:5555" is just to check if there is a response provided by tunnel server instance started with pymobiledevice3. Do you have pymobiledevice3 installed?
from ios-deploy.
Can anyone knows "127.0.0.1:5555" in sk2212's script? I really don't understand it's purpose. If someone knows,please share with me . I really appreciate.
curl -sS "127.0.0.1:5555" is just to check if there is a response provided by tunnel server instance started with pymobiledevice3. Do you have pymobiledevice3 installed?
@sk2212
Yes. I have installed pymobiledevice3, and following your instructions step by step, I am able to launch and debug apps installed on the phone using 'process launch'. However, when I try to use the script you provided to simplify the whole process, I find that 'server_start.o' is empty, resulting in an empty 'rsd_output'.
Given the presence of port 5555, I suspect this is a service launched locally by pymobiledevice3, but I couldn't find any documentation about this port in the pymobiledevice3 repository. I would be very grateful if you could provide me with the documentation for port 5555. Thank you very much.
from ios-deploy.
@laiyierjiangsu yeah, it seems that the standard port '5555' was changed in 'pymobiledevice3':
doronz88/pymobiledevice3@6b0145e
from ios-deploy.
@sk2212 Thank you for your help. I think I should read through the source code of pymobiledevice3 to thoroughly understand its mechanisms. It looks very interesting."
from ios-deploy.
Related Issues (20)
- 1.12.2 release was not completed HOT 3
- VendContainer support for HouseArrest service HOT 1
- Cant build after uninstalling this package HOT 2
- A way to launch in suspended state, to run debugger commands before an early crash HOT 1
- Python multithreading ios-deploy with subprocess hangs HOT 1
- can I run an app with bundleid not bundle
- ios-deploy -c -j does not return a correct json format HOT 1
- ios-deploy -c -j does not return correct json format HOT 1
- ios-deploy - Unable to mount developer disk image ios16 HOT 3
- App launched with `--justlaunch` immediately crashes when trying to print to stdout HOT 2
- Debug logs are not printed to iphone systen log when running ios-deploy command over Wi-Fi connected iPhones.
- iOS
- Vision Pro support? HOT 1
- Is there a way to connect ios devices without using Xcode GUI?
- ios-deploy[14310:720906] [ !! ] Error 0xe8000080: This application does not support this kind of device. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)
- Can ios-deploy support to debug App Extension(appex)
- Is there a way to download crash logs from the device?
- ios-deploy: SystemError: <built-in function SBProcess_GetSTDOUT> returned NULL without setting an error
- Install apk
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-deploy.