Travis CI and iOS Projects

Travis is a Continuos Integration platform targeted to the Open Source Community. Among many other languages, it now supports Objective-C projects, but its lack of documentation can give the impression that it is a difficult task to achieve while in fact it quite simple. Find out how simple it is to configure your iOS Xcode project hosted in Github in 3 steps:

1. Configuration File

All Travis projects start with a YAML configuration file named travis.yml. An iOS project actually requires a very simple one:

language:objective-c
before_script:
  - cd TwinkleStarExample   # in case your project resides in a sub-directory
xcode_sdk: iphonesimulator

The xcode_sdk: line is important to avoid the error:

Code Sign error: The identity 'iPhone Developer' doesn't match any valid, non-expired certificate/private key pair in your keychains

2. Shared Schemes

Ensure the schemes of your target are Shared. This option makes a scheme visible to anyone using that project. To enable it, go to the menu: Product > Scheme > Manage Schemes.

This prevents the following error:

xcodebuild: error: The project 'PROJECT_NAME' does not contain a scheme named 'SCHEME_NAME'.

3. Success

Writing a configuration file and making a few clicks in Xcode are for sure exhausting!

Reward yourself by opening a can of Cola and start enjoying the benefits of continuous integrated builds. 🙂

For some examples, refer to some of my iOS repositories in Github:

Transcontinental

If you’ve worked with the Core Location class CLPlacemark, you might have noticed that despite having properties like ‘ISOCountryCode’ or ‘ocean’, there is not a property, nor an easy way to obtain its corresponding continent.

To solve this, I’ve programmed a small category on CLPlacemark that allows you to obtain its continent with a simple method:

NSString *continentForPlacemark = [paramPlacemark continent];

The continent is retrieved from a table using the ISOCountryCode property of the placemark. Also a simple Country-to-Continent decoder is available:

NSString *expectedContinent = [continentDecoder continentForCountryCode:@"PL"];

The name of this project is Transcontinental and is available as a MIT Licensed repository in Github. It also includes a simple example which should make its use clear as water.

Enjoy!

TwinkleStar

TwinkleStar is a small iOS library I wrote to handle device’s LED through a convenient singleton. It supports turning it on and off (again), setting up a strobe frequency and determining if a device counts with an integrated LED. All conveniently wrapped in a cool singleton with the following interface:

@property CGFloat flashFrequency;
@property BOOL isFlashLEDAvailable;

+(HZTwinkleStar *)sharedTwinkleStar;

-(void)turnFlashLEDOn;
-(void)turnFlashLEDOff;