Unit Tests fail to run in XCode/Xctool - ios

When I run my tests using Xcodebuild or Xctool, I see that the tool builds and installs the app into the simulator but fails to run the test. It is stuck forever in either Touching <app-name>.xctest when I use xcodebuild or Launching and Running tests when using xctool. I can see that the simulator is launched with its default homescreen but does not progress after that. This happens as part of a continuous integration environment I am trying to setup.
I do a clean test when using either tool. I also run xcrun simctl shutdown "iPhone 6" || true and killall "Simulator" || true before running the xcode commands to ensure the simulator is turned off. I also tried pre-launching the simulator and waiting before initiating the test command since I read somewhere that it could help. Please note that this issue does not happen always. It happens like around 3 out of 10 times but at times, it gets even more frequent. There is no logs/trails that I could work on to debug this issue. Any help/leads would be great!
Xcode Version: 7.0.1
Xctool Version: 0.2.7
Simulator: IPhone 6
OS: Yosemite (10.10.5)
Thanks

Related

Lost connection to the debugger on "iPhone" Launching App Xcode 11.3.1

I've been experiencing this issue a lot with Xcode 11.3.1 when launching the App on the simulator, sometimes just restarting Xcode works, sometimes I have to restart my computer in order to make the app run again. It never happened on Xcode 11.1 tho.
I have noticed that on the simulator i got an error regarding "com.apple.commcenter.coretelephony.xpc". So the fix was to run this in terminal:
xcrun simctl spawn booted log config --mode "level:off" --subsystem com.apple.CoreTelephony
The downside is that you lose the auto layout warnings.
https://stackoverflow.com/a/54692253/4041884

How do I get 'react-native-cli' to run my app in the specified hardware?

The React Native CLI will not run the specified simulator. When I enter
/usr/local/bin/node /usr/local/lib/node_modules/react-native-cli run-ios ‑‑simulator="iPhone X"
the simulator runs as expected, but insists on running in an iPhone 6, regardless of what simulator I specify, and if I select an additional hardware from the simulator app's menu, the one that launches does not show my project. (In fact, if I an iPhone X, it shows an app that I worked on some time ago instead.)
I've uninstalled and reinstalled the react-native-cli, and have no additional global ios-sim (though I had one once).
How do I get react-native-cli to run my app in the specified hardware?
My starting place for encountering these errors is simply (1) to install react-native-cli, (2) install WebStorm, (3) build a default React Native project there, and (4) run the project using the default iOS run configuration there. (WebStorm 2018.1.5; macOS 10.13.5; React Native CLI 2.0.1; Node 10.6.0)
The CLI goes through a few simple steps which you can step through here.
The first parameter is the output of running this from the command line:
xcrun simctl list --json devices
A few things to check first after running the xcrun command above:
Do you see multiple child nodes that start with 'iOS'? If so, you may have multiple versions of the simulators installed. The CLI will only look at the first version that it finds that starts with 'iOS'. So if there is only one simulator in that particular version, you're going to get that one all the time.
Find the iPhone 6 simulator, does it show it's state as Booted? If so, it will take priority if a simulator name is not provided
Is the iPhone X simulator availability listed as (available)?
Did you reboot the computer to kill any stale simulator processes? This should also reset the state and availability statuses of the simulators
Other than that, the cli does a pretty simple check:
If a simulator is Booted and no name is provided, start that one.
Launch the first simulator in the list if no name match was found using the name property

Xcode 9.1 with fastlane not running headless

I'm running fastlane scan for our UI Tests on a iPad Air 2 iOS 11 simulator and my understanding from this article https://dzone.com/articles/new-xcuitest-features-with-xcode-9-hands-on-explor is that it should run headless automatically.
But it's launching the simulator every time. Is there a xcargs that needs passed to make it run headless.
I don't see anything in the fastlane docs for scan that relates to headless.
Just close the simulator application before you run xcodebuild. Conversely, if you want to see the simulator during tests, start the simulator beforehand via Xcode -> Open Developer Tool -> Simulator.

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

How to debug an iOS app with lldb on the command line on a device without Xcode

Is is possible to launch and debug one of my iOS apps in development on an iPhone (or other iOS device) without using Xcode?
I would like to do this from the command line using lldb.
I figure that since it can be done with Xcode that it may be possible to debug strictly from within the terminal.
ios-deploy can do that.
brew install node
npm install -g ios-deploy
ios-deploy -d -W -b path/to/foo.app
It will copy the app bundle to your connected device, launch the app, and start an lldb session for the app.
I just tested it right now. OSX 10.12.6, iOS 11.0.2, Xcode 9.0.1.
it is possible to debug your app without using xcode on a jailbroken device all you need is to add entitlements on debug server if you wish to debug apps you did not build , there is a great explanation here http://iphonedevwiki.net/index.php/Debugserver , once you attached to the process on the device just launch lldb on your computer and debug

Resources