How to capture iPhone app debug logs - iphone

I was researching libimobiledevice to basically capture the specific iPhone app logs. I have tried with the idevicesyslog command, but it gives me all the system logs along with my app.
I tried with idevicesyslog -d | grep com.example.Example but does not give me the info I am looking for.
I am interested in the debug logs of my app.
I know there is a way to capture it from the organizer in Xcode but I don't want to do it that way. I am planning to do it programmatically and then integrate with Appium automation script.

I was able to achieve this with idevicesyslog -d | grep '"https://ac.XYZ.COM" >& t' write to the file "t" and then clear the file and move on to the next step.
This I was able to achieve but the only issue I am facing here is that I need to update the command, like it wont write to log on real time basis when I am interacting with the device. If someone can suggest a way where it log to the file in a real time that would be great.

You can use -m option from idevicesyslog, this option is for "only print messages that contain STRING"
Example:
idevicesyslog -m "Vantage"
Hope this method is work for you :)

Related

Diagnose watch utility

I have a script that runs in the background which uses watch to monitor a directory for changes. This works just fine. However, I had a need for the script which runs the monitoring script to be run as daemon. The daemon is running as the same user, but now watch is returning "1 Various failures."
I suspect that there is some environment variable that is not set right, but there are too many to use trial and error to diagnose the issue. And unfortunately, "Various failures" is not very helpful. Any ideas how I might diagnose this?
The command is
watch -d -t -g ls -l
I think something like the following can be used as a work-around.
diff <(ls -l) <(sleep 1; ls -l)
I finally discovered the following on stderr.
Error opening terminal: unknown.
It was easily resolved by the answer to error opening terminal. So it did turn out to be an environment variable. I don't see this error message in the code. Perhaps it occurs when making a system call that needs the terminal.

How do I access the login history and wake-up reason on macOS Sierra?

Can someone tell me what code do I use to access login history (successful/failed login attempt & time) and wake-up reason (why the computer is waken from sleep) on Sierra?
Thanks!
Find wake reason:
log show --predicate 'eventMessage contains "Wake reason"'
Show login history:
last | grep -i ttys
If you're on a version that predates Sierra, the log command doesn't exist. Use the following instead:
syslog | grep -i "Wake reason"

Xcode - Passing Bash Commands With A Jailbroken Device

I'd like to know how it would be possible to execute bash commands on a jailbroken iOS device with Xcode? I'm not bothered about the code signing process because I already have a developer account.
I've tried using these 2 commands:
system("cd /var/mobile/Documents");
system("mkdir myNewFolder");
But Xcode returns "Cannot create directory, permission denied".
I know for definite that this is possible. Basically, I want to be using commands such as dpkg and apt commands.
Thanks in advance,
Declan
In UNIX like OS's like iOS you can use the 'Sudo' command to run as root.
To use in one line you need to use UNIX pipes like this:
system("echo yourPassword | sudo -S yourCommand");
You need to make sure sudo is installed on your device, not sure if it is by default.
Some more info here: On a jailbroken iPhone, how can I run commands as root?

On a jailbroken iPhone, how can I run commands as root?

I want to login as a root using system call in Xcode. I try this code without success:
System("su");
System("alpine");
or
System("su root");
System("alpine");
or
System("su root alpine");
When I google it I came to know that this is done using NSTask or NSPipe.
Can anybody tell me how it possible to run multiple system commands using NSTask and NSPipe?
Please give me some hints about this or another method to do this. I am using this application on jailbroken iPhone.
Some more details are here.
If you want to launch something as root you may use sudo.
Example of it's usage in one line with the password:
echo <password> | sudo -S <command>

How can I start X11 window with no display associated

I'd like to start Firefox for example with no display associated and eventually take a screenshot with import.
Can I in fact make it periodically with cronjobs?
I'm now making a ssh -X connection, take the xwininfo for the window started in background and everything's OK. But I'd like to automate it.
You could start Firefox inside Xvfb.
If you gave Xvfb its -fbdir option then you would also have the option to take your screenshot from the Xvfb framebuffer file. You would probably want to specify the same geometry for Xvfb and Firefox.
How about starting firefox inside a vncserver?
You can capture the value for $DISPLAY using grep
e.g.
export DISPLAY=`vncserver 2>&1 | egrep --only-matching ":[0-9]+" | head -n1`