Integrating Xcode Bots and Crashlytics Beta

If you have already setup Xcode Bots for your iOS project, you can step up your Continuos Integration game even more by hooking-up Xcode Bots to Crashlytics Beta distribution.

This guide assumes you have a Crashlytics account and that already have a working Bot outputting signed IPA files. This means, your Integrations should have ‘Build Results’ and they should contain an .ipa artifact:

Build Results

Keys for the Ride

  1. First, you will need your API Key and your Build Secret.
    From the Crashlytics dashboard, you can find them in Settings > Organizations > Your Organization.

    They are hidden right at the top of the screen:

    Crashlytics Organization

Tinkering the Bot

  1. Open your Bot and click on Edit Bot… (top right of the screen).

    Crashlytics Organization

  2. Click Next until you arrive to the screen Configure Bot Triggers and add a Run Script trigger from the + Add Trigger menu.

    Crashlytics Organization

  3. Then, write the script that submits your signed IPA to Crashlytics:
    "${XCS_SOURCE_DIR}/<CRASHLYTICS_PATH>/Crashlytics.framework/submit"  <API_KEY> <BUILD_SECRET> -ipaPath "${XCS_OUTPUT_DIR}/${XCS_PRODUCT}"
    

    About the command and its arguments:

    "${XCS_SOURCE_DIR}/<CRASHLYTICS_PATH>/Crashlytics.framework/submit":

    If the Crashlytics framework is somewhere in your repository (it should), this is the way to get it. Avoid accessing it directly from your User’s path, the Bot user will most likely not have execute permissions to run it (that’s why we want the ‘checked out’ version from the repo).

    Example: if the framework is under a source/vendor path of your repo, the path in your script would look like "${XCS_SOURCE_DIR}/source/vendor/Crashlytics.framework/submit".

API_Key and BUILD_SECRET are the keys from your account.

`-ipaPath "${XCS_OUTPUT_DIR}/${XCS_PRODUCT}"`: This will point to the .ipa artifact of your build located in the output directory of the Bot.
  1. Make a new integration! Your build should be available in Crashlytics now.

The submit command has a few other parameters that may be of use to you. Check the complete list in their Support Article.

iOS apps and the Open Source they use

I’ve compiled a list of six popular iPhone apps and the iOS Open Source Software they use.

I’ve also linked to the original repositories in case you want to check them out and start contributing to them. Projects that seem inactive, outdated or no longer maintained have been excluded from the list.

Instagram

  • AFNetworking: iOS and OS X networking framework.
  • Appirater: Reminds your iPhone app’s users to review the app.
  • asi-http-request: Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone.
  • CocoaHTTPServer: Small, lightweight, embeddable HTTP server for Mac OS X or iOS applications.
  • Cocoa Lumberjack: Fast & simple, yet powerful & flexible logging framework for Mac and iOS.
  • MBProgressHUD: Drop-in class that displays a translucent HUD with an indicator and/or labels.
  • PLCrashReporter (Github mirror): In-process crash reporting framework.
  • QSUtilities: Loose collection/library of utilities, controls and other helpers for iOS (iPhone, iPod Touch, iPad) development.
  • SocketRocket: A conforming Objective-C WebSocket client library.
  • XBImageFilters: OpenGL ES 2-based image and real-time camera filters for iOS.

Foursquare

  • Facebook SDK for iOS: Integrate with Facebook, help build engaging social apps, and get more installs.
  • FSNetworking: Foursquare iOS networking library.
  • kingpin: Drop-in MapKit/MKAnnotation pin clustering library for MKMapView on iOS.
  • AFNetworking: iOS and OS X networking framework.
  • SKBounceAnimation: CAKeyframeAnimation subclass that lets you quickly and easily set a number of bounces, and start and end values, and creates an animation for you.
  • DB5: App Configuration via Plist.

LinkedIn

  • BlocksKit: The Objective-C block utilities you always wish you had.
  • SDWebImage: Asynchronous image downloader with cache support with an UIImageView category.
  • DTCOreText: Methods to allow using HTML code with CoreText.

Shazam

  • AudioStreamer: Streaming audio player class (AudioStreamer) for Mac OS X and iPhone.
  • ColorArt: iTunes 11-style color matching code.
  • objc-geohash: Objective-C GeoHash Library. Get hashes by longitude and latitude.
  • TPCircularBuffer: Simple, fast circular buffer implementation.
  • FormatterKit: stringWithFormat: for the sophisticated hacker set.
  • UIView+Glow: Category on UIView that adds support for making views glow.
  • WEbViewJavascriptBridge: iOS / OSX bridge for sending messages between Obj-C and JavaScript in WebViews.

Skype

  • AFNetworking: iOS and OS X networking framework.
  • Hockey SDK: Official iOS SDK for the HockeyApp service.
  • PLCrashReporter (Github mirror): In-process crash reporting framework.
  • TTTAttributedLabel: Drop-in replacement for UILabel that supports attributes, data detectors, links, and more.
  • SDWebImage: Asynchronous image downloader with cache support with an UIImageView category.
  • Cocoa Lumberjack: Fast & simple, yet powerful & flexible logging framework for Mac and iOS
  • MWPhotoBrowser: A simple iOS photo browser with optional grid view, captions and selections.
  • QSUtilities: Loose collection/library of utilities, controls and other helpers for iOS (iPhone, iPod Touch, iPad) development.
  • BlocksKit: The Objective-C block utilities you always wish you had.

Spotify

  • FMDB: Objective-C wrapper around SQLite.
  • MAObjCRuntime: ObjC wrapper for ObjC runtime API.
  • Nu: Programming Language.
  • PLCrashReporter (Github mirror): In-process crash reporting framework.
  • SBJSON: Strict JSON parser and generator in Objective-C.

Rocking for Spotify

Long time no see!

I’ve been quite busy for the last two months: little bit of traveling followed by my first month at Spotify. So far, so good. I’m already tinkering the iOS codebase and contributing to make Browse on iOS even more awesome.

Spotify Logo

Hopefully, I’ll return to my weekly writing next week. Stay tuned! I got a neat experiment around Bluetooth Low Energy that I want to share with you.

__block directive, a simple explanation

Nowadays, if you pass a variable inside a block and try to assign a new value to it, you will encounter the error Variable is not assignable (missing __block type specifier).

This is a definitive improvement from the previous behavior where your variables simply remained unmodified. Now consider the following example:

    NSMutableString *digits = [NSMutableString stringWithString:@"12345"];

    void (^someBlock) (void) = ^{
        [digits appendString:@"67890"];

    };

    someBlock();

    NSLog(@"%@", digits);

Since digits was modified inside a block without the __block directive, you could think it will print the sequence “12345”.

Surprisingly, digits actually holds the value “1234567890”.

Why?

The answer is simple. When you make use of a variable inside a block. It is imported into the block structure as a const. Hence, the behavior is consistent with the declaration:

NSMutableString * const importedDigits = digits;

You would not be able to point importedDigits to a different address, but nothing stops you from changing the content of the object digits being referenced.

By using the __block directive, the variable is no longer imported to the block. Instead, it’s passed by reference and its behavior will be consistent with the declaration:

NSMutableString **digitsReference = &digits;

In this case, you can move where digitsReference is pointing at and you will actually be affecting the content of the variable digits.

For more information on the topic, check out the Block Implementation Specification in Clang’s documentation.