I'm using the Jenkins CI as build management tool on the build server and I am running my unit test cases using the below command through Jenkins.
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
xcodebuild -sdk iphonesimulator -project MyStore2.xcodeproj -scheme MyStore2 -configuration Debug RUN_APPLICATION_TESTS_WITH_IOS_SIM=YES ONLY_ACTIVE_ARCH=NO clean test 2>&1 | /usr/local/bin/ocunit2junit
The iPhone simulator is not launched from the Jenkins UI, whereas if I use the same command in command prompt, it is working fine.
The build console output is as below:
/Users/Shared/Jenkins/Home/workspace/iOSUnitTestCaseSample/MyStore2/Images.xcassets
2014-08-12 03:11:38.979 IBCocoaTouchImageCatalogTool[92947:303] CFPreferences: user home directory at file:///Users/Shared/Jenkins/Library/Application%20Support/iPhone%20Simulator/User/ is unavailable. User domains will be volatile.
/* com.apple.actool.compilation-results */
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2.app/LaunchImage-700-568h#2x.png
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2.app/Assets.car
/Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Intermediates/MyStore2.build/Debug-iphonesimulator/MyStore2.build/assetcatalog_generated_info.plist
.
.
.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2Tests.xctest/MyStore2Tests -o /Users/Shared/Jenkins/Library/Developer/Xcode/DerivedData/MyStore2-cfjvjlzuxlhdpddpszyhlozlqjdw/Build/Products/Debug-iphonesimulator/MyStore2Tests.xctest.dSYM
Please guide me on how to resolve this issue. Help Appreciated.
Thanks.
I've solved this in the past by using the JNLP client on the Jenkins slave and having a user logged in. My theory is that if you launch the slave agent via SSH, there is no windowing environment for the simulator to run in.
Another solution is to use ios-sim.
Related
This is an issue I've been facing for the past week.
I have an M1 Mac Mini setup as a self-hosted agent to run iOS related builds/archives through Azure Pipelines.
I'm able to build/archive locally on the machine itself using terminal. Mobile provisioning and code signing are setup and working fine.
When I run the agent interactively using run.sh, I am able to run the pipeline successfully. When I try running the agent as a launchd service using ./svc.sh install -> ./svc.sh start, it always fails with the same error:
** ARCHIVE FAILED **
The following build commands failed:
ValidateEmbeddedBinary /Users/<user>/Library/Developer/Xcode/DerivedData/<project>/Build/Intermediates.noindex/ArchiveIntermediates/<app-name>/BuildProductsPath/Debug-iphoneos/<app-name>.app (in target '<app-name>' from project '<project>')
(1 failure)
##[error]Bash exited with code '65'.
The command I'm using to archive is
xcodebuild -workspace ~/repos/<project>/<project>.xcworkspace -scheme <app-name> -allowProvisioningUpdates clean archive -archivePath build/<app-name> -destination generic/platform=iOS
Again, this command works when I run it locally and when I run the agent interactively.
I removed app/project names for privacy reasons.
I've searched high and low as to why this error is occurring and I've tried virtually all suggestions to fix it. For the life of me I don't know why the command would work locally and when the agent is run interactively, but does not work when the agent is run as a launchd service.
Edit: I’ve noticed a pattern: the archive fails with that error after every successful run. In other words the command successfully archives but when I run it again, it fails. If I run it once more, it’s successful. This occurs when running it through Azure Pipelines and locally via terminal. I have no words!
I am using Jenkins job for running current test cases for iOS app. using,
xcodebuild test ... | xcpretty
Although all tests are successful but Jenkins still marked build as failure.
How can I see the actual result?
Edit-1:
Even when i removed | xcpretty, still jobs marked as failure. Here are the full shell command,
xcodebuild test -workspace App.xcworkspace -scheme App -destination 'platform=iOS Simulator,name=iPhone 6, OS=10.2'
Finally the problem was solved by placing below line at the very begining of jenkins shell
#!/bin/sh
I have integrated my xcode project with jenkin.I have got xcode build succeeded, creating ipa but at the end "Build step 'Execute shell' marked build as failure" & Could not connect to SMTP host to send mail. Finished: FAILURE.
My Shell script is, xcodebuild -target EmailTests -configuration Debug -sdk iphonesimulator | ./ocunit2junit.rb SMTP details copied from Mac Mail--> Preferences to Jenkins Configuration.
Kindly help me to clear this issue.
Seems more like Jenkins configuration issue.
Go to Manage Jenkins -> Configure System and apply the changes as show in screenshot.
Try running your command:
xcodebuild -target EmailTests -configuration Debug -sdk iphonesimulator | ./ocunit2junit.rb from a shell in Terminal. If it has the same error when you run outside Jenkins you can stop worring about Jenkins. If it dose work, try to figure out how the 2 environments differ.
Also try connecting to the smtp server manually, from the same machine that you are running the test on. First look up the smpt server using nslookup then connect with telnet to tcp port 25. Here are details for checking the mail connection: https://www.port25.com/how-to-check-an-smtp-connection-with-a-manual-telnet-session-2/
I have integrated iOS project with Jenkins. To run the automation test cases I am using the below code in shell script.
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
export CODESIGN_ALLOCATE=`xcode-select -print-path`/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
xcodebuild -alltargets clean
xcodebuild -alltargets
xcodebuild -sdk iphonesimulator \
-project Myapp.xcodeProj \
-scheme Myapp-cal \
ONLY_ACTIVE_ARCH=NO \
CONFIGURATION_BUILD_DIR="$WORKSPACE/build" \
clean build
cucumber
The automation testing is working fine in xcode where as with Jenkins getting the below error.
Unable to auto detect APP_BUNDLE_PATH. Have you built your app for
simulator? Searched dir:
/Users/test/Library/Developer/Xcode/DerivedData/Myapp-fayplezntrxmdqeteknsfkkvtzla/Build/Products
Please build your app from Xcode You should build the -cal target.
Help appreciated
I believe all you need to do is export your APP_BUNDLE_PATH in your script before you call cucumber.
Something like this:
export APP_BUNDLE_PATH="${WORKSPACE}/build/Build/Products/Debug-iphonesimulator/Myapp-cal.app"
cucumber
To see an example of this in the wild see the briar-ios-example repo. [1]
FYI/BTW APP and APP_BUNDLE_PATH are interchangeable. [2]
[1] https://github.com/jmoody/briar-ios-example/blob/master/Briar/jenkins-calabash.sh
[2] http://calabashapi.xamarin.com/ios/file.ENVIRONMENT_VARIABLES.html
Deleting the contents of /Library/Developer/Xcode/DerivedData and compiling again solved this problem for me. I did not wanted to hardcode the APP_BUNDLE_PATH as I have multiple targets.
My error message was Unable to auto detect APP_BUNDLE_PATH.
I want to build a Xcode project from Terminal and then run it as required, also from Terminal.
I have been looking for a way to do this for a while now but only managed to find a method which works for the iPhone Simulator, not for the actual device it self.
Is this even possible? The reason I want to a Xcode project on a device from Terminal is because the application runs a series of automated tests and I would prefer to automate this process using a bash script.
Thanks
To build your xcode project from the command line using a bash script use:
/usr/bin/xcodebuild -target TargetYouWantToBuild -configuration Debug
Look at the man page for xcodebuild for more options.
We do this for our unit test suite target, and we use GHUnit.
This is the section of our build script for running the tests:
export GHUNIT_CLI=1
export WRITE_JUNIT_XML=1
clean
echo "Building Bamboo GHUnit Tests..."
OUTPUT=`/usr/bin/xcodebuild -target BambooAutomatedUnitTest -configuration Debug -sdk iphonesimulator4.3 build`
RESULT=`echo "$OUTPUT" | grep "\\*\\* BUILD "`
if [ "$RESULT" != "** BUILD SUCCEEDED **" ]
then
echo "$OUTPUT"
exit 1
fi
echo "${RESULT}\n"