How to output log to terminal from iOS simulator? - ios

Logging to Chrome is extremely slow for me to the point of being unusable so I'm trying to get it to log to the terminal instead. They provide a command react-native log-ios for this but it gives me this error:
error Cannot read property 'udid' of null. Run CLI with --verbose flag for more details.
which, like 99% of React Native errors, makes no sense to me.
Any idea how I can get this command to work? Or is there any system command, similar to adb logcat for Android, that I can use directly to print iOS Simulator log to the terminal?

Related

Debugging Cordova iOS plugin with NSLog, where does it output?

I followed the tutorial at the Cordova official website to create my first "hello world" program for iOS, and everything went successfully, and I'm able to run the example application in the simulator just fine. What I need is to test, use and if necessary fix an iOS plugin. I installed the plugin and it seems to have installed and works fine.
My problem is simple: I'm trying to output some debugging information from the Objective-C code of the plugin using NSLog(), but I have no idea where that output can be seen.
I am definitely editing the correct .m file (inside the platforms/ios/HelloWorld/Plugins/plugin-name directory), as eg. syntax errors show up and stop the "cordova emulate ios" command from completing successfully. So I'm certain that my NSLog() additions are being compiled in. I'm also certain that the functions in question are being called from the javascript. I just don't know where those messages are being outputted to.
In the simulator I try to select Debug > Open System Log... but nothing of what I'm printing appears there.
When I run "cordova emulate ios", it says "[ios-sim] logPath: /path/to/the/project/platforms/ios/cordova/console.log". However, there is no such file in that directory. (In fact, there is no file named "console.log" anywhere inside the project directory tree.)
NSLog logs to the simulated device's logarchive. You must select the simulator device in Console to see that, or you can use the CLI:
xcrun simctl spawn booted log show
xcrun simctl spawn booted log stream
etc...
Check the log command's help and man pages for filtering options.

Viewing console statements from command line in iOS React Native app?

When running an app in the Android Emulator, I can type adb logcat *:S ReactNative:V ReactNativeJS:V to view the console statements in a terminal, which is much faster than viewing them in Chrome or other debugger.
Is there a similar command in macOS to view the console statements of an app running in iOS simulator?
You can just stop the debugger and look for logs in Xcode or you can call this in terminal:
react-native log-ios
Source

Reading qDebug output of Apps on ios devices from command line

I am currently working on automated testing of Qt-Applications on devices running iOS. So far I am able to install and run these Applications fine, but I am unable to read their output. As far as I understood, reading this issue, Qt uses the gdb server to deliver the output of std::out and std::err to the Qt Creator but I can not get my head around on how to use this information. Besides the bundle identifier, I am given the .ipa-file of the application only. I have access to the applications code but I must not change it.
I use the libmobiledevice libraries to handle all tasks like connection, installation and execution of and on the device.
To summarize: I want to read the debug output of a Qt-written application displayed on my console, like it would be in the "Application output" window of my Creator.
I found a way using the imobiledevice libraries. By calling Idevicedebug -u <uuid> run de.foo.app I was able to execute the application. The qDebug output was prompted to std::out.
As the app crashed when started with a locked screen, I had to check for the display being idle by examining the output of idevicediagnostics ioreg IOPower first.
Now, half a year later, I found a solution that worked both elegant and stable.
I installed the ios-deploy tool using node:
npm install -g ios-deploy
Using this, I was able to install the app and listen to it's output via:
ios-deploy --debug --bundle path/to/my.app
I recieved the full qDebug, std::out and std::err output perfectly fine.
To uninstall the app, I simply added the -9 or --uninstall_only option:
ios-deploy --debug --bundle path/to/my.app --uninstall_only
Using this solution the app could be started reliably, without crashing with a locked screen

Corona SDK and lldb

Whether it possible to debug corona SDK application on iOS simulator?
I build a Corona SDK application for Xcode simulator and wrote next commands:
cd /Users/username/Library/Application\ Support/iPhone\ Simulator/7.0.3/Applications/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/app-name.app/
lldb
(lldb) attach --name "app-name" --waitfor
Then I run app in simulator and I get the next message from lldb:
error: attach failed: process did not stop (no such process or permission problem?)
Are you logged in to the Mac remotely (ssh or whatever)? You need to authorize debugging the first time you use the debugger. It's easy to verify if your machine is set up to allow debugging:
% /usr/sbin/DevToolsSecurity -status
Developer mode is currently enabled.
If it's not enabled, I think sudo /usr/sbin/DevToolsSecurity -enable may do the trick. If you're debugging locally, you should see a pop-up window asking you if you want to allow the debugging to happen. But when logged in remotely, you won't see that pop-up of course.

unable to run scripts on simulator from cron tab

We are using sikuli tool for mobile automation on our MAC OSX 10.7.3
I have written a shell script to open simulator and to run scripts on simulator
/Users/ezprintsqa/Downloads/FoneMonkey/bin/iphonesim launch /Users/ezprintsqa/Documents/Xcode/DerivedData/SnapCards- btmjdowsgmixpvdyfxfvhxtoihab/Build/Products/Debug-iphonesimulator/SnapCardsFoneMonkey.app&
/Users/ezprintsqa/Downloads/Sikuli-IDE.app/sikuli-ide.sh -r /Users/ezprintsqa/Downloads/SikuliWorkSpace/SnapcardsTestSuite1.sikuli
When I execute from command line I can see simulator opening and scripts getting executed on simulator.
But when I do same thing using cron tab I can see only simulator opening but the tool can't identify the simulator now to run scripts, the tool throws error message that it is unable to identify the simulator.
When the tool is able to identify the simulator while running from command prompt why is it unable to identify while running from crontab?
Thanks
You are saying:
the tool throws error message that it is unable to identify the simulator.
Do I understand right, that the script throws a FindFailed exception, meaning, that some image (might be the visual identification of the simulator window) is not found on the screen within the standard waiting time of 3 seconds?
I this is the case, you should give more time to the simulator to start up in the crontab case, either by adding a wait(n) at the beginning of the Sikuli script or use wait(image, n) to wait longer for the image to appear

Resources