Codecov example for Xcode
Objective-C
Latest commit 9fd38e9 Dec 27, 2016 @RyanCopley RyanCopley committed on GitHub Merge pull request #4 from ajsecord/patch-1
s/enviornment/environment in README.md
Permalink
Failed to load latest commit information.
Example
example.xcodeproj
exampleTests
.travis.yml It would help to make sure things are named properly :) May 16, 2015
README.md s/enviornment/environment in README.md Dec 27, 2016

README.md

Codecov Objective-C Example

This repository serves as an example on how to use Codecov Global for Xcode in both Objective-C and Swift.

PS there is a Swift specific example here https://github.com/codecov/example-swift

codecov.io

Setup

  • Create a shared scheme for your test target https://i.imgur.com/JKNFq0G.png
  • At the highest, your deployment target can be 8.1 or earlier. This will update as Travis supports more simulators.
  • Write unit tests
  • Setup your CI

xctool also does not respect the /Scheme/TestAction/@codeCoverageEnabled setting in .xcscheme files. Make sure -enableCodeCoverage YES is set.

Travis CI

Add to your .travis.yml file.

language: objective-c
script: 
  - xctool -project {{path_to_xcodeproj}} -scheme {{your_testing_scheme}} build test -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
  - bash <(curl -s https://codecov.io/bash)

Reference http://docs.travis-ci.com/user/languages/objective-c/

The two important parts are:

  • GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES (To have Xcode create code coverage files)
  • bash <(curl -s https://codecov.io/bash) (To upload code coverage to Codecov.io)

This is used to have Xcode output code coverage files for Codecov.io to process.

Private Repos

Set CODECOV_TOKEN in your environment variables.

Add to your .travis.yml file.

after_success:
  - bash <(curl -s https://codecov.io/bash) -t :uuid-repo-token

Or you can set the environment variable CODECOV_TOKEN to your token.

Build specific projects

# match ExampleName and ExampleNameTests
bash <(curl -s https://codecov.io/bash) -J 'ExampleName'

# user regexp to match only ExampleName and not ExampleNameTests
bash <(curl -s https://codecov.io/bash) -J '^ExampleName$'

View source and learn more about Codecov Global Uploader