Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using CircleCI 2.0 #158

Open
onmyway133 opened this issue Apr 3, 2018 · 0 comments
Open

Using CircleCI 2.0 #158

onmyway133 opened this issue Apr 3, 2018 · 0 comments
Labels
ci continuous integration iOS xcode

Comments

@onmyway133
Copy link
Owner

onmyway133 commented Apr 3, 2018

We 've been using CircleCI for many of our open source projects. Since the end of last year 2017, version 2.0 began to come out, and we think it's good time to try it now together with Swift 4.1 and Xcode 9.3

The problem with version 2.0 is it's so powerful and has lots of cool new features like jobs and workflows, but that requires going to documentation for how to migrate configuration file, especially Search and Replace Deprecated 2.0 Keys

Creating config.yml

The first thing is to create a new config.yml inside folder .circleci

Copy your existing circle.yml file into a new directory called .circleci at the root of your project repository.

Next is to declare version and jobs

Add version: 2 to the top of the .circleci/config.yml file.

Checking xcodebuild

For simple cases, we just use xcodebuild to build and test the project, so it's good to try it locally to avoid lots of trial commits to trigger CircleCI. You can take a look at this PR onmyway133/EasyConfetti#20

Before our configuration file for version 1.0 looks like this

- set -o pipefail && xcodebuild -project Cheers.xcodeproj -scheme "Cheers-iOS" -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 8,OS=11.0' -enableCodeCoverage YES test

Now we should put pipefail inside shell, follow https://github.com/CircleCI-Public/circleci-demo-ios/blob/master/.circleci/config.yml

shell: /bin/bash --login -o pipefail

Now is the actual trying xcodebuild, after many failures due to destination param

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ platform:iOS Simulator, OS:11.3 }

	Missing required device specifier option.
	The device type “iOS Simulator” requires that either “name” or “id” be specified.
	Please supply either “name” or “id”.
xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'

I found this to work, run this in the same folder as your xcodeproj

xcodebuild -project Cheers.xcodeproj -scheme "Cheers-iOS" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=11.3,name=iPhone X" -enableCodeCoverage YES test

Adding workflow

Version 2.0 introduces workflow which helps organising jobs

A workflow is a set of rules for defining a collection of jobs and their run order. Workflows support complex job orchestration using a simple set of configuration keys to help you resolve failures sooner.

For our simple use cases, we add this workflow

workflows:
  version: 2
  build-and-test:
    jobs:
      - build-and-test

Collecting Test Metadata

CircleCI collects test metadata from XML files and uses it to provide insights into your job

Final

Use below as template

version: 2.1
jobs:
  build_test:
    macos:
      xcode: "11.0"
    shell: /bin/bash --login -o pipefail
    steps:
      - checkout
      - run:
          command: |
            curl https://cocoapods-specs.circleci.com/fetch-cocoapods-repo-from-s3.sh | bash -s cf
            pod install
      - run:
          command: xcodebuild -workspace MyApp.xcworkspace -scheme "MyApp" -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone X,OS=12.2" -enableCodeCoverage YES test
      - store_test_results:
          path: test-results

workflows:
  version: 2.1
  primary:
    jobs:
      - build_test

Read more

@onmyway133 onmyway133 added xcode iOS ci continuous integration labels Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci continuous integration iOS xcode
Projects
None yet
Development

No branches or pull requests

1 participant