xctool doesn't run with the requested iOS version - ios

I am running iOS tests on Circle CI using Xcode 6.4 and iOS 8.4 with this command:
xctool -workspace ios.xcworkspace -scheme ios test -sdk iphonesimulator8.4
But when the simulator runs, it fails to run my tests and I receive this error:
Test did not run: The simulator failed to start, or the TEST_HOST
application failed to run. Simulator error: Exception encountered
connecting to CoreSimulatorBridge: Unable to connect to
CoreSimulatorBridge
Looking at the logs, it looks like the simulator actually tries to run against iOS 9:
run-test iosTests.xctest (iphonesimulator9.0, iPhone 4s, application-test)
Is there a way to force it to run on iOS 8.4 so the tests would run?

I had the same issue recently on Circle CI. I'm not sure if it's related to xctool's newest version (0.2.7) or not, but adding this fixed it for me:
-destination platform='iOS Simulator,OS=8.4,name=iPhone 6'
So the full command in your case should be:
xctool -workspace ios.xcworkspace -scheme ios test -sdk iphonesimulator8.4 -destination platform='iOS Simulator,OS=8.4,name=iPhone 6'

Related

Run UITests from command line Apple Watch

I'm having troubles while running XCUITests on iPhone and paired apple watch (simulators) simultaneously using terminal. I can do it by hitting "test button" for each of my uitests targets separately, it works just fine, but I need to do it
1 - from command line
2 - simultaneously
However, I am able to run uitests from command line for the same iPhone simulator (that is paired with apple watch simulator) using
xcodebuild -workspace MyApp.xcworkspace -scheme 'MyApp' -destination 'name=iPhone 11' test
It works as expected- launches simulator and run tests
The problem is:
When I do the same for paired apple watch (it doesn't matter separately or simultaneously with this iPhone) tests for apple watch doesn't launch at all
xcodebuild -workspace MyApp.xcworkspace -scheme 'MyApp WatchKit App' -destination 'name=iPhone 11' test
Terminal says that:
The requested device could not be found because no available devices matched the request.
Available destinations for the "WatchTesterApp WatchKit App" scheme:
{ platform:iOS Simulator, id:2B6CA009-BF6B-4437-9E80-18D53EB003BA, OS:14.5, name:iPhone 11 }
But this device is here and listed as available
So, any suggestions? maybe someone had similar issue?
I will appreciate any help
So, after a long investigation and a long list of possible fixes that resolved nothing, I updated Xcode and tried to run the same command, which didn't work either and only after creating new clean project using new Xcode it finally worked.
I used:
xcodebuild test -workspace WatchTesterAppExample.xcworkspace -scheme 'WatchTesterAppExample WatchKit App' -destination 'platform=WatchOS Simulator,name=Apple Watch Series 7 - 45mm' &
xcodebuild test -workspace WatchTesterAppExample.xcworkspace -scheme 'WatchTesterAppExample' -destination 'platform=iOS Simulator,name=iPhone 13'
It worked for me on the simulators, didn't try it on real device yet
Interesting fact: I am still able to see this error in some case, especially when I don't specify platform in the 'destination'

react-native run-ios builds sporadically

react-native-cli: 2.0.1
react-native: 0.58.4
When I use react-native cli invoking build ios to simulator, it is not building any app. It just opens IOS simulator.
This is everything what i get:
Found Xcode project HelloWorld.xcodeproj
Launching iPhone 6s (iOS 12.1)...
Building using "xcodebuild -project HelloWorld.xcodeproj -configuration Debug -scheme HelloWorld -destination id=32CE8569-3EE3-4DDD-9963-E0ED0E8DA946 -derivedDataPath build"
User defaults from command line:
IDEDerivedDataPathOverride = /Users/tokra/Documents/Code/bitbucket.fork/rn-test/HelloWorld/ios/build
I remember it built only once, since then I cannot force rebuild.
Is there any way how to force build xcode in cli using react-native?

Starting the simulator in XCode 9 (not headless)

I am trying to run both my unit and ui tests with xcodebuild like:
$ xcodebuild -scheme "MyAppScheme" -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=11.0' build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
The problem is that the simulator doesn't start but instead is running heedlessly.
I am aware of the so called "headless simulator" introduced in XCode 9. Any ideas of how to run the tests with xcodebuild and launch the emulator ?
As far as I know there are no options to allow you to run the tests on a not headless Simulator.
However if a Simulator is already launched the tests will run on that Simulator instead of a headless one. So you can first launch the Simulator and then run the tests:
$ open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app && xcodebuild -scheme "MyAppScheme" -destination 'platform=iOS Simulator,name=iPhone 7 Plus,OS=11.0' build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO

XCodebuild not running tests on Simulator

I am running the following command from command line to build/test my workspace. The idea is to port it eventually to a CI system. But what happens is that one of the runs succeed but all of the following ones fail. They fail in an odd manner in that the build completes as part of the command but then, I see the message which kicks off the simulator and I see the simulator up but the tests are never run on it. The command is either hung on it forever or it fails with no error message. I tried using xcrun simctl erase all before the command to make sure the simulator is clean. I also tried avoiding specifying derivedDatapath and OBJROOT hoping that would make the builds clean but so far, I am stuck here.
xcodebuild test -workspace <workspace-name> -scheme <scheme-name> -configuration Coverage -sdk iphonesimulator -destination platform='iOS Simulator',OS=9.0,name='iPhone 6'
The final error I see is /usr/bin/touch -c /home-folder/Library/Developer/Xcode/DerivedData/.../Build/Products/Coverage-iphonesimulator/Tests.xctest ** TEST FAILED **
The code runs smoothly from within XCode and the tests always pass. I believe this is some issue with the terminal app connecting to the simulator or the simulator being in a weird state after an earlier run but I could not figure out what could be causing the problem. Any suggestions would be great.
XCode Version: 7.0.1
I don't know if that is the issue, but shouldn't test be at the end of the line? Like this:
xcodebuild -workspace <workspace-name> -scheme <scheme-name> -configuration Coverage -sdk iphonesimulator -destination platform='iOS Simulator',OS=9.0,name='iPhone 6' test

XCode 6 Unit Testing Without Building

Is there a way to prevent the app from building when I am just unit testing? When I run the test it builds the app and that takes minutes. I have written the tests in Swift and targets ios 8.
In Xcode 8+, you can pass the "test-without-building" option.
$ xcodebuild -workspace <your_xcworkspace> -scheme <your_scheme> -sdk iphonesimulator -destination ‘platform=iOS Simulator,name=<your_simulator>,OS=10.2’ test-without-building
Read more here: https://medium.com/xcblog/speed-up-ios-ci-using-test-without-building-xctestrun-and-fastlane-a982b0060676

Resources