XCode 6 Unit Testing Without Building - ios

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

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'

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

Xcode 7 XCTest app memory monitor

I created bunch of XCode7 UI tests that I run for every developer build, I wonder if I can track application memory usage from point when I start tests until all my tests finished so it could be analyzed later?
I start my tests by command-line:
xcodebuild test -scheme "AppSchema" -configuration Debug -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6s Plus,OS=9.3'

Terminal Command build xcode project for 64 bit with all other also

I am using below command :
xcodebuild -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -sdk iphonesimulator -configuration Debug
xcodebuild -project $PROJECT_NAME.xcodeproj -scheme $PROJECT_NAME -sdk iphoneos -configuration Debug
for building the application it's working but I need to build our application with iphone/ipad retina 64 bit but it' not working.
for combining
lipo -create "${WS_DIR}/Build/Debug-iphoneos/libRPCCore.a" "${WS_DIR}/Build/Debug-iphonesimulator/libCore.a" -output "${WS_DIR}/Build/RPCLib/libCore.a"
I am not able to build the application for ipad/ipahone retina 64 bit application using terminal command. please help to create the build script.
I suspect this is because you have Build Active Architecture Only set for Debug mode, which is the default setting I believe. This is because there is no need to build for all architectures during debugging as the build is expected to run only on the device being used for debugging.
This is normally turned off for release and you can test this from the command line by using -configuration Release.
BTW I don't believe you need to specify the -sdk option to xcodebuild as the build settings should have that covered.

Xcode 5 xcodebuild unit test seems to return status successful when tests fail

Hi I'm following examples from Test Driven iOS development and I've written a few unit tests with the new Xcode 5 and XCTest. My tests fail with the Xcode GUI client, but when I use xcodebuild the status code is 0.
xcodebuild -target TemperatureConverterTests build
and
echo $?
returns 0.
The tests are suppose to fail. Is the command to run the test cases correct?
xcodebuild command has changed with xcode 5. Here is a script to run Unit tests :
Don't forget that schemes must be shared, you've got to create your Tests Scheme, Xcode 5 didn't create it for you
xcodebuild -workspace MyApp.xcworkspace -scheme myApp-Tests -destination=build -configuration Debug -sdk iphonesimulator7.0 ONLY_ACTIVE_ARCH=YES clean build test
Hope this helps :)
If you don't want (as you rarely need) a separate (and annoying) "scheme" for your testing "target"... Use a variation on #Rémy Virin's answer...
xcodebuild -scheme YourAppOrLib -target YourAppOrLibTests
As pictured below.. this allows you to run the Unit tests for the target.... without cluttering the project with non-production schemes... In this case IndexedKeyMap is my YourAppOrLib.

Resources