I am running test using xctool, and I would like to be able to choose the simulator. I am using the following line:
xctool -workspace MyProject.xcworkspace -scheme MyProject test -reporter junit:test-results.xml -reporter teamcity -sdk iphonesimulator
However, the simulator that is open is the iPhone 4s simulator. Does anybody knows how to select the iPhone 6 simulator.
Using the -destination flag you can select a specific device to be run for your simulator :
-destination platform='iOS Simulator',OS=8.4,name='iPhone 6'
You should try the following command (replacing MyProject by the name of your project):
xctool -workspace MyProject.xcworkspace -scheme MyProject test -reporter junit:test-results.xml -reporter teamcity -sdk iphonesimulator -destination platform='iOS Simulator',OS=8.4,name='iPhone 6'
Related
When I run my UITest from XCode they all pass correctly but when I use xcodebuild - some of them fail with error:
Failure: UITestBase.swift:63: Failed to get matching snapshot: Lost connection to the application (pid 43193).
Currently I'm using 11.6, it did work fine on Xcode 10.x, xcodebuild points to correct Xcode where tests pass from IDE
xcodebuild command that I'm using:
xcodebuild clean test -workspace APP.xcworkspace -scheme APPUITests -configuration Release OTHER_SWIFT_FLAGS="-DCOCOAPODS -DAPPProdTarget" -destination "platform=iOS Simulator,name=iPhone 11,OS=13.6"
I am currently want to create a debug simulator build using xcodebuild command rather than xcode IDE.
however, I always see a "debug-iphoneos" folder is generated, which is for the real device. I expected the simulator output folder "Debug-iphonesimulator"
Can anyone take a look at my script and suggest why the script is not working for simulator?
xcodebuild -scheme "TestApp" -configuration "Debug" -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' -workspace TestApp.xcworkspace clean archive -archivePath build/TestApp PROVISIONING_PROFILE="$provisioningUUID" CODE_SIGN_IDENTITY="$codeSignIdentity"
now I can run successfully as below:
xcodebuild -arch i386 -sdk iphonesimulator9.3 -workspace "$app.xcworkspace" -scheme "$scheme" -configuration "Debug"
You should run the following instead:
xcodebuild -arch i386 -sdk iphonesimulator9.1 -workspace [name].xcworkspace -scheme [targetName or ProjectName] ONLY_ACTIVE_ARCH=NO VALID_ARCHS="i386 x86_64"
where iphonesimulator9.1 depends on which iPhone Simulator you installed.
I try to compile my app for UITesting and in a second time run the UITest on iOS simulator. But I need to do this in 2 times.
In one time I use :
xcodebuild -workspace './MyApp.xcworkspace' -scheme 'MyScheme' -derivedDataPath '~/Documents/derived_data/' -destination 'platform=iOS Simulator,id=6EE927C0-FC0E-4235-8915-3BFF1F128B76,OS=9.2' build test | xcpretty
Any Idea how to copy and launch MyApp.app, MyAppUITests-Runner.app in the simulator?
Thanks.
Alak
Edit:
Anyway to launch something like :
xcrun simctl launch "UITest"
and get xcactivitylog from this ?
try this:
xcodebuild -workspace App.xcworkspace -scheme "App-Scheme" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.1' test
it will compile the App and run the UI Test in the simulator.
i want to get my project's code coverage (which is managed by cocoapods), i run the following cmd :
xcodebuild -scheme KVODemo -configuration Debug -destination 'platform=iOS Simulator,name=iPhone 6' -enableCodeCoverage YES -workspace KVODemo.xcworkspace test
but i can not find the Coverage.profdata file (for normal project which is not managed by cocoapods is under the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata)
i just want to know how to get the code coverage for cocoa pods project.
ok , after a detail look at the cmd xcodebuild , i noticed something.
here is some info in the "man xcodebuild":
xcodebuild -showBuildSettings
[-project name.xcodeproj |
[-workspace name.xcworkspace -scheme schemename]]
the $PROJECT_TEMP_ROOT i mentioned in my question is the result of
xcodebuild -showBuildSettings |grep PROJECT_TEMP_ROOT
and this should the same as the xcodebuild -showBuildSettings -project xxx.xcodeproj
because my project is managed by cocoa pods, so i should get the $PROJECT_TEMP_ROOT in this way :
xcodebuild -showBuildSettings -workspace xxx.xcworkspace -scheme xxx
and finally , find the Coverage.profdata in the $PROJECT_TEMP_ROOT/CodeCoverage/$PROJECT_NAME/Coverage.profdata
I'm trying to launch an iOS app tests through command line, from a Jenkins Job.
If I launch the command in my user's console, works ok, the command is:
xcodebuild test -scheme demoIC -destination 'platform=iOS Simulator,id=E6954360-11D9-49E0-9008-A8EE6BA1ACFC'
It's supposed Jenkins uses 'jenkins' user for launching jobs, so I have done:
su - jenkins
And the when I launch the same command, I got an error:
2015-02-16 18:21:41.215 xcodebuild[3952:1303] iPhoneSimulator: Could not launch simulator: -10810
You can give a try to this, it worked for me:
xcrun xcodebuild -workspace $Project_Name.xcworkspace -scheme "$Build_Test_Scheme" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=13.2.2' -derivedDataPath './output' test