Development
Conditionally Running Tests in TestNG
Jeroen van Erp
09 Oct, 2012
When running a unit test target needing an entitlement (keychain access) it does not work out of the box on Xcode. You get some descriptive error in the console about a “missing entitlement”. Everything works fine on the Simulator though.
Often this is a case of the executable bundle’s code signature not begin valid anymore because a testing bundle was added/linked to the executable before deployment to the device. Easiest fix is to add a new “Run Script Build Phase” with the content:
codesign --verify --force --sign "$CODE_SIGN_IDENTITY" "$CODESIGNING_FOLDER_PATH"
Now try (cleaning and) running your unit tests again. Good chance it now works.
I think you mean “… undescriptive error …”
I still not understand how to run the unit test on a real device. Where the signing step above should be run ? Please help !
When I run this command:
xcodebuild test -project myapp.xcodeproj -scheme myapp-tests -sdk iphonesimulator
all tests run successfully on emulator.
I want to run the test on the real device and try this command:
xcodebuild test -project myapp.xcodeproj -scheme myapp-tests -sdk iphoneos
Build settings from command line:
SDKROOT = iphoneos8.1
xcodebuild: error: Failed to build project acc with scheme acc-tests.
Reason: Xcode cannot run using the selected device.
@Chi Thu Le: This could be any number of things. I would first try and get it running in Xcode itself, if that works, start digging.
You also need the correct settings for the SDK and Architecture. Especially the SDK one (“-sdk”) is the one you’re looking for.
I got it work with following command line:
xcodebuild test -project myapp.xcodeproj -scheme myapp-tests -sdk iphoneos -destination name=’Chi Thu Le’s iPhone’
Thank you Jeroen for quick response.