|
| 1 | +--- |
| 2 | +layout: classic-docs |
| 3 | +title: "Hello World On MacOS" |
| 4 | +short-title: "Hello World On MacOS" |
| 5 | +description: "First macOS project on CircleCI 2.0" |
| 6 | +categories: [getting-started] |
| 7 | +order: 4 |
| 8 | +--- |
| 9 | + |
| 10 | +This document describes how to get started with continuous integration on **macOS |
| 11 | +build environments** on CircleCI. If you still need to get acquainted with |
| 12 | +CircleCI, it is recommended to checkout the [getting started guide]({{ site.baseurl }}/2.0/getting-started). |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +To follow along with this document you will need: |
| 17 | + |
| 18 | +- An [account](https://circleci.com/signup/) on CircleCI. |
| 19 | +- A subscription to a [paid plan](https://circleci.com/pricing/#build-os-x) to enable building on the macOS executor. |
| 20 | +- An Apple computer with XCode installed on it (if you want to open the example project). |
| 21 | + |
| 22 | +## Overview Of The macOS Executor |
| 23 | + |
| 24 | +The macOS build environment (or `executor`) is used for iOS and macOS |
| 25 | +development, allowing you to test, build, and deploy macOS and iOS applications on |
| 26 | +CircleCI. The macOS executor runs jobs in a macOS environment and provides access to iPhone, iPad, Apple Watch and Apple TV simulators. |
| 27 | + |
| 28 | +Before we get to setting up the macOS executor, we will need to setup our example application. |
| 29 | + |
| 30 | +## Example Application |
| 31 | + |
| 32 | +The example application is a simple mac app - it runs a 5 minute |
| 33 | +timer and contains a single unit test (real-world applications |
| 34 | +will be far more complex; this app simply serves as an introduction to the macOS |
| 35 | +build environment). |
| 36 | + |
| 37 | +As a user getting to know the macOS build environment, our ideal scenario is for CircleCI to help with the following: |
| 38 | + |
| 39 | +- Run tests using XCode on the macOS VM whenever we push code. |
| 40 | +- Create and upload the compiled application as an artifact after tests have run successfully. |
| 41 | + |
| 42 | +You can checkout the example application's repo on |
| 43 | +[Github](https://github.com/CircleCI-Public/circleci-demo-macos). |
| 44 | + |
| 45 | +## Example Configuration File |
| 46 | + |
| 47 | +Our application does not make use of any external tools or dependencies, so we |
| 48 | +have a fairly simple `.circleci/config.yml` file. Below, each line is commented |
| 49 | +to indicate what is happening at each step. |
| 50 | + |
| 51 | +```yaml |
| 52 | +version: 2 # use version 2.0 of CircleCI |
| 53 | +jobs: # a basic unit of work in a run |
| 54 | + build: # runs not using `Workflows` must have a `build` job as entry point |
| 55 | + macos: # indicate that we are using the macOS executor |
| 56 | + xcode: "10.0.0" # indicate our selected version of Xcode |
| 57 | + steps: # a series of commands to run |
| 58 | + - checkout # pull down code from your version control system. |
| 59 | + - run: |
| 60 | + # run our tests using xcode's cli tool `xcodebuild` |
| 61 | + name: Run Unit Tests |
| 62 | + command: xcodebuild test -scheme circleci-demo-macos |
| 63 | + - run: |
| 64 | + # build our application |
| 65 | + name: Build Application |
| 66 | + command: xcodebuild |
| 67 | + - run: |
| 68 | + # compress Xcode's build output so that it can be stored as an artifact |
| 69 | + name: Compress app for storage |
| 70 | + command: zip -r app.zip build/Release/circleci-demo-macos.app |
| 71 | + - store_artifacts: # store this build output. Read more: https://circleci.com/docs/2.0/artifacts/ |
| 72 | + path: app.zip |
| 73 | + destination: app |
| 74 | +``` |
| 75 | +
|
| 76 | +If this is your first exposure to a CircleCI `config.yml`, some of the above |
| 77 | +might seem a bit confusing. In the section below you can find some links that |
| 78 | +provide a more in-depth overview of how a `config.yml` works. |
| 79 | + |
| 80 | +Since this is a general introduction to building on MacOs, the `config.yml` above example covers the following: |
| 81 | + |
| 82 | +- Picking an [`executor`]({{ site.baseurl }}/2.0/configuration-reference/#docker--machine--macosexecutor) to use |
| 83 | +- Pulling code via the [`checkout`]({{ site.baseurl }}/2.0/configuration-reference/#checkout) key |
| 84 | +- Running tests with Xcode |
| 85 | +- Building our application |
| 86 | +- Compressing our application and storing it with the [`store_artifacts`]({{ |
| 87 | + site.baseurl }}/2.0/configuration-reference/#store_artifacts) key. |
| 88 | + |
| 89 | +You can learn more about the `config.yml` file in the [configuration reference guide]({{site.baseurl}}/2.0/configuration-reference/). |
| 90 | + |
| 91 | +## Next Steps |
| 92 | + |
| 93 | +The macOS executor is commonly used for testing and building iOS applications, |
| 94 | +which can be more complex in their continuous integrations configuration. If you |
| 95 | +are interested in building and/or testing iOS applications, consider checking |
| 96 | +out our following docs that further explore this topic: |
| 97 | + |
| 98 | +- [Testing iOS Applications on macOS]({{ site.baseurl }}/2.0/testing-ios) |
| 99 | +- [iOS Project Tutorial]({{ site.baseurl }}/2.0/ios-tutorial) |
| 100 | +- [Setting Up Code Signing for iOS Projects]({{ site.baseurl }}/2.0/ios-codesigning) |
| 101 | + |
| 102 | +Also, consider reading documentation on some of CircleCI's features: |
| 103 | + |
| 104 | +- See the [Concepts]({{ site.baseurl }}/2.0/concepts/) document for a summary of 2.0 configuration and the hierarchy of top-level keys in a `.circleci/config.yml` file. |
| 105 | + |
| 106 | +- Refer to the [Workflows]({{ site.baseurl }}/2.0/workflows) document for examples of orchestrating job runs with parallel, sequential, scheduled, and manual approval workflows. |
| 107 | + |
| 108 | +- Find complete reference information for all keys and pre-built Docker images in the [Configuring CircleCI]({{ site.baseurl }}/2.0/configuration-reference/) and [CircleCI Images]({{ site.baseurl }}/2.0/circleci-images/) documentation, respectively. |
0 commit comments