Install Layer

Layer is distributed as a source code package or compiled bundle, and can be easily integrated into a new app or an existing codebase with standard tooling.

Note

Both LayerKit and Atlas are fully compatible with Swift tooling, and can be used with existing Swift-based projects. However, we currently have no plans to re-write our SDKs using Swift.

Option 1: CocoaPods

We recommend installing Layer using CocoaPods, which provides a simple dependency management system that automates the error-prone process of manually configuring libraries. First make sure you have CocoaPods installed (you will also need to have Ruby installed):

sudo gem install cocoapods
pod setup

Now create an empty file in the root of your project directory, and name it Podfile. Add the following lines to this file:

use_frameworks!
pod 'LayerKit'

Finally, run pod install to setup your CocoaPods environment and import LayerKit into your project. Make sure to start working from the .xcworkspace file that CocoaPods automatically creates, not the .xcodeproj you may have had open.

Option 2: Carthage

Layer can also be installed via Carthage, which is a decentralized dependency manager. Carthage will not make any modifications to your project, so the installation requires a few more manual steps than with CocoaPods. To get started, ensure that you have installed Carthage and then create a Cartfile with the following content:

github "layerhq/releases-ios"

Next, install the package by running carthage update.

Then, drag LayerKit.framework from Carthage/Checkouts/releases-ios onto your project in Xcode and link it with your application target. Then, select your application target in Xcode, navigate to the Build Phases panel and add a New Run Script Phase. Set the content to:

/usr/local/bin/carthage copy-frameworks

In the Input Files section, add $(SRCROOT)/Carthage/Checkouts/releases-ios/LayerKit.framework. Now build your appilcation target and everything should be set.

Option 3: Manual installation

Our releases repo provides two framework distributions you can add to your project:

  • LayerKit.framework: This is a dynamic framework that is compatible with Objective-C and Swift projects that target iOS 8 or later.
  • LayerKit.embeddedframework: This is a pseudo-framework that contains a static library asset and a set of public header files. It is compatible with Objective-C projects that target iOS 7 or later.

Download the appropriate build artifact from this repository and add it to your application:

  1. Drag and drop the framework onto your project, instructing Xcode to copy items into your destination group’s folder.
  2. Update your project settings to include the linker flags: -ObjC -lz
  3. Add the following Cocoa SDK frameworks to your project: ‘CFNetwork’, ‘Security’, ‘MobileCoreServices’, ‘SystemConfiguration’, ‘libsqlite3.tbd’
  4. LayerKit.framework only: The dynamic framework distribution requires the configuration of additional build phases to complete installation. The steps are detailed on our Knowledge Base.

Build and run your project to verify the installation was successful.

Note

There is a known issue with the iOS 10 Simulator only (not on devices). This can be resolved by enabling Keychain Sharing.

Verifying installation

To verify that everything is installed and working correctly, import the headers and connect the client:

#import <LayerKit/LayerKit.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSURL *appID = [NSURL URLWithString:@"INSERT-APPID-URL-HERE"];
    LYRClient *layerClient = [LYRClient clientWithAppID:appID delegate:self options:nil];
    [layerClient connectWithCompletion:^(BOOL success, NSError *error) {
        if (success) {
            NSLog(@"Successfully connected to Layer!");
        } else {
            NSLog(@"Failed connection to Layer with error: %@", error);
        }
    }];
}

Note

Make sure to use your actual app ID, which can be found from the Developer Dashboard.

Overview Setup Application