iOS - How to pass build params in fastlane snapshot - xcodebuild

I am using fastlane snapshot tool for taking snapshot for app screens.
According to fastlane community, i need to run,
fastlane snapshot init
Then after configuring project ui test target, i need to run
fastlane snapshot
But if I want to provide some build parameters like, xcodebuild test test-only params, how can I do that. For example i want to build like,
xcodebuild test -workspace <path>
-scheme <name>
-destination <specifier>
-only-testing:TestBundleA/TestSuiteA/TestCaseA
-only-testing:TestBundleB/TestSuiteB
-only-testing:TestBundleC
I see,
fastlane snapshot --help
Then I added in Snapfile,
xcargs -only-testing:TestBundleB/TestSuiteB
But this gives error
(eval):36: syntax error, unexpected tSYMBEG, expecting keyword_do or
'{' or '(' only-testing:TestBundleB/TestSuiteB
How can i solve this error?

I am not familiar with running snapshot from the command line, so if you can, I would recommend creating a fastlane/Fastfile (or editing it if it already exists) to have a lane that calls snapshot with the options that you are looking for. You can call it with its various parameters as explained in the docs
The example shows you how snapshot could be called, and the Parameters table describes the other parameters you can pass to the fastlane Action.
To pass xcargs via the Snapfile, try xcargs "-only-testing:TestBundleB/TestSuiteB" in your Snapfile. See this Issue.

Related

How to skip tests in release part of build

We are currently using gradle-release-plugin.
Our release builds are twice as long due to unit and integration tests being run on both "SNAPSHOT" version and after the branch is "tagged".
here is the command line we execute in our release trigger:
./gradlew --info clean build release -Prelease.useAutomaticVersion=true
I read the plugin code and the doc and found "buildTasks" configuration but didn't find documentation or examples on them.
I'm sure we do something wrong but can't figure out what.
Thanks in advance

How do I see the logs added to the Xcode Build Phase Scripts in Azure DevOps pipeline?

I have a react native app within an nx monorepo that runs, archives, and builds successfully on my local machine.
I am trying to accomplish the same with Azure DevOps pipeline with the following XCode build task.
The Azure DevOps Xcode build task looks like this...
#Your build pipeline references an undefined variable named ‘Parameters.scheme’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.xcodeVersion’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘APPLE_CERTIFICATE_SIGNING_IDENTITY’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘APPLE_PROV_PROFILE_UUID’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- task: Xcode#5
displayName: 'Xcode Build to Generate the signed IPA'
inputs:
actions: 'clean build -verbose'
xcWorkspacePath: 'apps/my-app/ios/MyApp.xcworkspace'
scheme: '$(Parameters.scheme)'
xcodeVersion: '$(Parameters.xcodeVersion)'
packageApp: true
exportOptions: specify
exportMethod: 'ad-hoc'
signingOption: manual
signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
provisioningProfileUuid: '$(APPLE_PROV_PROFILE_UUID)'
In the pipeline logs, I observed that it runs a task close to this...
xcodebuild -sdk iphoneos -configuration Release -workspace ios/MyApp.xcworkspace -scheme MyApp clean build -verbose
I modified the paths as above and ran the task on local terminal and it builds successfully. It prints the logs I set in Xcode > Target (MyApp) > BuildPhases > Bundle React Native code and images as shown below
echo "\n 0. ⚛️🍀 DEBUG PIPELINE: Bundle React Native code and images \n"
echo "\n 1. ⚛️🍀 cd \$PROJECT_DIR/.."
pwd
ls
cd $PROJECT_DIR/..
export NODE_BINARY=node
./node_modules/react-native/scripts/react-native-xcode.sh
echo "\n 0. 🩸 DEBUG PIPELINE: Bundle React Native code and images::SCRIPT COMPLETED \n"
None of these logs show up in the pipeline. Even when I enable system diagnostics before running the pipeline with...
☑️ Enable system diagnostics
I have seen these related questions and answers and my attempt is at troubleshooting to see the what gets run.
Question: Does the Azure DevOps Xcode build task above use the same phase script? Does it remove the logs? Does it use another build phase script? How can I see the logs added to BuildPhase scripts in the AzurePipe line logs?
Thank you.

