diff --git a/README.md b/README.md
index 97f8cc0..c1850ae 100644
--- a/README.md
+++ b/README.md
@@ -1,92 +1,89 @@
-# iOS Build for testing
+# Xcode Build for testing for iOS
-Build xctestrun bundle for your project.
+[![Step changelog](https://shields.io/github/v/release/bitrise-steplib/steps-xcode-build-for-test?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/steps-xcode-build-for-test/releases)
-## How to use this Step
+Performs xcodebuild's build-for-testing action
-Can be run directly with the [bitrise CLI](https://github.com/bitrise-io/bitrise),
-just `git clone` this repository, `cd` into it's folder in your Terminal/Command Line
-and call `bitrise run test`.
+
+Description
-*Check the `bitrise.yml` file for required inputs which have to be
-added to your `.bitrise.secrets.yml` file!*
+The Step runs Xcode's `xcodebuild` command with the `build-for-testing` option. This builds your app for testing and also creates an `.xctestrun` file.
-Step by step:
+### Configuring the Step
-1. Open up your Terminal / Command Line
-2. `git clone` the repository
-3. `cd` into the directory of the step (the one you just `git clone`d)
-5. Create a `.bitrise.secrets.yml` file in the same directory of `bitrise.yml`
- (the `.bitrise.secrets.yml` is a git ignored file, you can store your secrets in it)
-6. Check the `bitrise.yml` file for any secret you should set in `.bitrise.secrets.yml`
- * Best practice is to mark these options with something like `# define these in your .bitrise.secrets.yml`, in the `app:envs` section.
-7. Once you have all the required secret parameters in your `.bitrise.secrets.yml` you can just run this step with the [bitrise CLI](https://github.com/bitrise-io/bitrise): `bitrise run test`
+At a minimum, the Step needs valid values for three inputs:
-An example `.bitrise.secrets.yml` file:
+- **Project (or Workspace) path**: This is the path to the `.xcodeproj` or `.xcworkspace` file. In most cases, leave it on the default value.
+- **Scheme name**: The name of your Xcode scheme. By default, the Step will use the scheme that was set when you added the app on Bitrise.
+- **Device destination**: The device and platform type to build the tests for. For available values call, `man xcodebuild` and check the Destinations section.
+We also recommend checking out our [System reports page](https://github.com/bitrise-io/bitrise.io/tree/master/system_reports) on GitHub: you can check out the available, pre-installed simulators and other tools.
-```
-envs:
-- A_SECRET_PARAM_ONE: the value for secret one
-- A_SECRET_PARAM_TWO: the value for secret two
-```
+Optionally, you can define the configuration to use in the **Configuration name** input. Normally, the scheme defines the configuration type, such as **debug** or **release**.
-## How to create your own step
+The Step can also cache your Swift PM dependencies. To enable caching, make sure the **Enable caching of Swift Package Manager packages** input is set to `swift_packages`.
-1. Create a new git repository for your step (**don't fork** the *step template*, create a *new* repository)
-2. Copy the [step template](https://github.com/bitrise-steplib/step-template) files into your repository
-3. Fill the `step.sh` with your functionality
-4. Wire out your inputs to `step.yml` (`inputs` section)
-5. Fill out the other parts of the `step.yml` too
-6. Provide test values for the inputs in the `bitrise.yml`
-7. Run your step with `bitrise run test` - if it works, you're ready
+### Troubleshooting
-__For Step development guidelines & best practices__ check this documentation: [https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md](https://github.com/bitrise-io/bitrise/blob/master/_docs/step-development-guideline.md).
+In the **Debug** option group, you can:
-**NOTE:**
+- Add additional flags to the xcodebuild command.
+- Enable verbose logging.
+- Change the output directory path and the output tool.
-If you want to use your step in your project's `bitrise.yml`:
+### Useful links
-1. git push the step into it's repository
-2. reference it in your `bitrise.yml` with the `git::PUBLIC-GIT-CLONE-URL@BRANCH` step reference style:
+- [Running Xcode tests](https://devcenter.bitrise.io/testing/running-xcode-tests/)
+- [Building from the Command Line with Xcode](https://developer.apple.com/library/archive/technotes/tn2339/_index.html)
-```
-- git::https://github.com/user/my-step.git@branch:
- title: My step
- inputs:
- - my_input_1: "my value 1"
- - my_input_2: "my value 2"
-```
+### Related Steps
-You can find more examples of step reference styles
-in the [bitrise CLI repository](https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml#L65).
+- [Xcode Test for iOS](https://www.bitrise.io/integrations/steps/xcode-test)
+- [Xcode Analyze](https://www.bitrise.io/integrations/steps/xcode-analyze)
+
-## How to contribute to this Step
+## 🧩 Get started
-1. Fork this repository
-2. `git clone` it
-3. Create a branch you'll work on
-4. To use/test the step just follow the **How to use this Step** section
-5. Do the changes you want to
-6. Run/test the step before sending your contribution
- * You can also test the step in your `bitrise` project, either on your Mac or on [bitrise.io](https://www.bitrise.io)
- * You just have to replace the step ID in your project's `bitrise.yml` with either a relative path, or with a git URL format
- * (relative) path format: instead of `- original-step-id:` use `- path::./relative/path/of/script/on/your/Mac:`
- * direct git URL format: instead of `- original-step-id:` use `- git::https://github.com/user/step.git@branch:`
- * You can find more example of alternative step referencing at: https://github.com/bitrise-io/bitrise/blob/master/_examples/tutorials/steps-and-workflows/bitrise.yml
-7. Once you're done just commit your changes & create a Pull Request
+Add this step directly to your workflow in the [Bitrise Workflow Editor](https://devcenter.bitrise.io/steps-and-workflows/steps-and-workflows-index/).
+You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise).
-## Share your own Step
+## ⚙️ Configuration
-You can share your Step or step version with the [bitrise CLI](https://github.com/bitrise-io/bitrise). If you use the `bitrise.yml` included in this repository, all you have to do is:
+
+Inputs
-1. In your Terminal / Command Line `cd` into this directory (where the `bitrise.yml` of the step is located)
-1. Run: `bitrise run test` to test the step
-1. Run: `bitrise run audit-this-step` to audit the `step.yml`
-1. Check the `share-this-step` workflow in the `bitrise.yml`, and fill out the
- `envs` if you haven't done so already (don't forget to bump the version number if this is an update
- of your step!)
-1. Then run: `bitrise run share-this-step` to share the step (version) you specified in the `envs`
-1. Send the Pull Request, as described in the logs of `bitrise run share-this-step`
+| Key | Description | Flags | Default |
+| --- | --- | --- | --- |
+| `project_path` | Xcode Project (`.xcodeproj`) or Workspace (`.xcworkspace`) path. The input value sets xcodebuild's `-project` or `-workspace` option. | required | `$BITRISE_PROJECT_PATH` |
+| `scheme` | Xcode Scheme name. The input value sets xcodebuild's `-scheme` option. | required | `$BITRISE_SCHEME` |
+| `configuration` | Xcode Build Configuration. If not specified, the default Build Configuration will be used. The input value sets xcodebuild's `-configuration` option. | required | `Debug` |
+| `destination` | Destination specifier describes the device to use as a destination. The input value sets xcodebuild's `-destination` option. | required | `generic/platform=iOS` |
+| `xcconfig_content` | Build settings to override the project's build settings. Build settings must be separated by newline character (`\n`). Example: ``` COMPILER_INDEX_STORE_ENABLE = NO ONLY_ACTIVE_ARCH[config=Debug][sdk=*][arch=*] = YES ``` The input value sets xcodebuild's `-xcconfig` option. | | `COMPILER_INDEX_STORE_ENABLE = NO` |
+| `xcodebuild_options` | Additional options to be added to the executed xcodebuild command. | | |
+| `log_formatter` | Defines how xcodebuild command's log is formatted. Available options: - `xcpretty`: The xcodebuild command’s output will be prettified by xcpretty. - `xcodebuild`: Only the last 20 lines of raw xcodebuild output will be visible in the build log. The raw xcodebuild log will be exported in both cases. | required | `xcpretty` |
+| `output_dir` | This directory will contain the generated artifacts. | required | `$BITRISE_DEPLOY_DIR` |
+| `cache_level` | Defines what cache content should be automatically collected. Available options: - `none`: Disable collecting cache content. - `swift_packages`: Collect Swift PM packages added to the Xcode project. | required | `swift_packages` |
+| `verbose_log` | If this input is set, the Step will print additional logs for debugging. | required | `no` |
+
-That's all ;)
+
+Outputs
+
+| Environment Variable | Description |
+| --- | --- |
+| `BITRISE_TEST_DIR_PATH` | |
+| `BITRISE_XCTESTRUN_FILE_PATH` | |
+| `BITRISE_TEST_BUNDLE_ZIP_PATH` | |
+| `BITRISE_XCODE_RAW_RESULT_TEXT_PATH` | This is the path of the raw build results log file. |
+
+
+## 🙋 Contributing
+
+We welcome [pull requests](https://github.com/bitrise-steplib/steps-xcode-build-for-test/pulls) and [issues](https://github.com/bitrise-steplib/steps-xcode-build-for-test/issues) against this repository.
+
+For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://devcenter.bitrise.io/bitrise-cli/run-your-first-build/).
+
+Learn more about developing steps:
+
+- [Create your own step](https://devcenter.bitrise.io/contributors/create-your-own-step/)
+- [Testing your Step](https://devcenter.bitrise.io/contributors/testing-and-versioning-your-steps/)
diff --git a/bitrise.yml b/bitrise.yml
index a8c99d4..6f4dcb1 100644
--- a/bitrise.yml
+++ b/bitrise.yml
@@ -1,166 +1,42 @@
-format_version: 6
+format_version: "11"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
-app:
- envs:
- - ORIG_BITRISE_SOURCE_DIR: $BITRISE_SOURCE_DIR
-
workflows:
- test:
- before_run:
- - audit-this-step
- - go-tests
- after_run:
- - test_objc_all
- - test_swiftpm
-
- test_swiftpm:
- envs:
- - SAMPLE_APP_URL: https://github.com/bitrise-io/sample-apps-ios-swiftpm.git
- - SAMPLE_APP_BRANCH: codesign-update
- - PROJECT_PATH: sample-swiftpm.xcodeproj
- - SCHEME: "sample swiftpm"
- after_run:
- - _checkout
- - _run_and_test_output
-
- test_objc_all:
- envs:
- - SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
- - SAMPLE_APP_BRANCH: renamed-scheme
- - PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj
- after_run:
- - _checkout
- - test_build_output_renamed
- - test_build_output_spaces
- - test_build_output_renamed_custom_build_options
- - test_build_output_spaces_custom_build_options
-
- test_build_output_renamed:
- envs:
- - SCHEME: "renamed_scheme"
- - XCODE_BUILD_OPTIONS: ""
- - PROJECT_PATH: $PROJECT_PATH
- after_run:
- - _run_and_test_output
-
- test_build_output_spaces:
- envs:
- - SCHEME: "Scheme with spaces"
- - XCODE_BUILD_OPTIONS: ""
- - PROJECT_PATH: $PROJECT_PATH
- after_run:
- - _run_and_test_output
-
- test_build_output_renamed_custom_build_options:
- envs:
- - SCHEME: "renamed_scheme"
- - XCODE_BUILD_OPTIONS: "-derivedDataPath ./ddata -destination generic/platform=iOS"
- - PROJECT_PATH: $PROJECT_PATH
- after_run:
- - _run_and_test_output
-
- test_build_output_spaces_custom_build_options:
- envs:
- - SCHEME: "Scheme with spaces"
- - XCODE_BUILD_OPTIONS: "-derivedDataPath ./ddata -destination generic/platform=iOS"
- - PROJECT_PATH: $PROJECT_PATH
- after_run:
- - _run_and_test_output
+ check:
+ steps:
+ - git::https://github.com/bitrise-steplib/steps-check.git: {}
- _run_and_test_output:
- envs:
- - SCHEME: $SCHEME
- - PROJECT_PATH: $PROJECT_PATH
+ e2e:
steps:
- - path::./:
- title: Step Test
- run_if: true
+ - git::https://github.com/bitrise-steplib/steps-check.git:
inputs:
- - project_path: $PROJECT_PATH
- - scheme: $SCHEME
- - output_tool: xcodebuild
- - xcodebuild_options: $XCODE_BUILD_OPTIONS
- after_run:
- - _output_test
+ - workflow: e2e
- _checkout:
+ sample:
+ envs:
+ - TEST_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
+ - TEST_APP_BRANCH: renamed-scheme
+ - BITRISE_PROJECT_PATH: ios-simple-objc/ios-simple-objc.xcodeproj
+ - BITRISE_SCHEME: renamed_scheme
steps:
- script:
inputs:
- content: |-
- #!/bin/bash
+ #!/bin/env bash
set -ex
- rm -rf "$ORIG_BITRISE_SOURCE_DIR/_tmp"
- mkdir -p "$ORIG_BITRISE_SOURCE_DIR/_tmp"
- - change-workdir:
- title: Switch working dir to _tmp dir
- run_if: true
- inputs:
- - path: "$ORIG_BITRISE_SOURCE_DIR/_tmp"
- - is_create_path: true
+ rm -rf "./_tmp"
- git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
inputs:
- - repository_url: $SAMPLE_APP_URL
- - clone_into_dir: .
- - branch: $SAMPLE_APP_BRANCH
- - commit: $SAMPLE_APP_COMMIT
- - certificate-and-profile-installer:
-
- _output_test:
- steps:
- - script:
- title: Output check
- inputs:
- - content: |-
- #!/bin/bash
- set -e
- if [[ "$BITRISE_DEPLOY_DIR/testbundle.zip" != "$BITRISE_TEST_BUNDLE_ZIP_PATH" ]] ; then
- echo "BITRISE_TEST_BUNDLE_ZIP_PATH (\"$BITRISE_TEST_BUNDLE_ZIP_PATH\") should be: \"$BITRISE_DEPLOY_DIR/testbundle.zip\""
- exit 1
- fi
- if [[ "$BITRISE_DEPLOY_DIR/Debug-iphoneos" != "$BITRISE_TEST_DIR_PATH" ]] ; then
- echo "BITRISE_TEST_DIR_PATH (\"$BITRISE_TEST_DIR_PATH\") should be: \"$BITRISE_DEPLOY_DIR/Debug-iphoneos\""
- exit 1
- fi
- if [[ "$BITRISE_XCTESTRUN_FILE_PATH" =~ "$BITRISE_DEPLOY_DIR/${SCHEME}_iphoneos[0-9]{2}.[0-9]{1,2}-arm64e.xctestrun" ]] ; then
- echo "BITRISE_XCTESTRUN_FILE_PATH (\"$BITRISE_XCTESTRUN_FILE_PATH\") should be: \"$BITRISE_DEPLOY_DIR/${SCHEME}_iphoneos{{sdk-version}}-arm64e.xctestrun\""
- exit 1
- fi
-
- echo "BITRISE_TEST_BUNDLE_ZIP_PATH: $BITRISE_TEST_BUNDLE_ZIP_PATH"
- echo "BITRISE_TEST_DIR_PATH: $BITRISE_TEST_DIR_PATH"
- echo "BITRISE_XCTESTRUN_FILE_PATH: $BITRISE_XCTESTRUN_FILE_PATH"
-
- go-tests:
- steps:
- - go-list:
- - golint:
- - errcheck:
- - go-test:
-
- dep-update:
- title: Dep update
- description: |
- Used for updating bitrise dependencies with dep
- steps:
- - script:
- title: Dependency update
+ - repository_url: $TEST_APP_URL
+ - branch: $TEST_APP_BRANCH
+ - clone_into_dir: ./_tmp
+ - path::./:
+ title: Step Test
inputs:
- - content: |-
- #!/bin/bash
- set -ex
- go get -u -v github.com/golang/dep/cmd/dep
- dep ensure -v
- dep ensure -v -update
+ # Inputs with non-default value or using environment variables
+ - project_path: ./_tmp/$BITRISE_PROJECT_PATH
+ - scheme: $BITRISE_SCHEME
- # ----------------------------------------------------------------
- # --- workflows to Share this step into a Step Library
- audit-this-step:
+ generate_readme:
steps:
- - script:
- inputs:
- - content: |-
- #!/bin/bash
- set -ex
- stepman audit --step-yml ./step.yml
+ - git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: {}
diff --git a/e2e/bitrise.yml b/e2e/bitrise.yml
new file mode 100644
index 0000000..9a320de
--- /dev/null
+++ b/e2e/bitrise.yml
@@ -0,0 +1,147 @@
+format_version: "11"
+default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
+
+workflows:
+ test_swiftpm:
+ before_run:
+ - _expose_xcode_version
+ steps:
+ - script:
+ inputs:
+ - content: |-
+ #!/bin/env bash
+ set -e
+ if [[ ${XCODE_MAJOR_VERSION} -gt 11 ]]; then
+ echo "This test case requires Xcode <= 11, skipping..."
+ exit 0
+ fi
+ envman add --key XCODE_MAJOR_VERSION_AT_MOST_11 --value "true"
+ - bitrise-run:
+ run_if: '{{enveq "XCODE_MAJOR_VERSION_AT_MOST_11" "true"}}'
+ inputs:
+ - workflow_id: utility_test_swiftpm
+ - bitrise_config_path: ./e2e/bitrise.yml
+
+ utility_test_swiftpm:
+ envs:
+ - SAMPLE_APP_URL: https://github.com/bitrise-io/sample-apps-ios-swiftpm.git
+ - SAMPLE_APP_BRANCH: codesign-update
+ - BITRISE_PROJECT_PATH: sample-swiftpm.xcodeproj
+ - BITRISE_SCHEME: sample swiftpm
+ after_run:
+ - _run
+
+ test_build_output_renamed:
+ envs:
+ - SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
+ - SAMPLE_APP_BRANCH: renamed-scheme
+ - BITRISE_PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj
+ - BITRISE_SCHEME: renamed_scheme
+ after_run:
+ - _run
+
+ test_build_output_spaces:
+ envs:
+ - SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
+ - SAMPLE_APP_BRANCH: renamed-scheme
+ - BITRISE_PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj
+ - BITRISE_SCHEME: Scheme with spaces
+ after_run:
+ - _run
+
+ test_build_output_renamed_custom_build_options:
+ envs:
+ - SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
+ - SAMPLE_APP_BRANCH: renamed-scheme
+ - BITRISE_PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj
+ - BITRISE_SCHEME: renamed_scheme
+ - XCODE_BUILD_OPTIONS: -derivedDataPath $BITRISE_SOURCE_DIR/_tmp/ddata -destination generic/platform=iOS
+ after_run:
+ - _run
+
+ test_build_output_spaces_custom_build_options:
+ envs:
+ - SAMPLE_APP_URL: https://github.com/bitrise-samples/sample-apps-ios-simple-objc-with-uitest.git
+ - SAMPLE_APP_BRANCH: renamed-scheme
+ - BITRISE_PROJECT_PATH: ./ios-simple-objc/ios-simple-objc.xcodeproj
+ - BITRISE_SCHEME: Scheme with spaces
+ - XCODE_BUILD_OPTIONS: -derivedDataPath $BITRISE_SOURCE_DIR/_tmp/ddata -destination generic/platform=iOS
+ after_run:
+ - _run
+
+ _run:
+ steps:
+ - script:
+ inputs:
+ - content: |-
+ #!/bin/env bash
+ set -ex
+ rm -rf "$BITRISE_SOURCE_DIR/_tmp"
+ mkdir -p "$BITRISE_SOURCE_DIR/_tmp"
+ - git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git:
+ inputs:
+ - repository_url: $SAMPLE_APP_URL
+ - clone_into_dir: $BITRISE_SOURCE_DIR/_tmp
+ - branch: $SAMPLE_APP_BRANCH
+ - commit: $SAMPLE_APP_COMMIT
+ - certificate-and-profile-installer:
+ - path::./:
+ title: Step Test
+ inputs:
+ - project_path: ./_tmp/$BITRISE_PROJECT_PATH
+ - scheme: $BITRISE_SCHEME
+ - output_tool: xcodebuild
+ - xcodebuild_options: $XCODE_BUILD_OPTIONS
+ - git::https://github.com/bitrise-steplib/bitrise-step-check-step-outputs.git@main:
+ is_always_run: true
+ inputs:
+ - envs:
+ - files:
+ - dirs: |-
+ BITRISE_TEST_DIR_PATH
+ - deploy_dir: $BITRISE_DEPLOY_DIR
+ - deployed_files: |-
+ BITRISE_TEST_BUNDLE_ZIP_PATH
+ BITRISE_XCTESTRUN_FILE_PATH
+ - deployed_dirs:
+ - script:
+ title: Output check
+ is_always_run: true
+ inputs:
+ - content: |-
+ #!/bin/env bash
+ set -e
+ if [[ "$BITRISE_DEPLOY_DIR/testbundle.zip" != "$BITRISE_TEST_BUNDLE_ZIP_PATH" ]] ; then
+ echo "BITRISE_TEST_BUNDLE_ZIP_PATH (\"$BITRISE_TEST_BUNDLE_ZIP_PATH\") should be: \"$BITRISE_DEPLOY_DIR/testbundle.zip\""
+ exit 1
+ fi
+ if [[ "$BITRISE_DEPLOY_DIR/Debug-iphoneos" != "$BITRISE_TEST_DIR_PATH" ]] ; then
+ echo "BITRISE_TEST_DIR_PATH (\"$BITRISE_TEST_DIR_PATH\") should be: \"$BITRISE_DEPLOY_DIR/Debug-iphoneos\""
+ exit 1
+ fi
+ if [[ "$BITRISE_XCTESTRUN_FILE_PATH" =~ "$BITRISE_DEPLOY_DIR/${BITRISE_SCHEME}_iphoneos[0-9]{2}.[0-9]{1,2}-arm64e.xctestrun" ]] ; then
+ echo "BITRISE_XCTESTRUN_FILE_PATH (\"$BITRISE_XCTESTRUN_FILE_PATH\") should be: \"$BITRISE_DEPLOY_DIR/${BITRISE_SCHEME}_iphoneos{{sdk-version}}-arm64e.xctestrun\""
+ exit 1
+ fi
+
+ _expose_xcode_version:
+ steps:
+ - script:
+ title: Expose Xcode major version
+ inputs:
+ - content: |-
+ #!/bin/env bash
+ set -e
+ if [[ ! -z "$XCODE_MAJOR_VERSION" ]]; then
+ echo "Xcode major version already exposed: $XCODE_MAJOR_VERSION"
+ exit 0
+ fi
+ version=`xcodebuild -version`
+ regex="Xcode ([0-9]*)."
+ if [[ ! $version =~ $regex ]]; then
+ echo "Failed to determine Xcode major version"
+ exit 1
+ fi
+ xcode_major_version=${BASH_REMATCH[1]}
+ echo "Xcode major version: $xcode_major_version"
+ envman add --key XCODE_MAJOR_VERSION --value $xcode_major_version