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

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

Related

Attach lldb to iPhone from command line

While attaching lldb to iPhone works from within Xcode. It is flaky at times. I wonder if it is because XCode has some additional checks before attaching to a process in iPhone. I'd like to debug an iPhone app from command line. lldb has some tutorial that suggest using platform select but that command is unsuccessful in even connecting.
$ (lldb) platform select remote-ios
Platform: remote-ios
Connected: no
Am I missing something?
This question has been asked earlier but has no correct answers:
Debugging iPhone App from Command Line
Attach LLDB to app on iPhone connected to computer - Command line
Probably the easiest way to do this is using ios-deploy e.g.
ios-deploy --bundle=<bundle.app> --debug
The above command will install your application bundle to the attached iOS device, and launch it with an lldb session connected.

Not able to launch app in iOS simulator in vscode

I am new to vscode, I tried running my code in iOS simulator but its not showing the simulator in the first place.
the options i get are
view android emulators
view iOS simulators
But when I click on view iOS simulators I get a pop up saying
" Something went wrong fetching you iOS simulators! Make sure you have Xcode installed. Try running this command in your terminal: instruments -s devices "
You may need to run this command, when VSCode tries access the simulator there may be error which says
Cannot find "xcodebuild". Xcode 11.0.0 or greater is required to
develop for iOS. Encountered error while building for device.
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

How to output log to terminal from iOS simulator?

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?

Cordova - console.log file does not exist when using iOS Simulator

When I run cordova run ios --emulator the script exits successfully and tells me, that there's a file (console.log) inside platforms/ios/cordova but there's no such file although I used console.log several times in my code.
Also, Safari does not show my device in the developer menu when it's connected via USB and running the app. I used cordova run ios --device to run the app.
Am I looking in the wrong place? Does the script lie? :D

Calabash can't connect to simulator

I'm trying to run some Calabash UI tests in my app but am running into trouble connecting to my simulator. I'm trying to just connect view the calabash-ios console, but am running into the following error:
WARNING
Warning Trying to connect to simulator that was not launched by Calabash/instruments.
To fix this you must let Calabash or instruments launch the app.
Query will work, but gestures will not.
I've run the app view my -cal target and have successfully seen the message Started LPHTTP server on port 37265. Here's some more info on Calabash/my setup:
xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
xcodebuild -version
Xcode 7.0
Build version 7A218
calabash-ios version
0.14.3
server_version
=> {"app_id"=>"com.solstice.discoverfinancialenterprise.mobile", "outcome"=>"SUCCESS", "server_port"=>37265, "version"=>"0.14.3", "app_name"=>"Discover", "system"=>"x86_64", "simulator_device"=>"iPhone", "simulator"=>"", "app_version"=>"1", "short_version_string"=>"6.6.1 UAT", "iphone_app_emulated_on_ipad"=>false, "app_base_sdk"=>"iphonesimulator9.0", "form_factor"=>"iphone 4in", "git"=>{"revision"=>"c2d009b", "remote_origin"=>"git#github.com:calabash/calabash-ios-server.git", "branch"=>"master"}, "screen_dimensions"=>{"sample"=>1, "height"=>1136, "width"=>640, "scale"=>2}, "4inch"=>true, "iOS_version"=>"8.4"}
Sorry the JSON isn't formatted, my console spat it out in an unformatted way.
I've used a few different simulators, iPhone 6, iOS 9 and iOS 8.3, and an iPhone 5s iOS 8.4. Does anyone know anything I need to do differently to get this to connect to my simulator?
+100 for including all the information about your environment.
Please update to Calabash 0.16.4 which is compatible with your Xcode version.
I'm trying to just connect view the calabash-ios console, but am running into the following error:
Can you show how you launched console and what command you tried to run?
Typically, you want something like this:
$ APP=/path/to/Your.app calabash-ios console
> start_test_server_in_background
You must let calabash launch the app or you will not be able to perform gestures.
APP and APP_BUNDLE_PATH are synonymous.
http://calabashapi.xamarin.com/ios/file.ENVIRONMENT_VARIABLES.html#label-APP+and+APP_BUNDLE_PATH

Resources