XCUITEST is not running while running from from terminal using xcodebuildcommand

I have more than 50 test cases in my UI-TEST scheme and I am running it via the below command
xcodebuild test -workspace tribo.xcworkspace -scheme triboUITests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone X,OS=12.4'
what happens is the RAM of my Mac machine shoots up and the system hangs up , I have attached the activity monitor report tooenter image description here
can anyone help me in running all XCUITEST cases present in scheme from terminal
The console command itself seems legit.
The RAM problem also could be caused by inaccurate resource management in test code.
Consider inspecting your code for possible memory leakings and other bugs.
You can run a specific test or tests as part of the xcodebuild invocation.
From the xcodebuild help command line:
-only-testing:TEST-IDENTIFIER constrains testing by specifying tests to include, and excluding other tests
-skip-testing constrains testing by specifying tests to exclude, but including other tests
-skip-testing:TEST-IDENTIFIER constrains testing by specifying tests to exclude, but including other tests
Using these commands may help you understand which tests are causing the issue.
You could also use the Xcode Memory Graph Debugger (see this link:
https://medium.com/zendesk-engineering/ios-identifying-memory-leaks-using-the-xcode-memory-graph-debugger-e84f097b9d15
Finally, you if you are trying to run all your tests in parallel, you may have too many simulators running on the machine.

Is it possible to run individual test cases/test classes on the command line with xcode 5?

I can run all unit tests using the following command:
xcodebuild test -workspace Project.xcworkspace -scheme Scheme -sdk iphonesimulator7.0 -destination platform='iOS Simulator',OS=7.0,name='iPhone Retina (4-inch)'
Is there anything I can pass to this to run individual unit tests/classes in the same way that you can using the Xcode UI?
Cheers.
Not that I know of, and it's not on the man page either. But you have such option in the excellent xctool (-only SomeTestTarget:SomeTestClass/testSomeMethod).
For those who are using later versions of Xcode (8.0+) and may run across this post in the future (like myself), this is now possible using the -only-testing flag, which is documented in the man page for xcodebuild. The format for using the flag is as follows:
xcodebuild \
-destination "$DEST" \
-workspace "$WRKSP" \
-scheme "$SCHEME" \
-only-testing:Target/Class/Method test
You can also omit elements from the path after the -only-testing flag, e.g. -only-testing:Scheme/Class will run all these tests within that class.
Here is a related Stackoverflow question, touching on the new functionality:
How to use xcodebuild with -only-testing and -skip-testing flag?
Another way is to edit the schemer of your test file and disable/enable the tests as you please. Then you can rerun the same command through the CLI and it will only run the tests you specified above.
If you're using Kiwi, you should supposedly be able to do it using the KW_SPEC environment variable. I haven't been able to, though: Running a single KIWI spec with xctool.

iOS: XCode 4.4.1: xcodebuild error - Unable to read diagnostics from file

So I would like to use xcodebuild in Terminal to create a build from a test application (called RunTeszt1). The app is an iOS single view application with nothing in it, just created and closed.
When I this from the Terminal, the build fails.
xcodebuild -target "RunTeszt1" -sdk "$iphoneos5" -configuration Debug
The error is:
Unable to read diagnostics from file "/var/folders/6s/cjw35hhs5lb6wpnx9m8lr2km0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/RunTeszt1-Prefix-eqntxoxxhhlzvieuipqbxfumbpxb/RunTeszt1-Prefix.pch.dia" (Invalid File): Bad header in diagnostics file
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
When I run the app from XCode (4.4.1), the build completes and everything is ok. However, If I run the Console app and inspect the results after hitting build button in XCode, I see the same error message in the console. Nevertheless the build succeeds and opens the simulator.
Is this really a bug in xcodebuild which should be sent to apple? If it is I imagine a bunch of people already sent it.
How can I either make the error go away, or stop it from cancelling the building process, so circumvent it like XCode does?
Turns out the problem was code signing. Even though I put Don't code sign in the build settings, it still hanged up on it. Also it seems "-sdk xxx" was also at fault (no matter what sdk I specified).
Running this command resulted in a successful build:
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -target RunTeszt2