Skip to content

A barebones iOS iMessage Extension demonstrating Fabric/Crashlytics/Answers integration w/ API key and build secret isolation.

Notifications You must be signed in to change notification settings

ansonl/fabric-ios-extension

Repository files navigation

Fabric iOS Extension

If you are looking for a customizble iMessage sticker project with Fabric integrated, see github.com/Fluffcorn.

How to integrate Fabric with your own iOS extension (with API key and build secret isolation for public projects and distribution)

  1. Download the Fabric frameworks.

  2. Import frameworks into your Xcode project

  • Import frameworks to Xcode project
  1. Create fabric.apikey and fabric.buildsecret files in Xcode project directory root. Put your Fabric API key and build secret into the files respectively.
  • Create files
  1. Add the below lines to the project .gitignore file if you intend on making the project public.

    fabric.apikey
    fabric.buildsecret
    
  • Add files to .gitignore
  1. Add Run Script below to your extension target. Run Script is located under the [ExtensionTarget] > Build Phases.

    FABRIC_APIKEY=$(cat ${SRCROOT}/fabric.apikey)
    FABRIC_BUILDSECRET=$(cat ${SRCROOT}/fabric.buildsecret)
    ${SRCROOT}/Fabric.framework/run ${FABRIC_APIKEY} ${FABRIC_BUILDSECRET}
    
  • Add run script
  1. Import frameworks into your initial view controller or class.

    #import <Fabric/Fabric.h>
    #import <Crashlytics/Crashlytics.h>
    
  2. Add or modify initWithCoder: method in your initial view controller or class.

    - (id)initWithCoder:(NSCoder *)decoder {
        self = [super initWithCoder:decoder];
        if (!self) {
           return nil;
        }
    
        NSURL* resourceURL = [[NSBundle mainBundle] URLForResource:@"fabric.apikey" withExtension:nil];
        NSStringEncoding usedEncoding;
        NSString* fabricAPIKey = [NSString stringWithContentsOfURL:resourceURL usedEncoding:&usedEncoding error:NULL];
        NSCharacterSet* whitespaceToTrim = [NSCharacterSet whitespaceAndNewlineCharacterSet];
        NSString* fabricAPIKeyTrimmed = [fabricAPIKey stringByTrimmingCharactersInSet:whitespaceToTrim];
    
        [Crashlytics startWithAPIKey:fabricAPIKeyTrimmed];
    
        return self;
    }
    
  3. Build and Run

Sources

About

A barebones iOS iMessage Extension demonstrating Fabric/Crashlytics/Answers integration w/ API key and build secret isolation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published