Skip to content

iOS SDK Embedding Draft

andrewtremblay edited this page May 3, 2013 · 39 revisions

#iOS SDK# ###Common Gotchas###

  • Before starting, confirm that you have the latest version of Xcode installed. The most up-to-date version of Xcode isn't required to use AppBlade, but it's what we would use. Plus it's just good practice.
  • Due to Apple's new device identification policy starting May 1st 2013, all apps submitted to the App Store with the AppBlade SDK embedded should be using our latest SDK which implements AppBlade API version 3. If you would like to still use our previous SDK, directions for embedding that can be found here.
  • The AppBlade framework is ARC-agnostic; It is compatible with ARC-enabled projects, but does not use ARC itself.

##Walkthrough## Embedding the AppBlade SDK and getting it up and running is fairly simple to do:

  1. Add your AppBlade SDK library files.
  2. Add your property lists.
  3. Build and Run!

There are a few optional steps that can help you do special things

###1. Add your AppBlade SDK Library Files### Adding the AppBlade SDK library files can be done in one of two following ways:

  1. Adding a binary
  2. Adding the source

If you'd like to compile your own binaries from source, we've got a guide for that.

###Including AppBlade Source### Some prefer to include the AppBlade source code directly to their project, either as a submodule for easier code updates or for development on new AppBlade features. AppBlade binaries should not be included if the source code is being used directly instead. Integrating source is a slightly more advanced process and not recommended for beginners.

  1. Clone the AppBlade master branch off of github, then drag the AppBlade project file into the left-hand File Navigator of your application's Xcode project.
    • NOTE: If you are also sharing this project with others (through github, for example) it is highly suggested that you use a copy of the AppBlade Framework in a subdirectory into your project instead of an external one. You may either simply copy iOS/Framework into your project folder or add AppBlade as a Submodule.
  2. Select the following options in the add file options panel and before clicking "Finish":
    • Make sure that "Copy items" is checked for "Destination".
    • Check each of your app targets in "Add to targets".
  3. Add the Apple Security.framework to your project.
    • Click your project file from the File Navigator and then select your app target from the list on the right.
    • Select the "Build Phases" tab and expand "Link Binary With Libraries" and click the "+" button to add a library.
    • Select Security.framework from the list and click "Add".
  4. Add the Appblade library to your Target Dependencies
    • From the "Build Phases" tab, expand "Target Dependencies" and click the "+" button to add a library.
    • Select the AppBlade target under your AppBlade subproject in the dropdown.
  5. Link the Appblade binary to your Link Binary With Libraries
    • From the "Build Phases" tab, expand "Link Binary With Libraries" and click the "+" button to add a binary.
    • Select the AppBlade.a binary under your Workspace folder in the appearing dropdown.
  6. Link the Appblade header files to your Project
    • In your Project Build Settings (Not your Target Build Settings), scroll down to Header Search Paths.
    • Add the path of your AppBlade iOS/Framework folder to your Header Search Paths. Make sure it is marked recursive.
  7. Progress! Next we add your property lists.

###Including AppBlade Binary## You can either download the compiled version from our website, or build the AppBlade library from downloaded source (directions for which can be found in the Building AppBlade Binary From Source section).

1. After downloading AppBlade or building it locally, navigate to the folder containing the libAppBladeUniversal.a binary and header file. In this case we're using the files from our website.

!

2. Open your Xcode project.

3. For a universal build, simply drag the libAppBladeUniversal.a and AppBlade.h files from the folder into your project, ensure that "Copy items" is checked and that it is linked to your build target.

!

4. Click your project file from the File Navigator and then select your app target from the list on the right.

5. Select the "Build Phases" tab and expand "Link Binary With Libraries", your libAppBladeUniversal.a lib should already be in there if you linked your target.

!

6. The AppBlade SDK has only one external dependency; the Security framework. Click the "+" button to add a library. Select Security.framework from the list and click "Add".

!

7. Again, make sure libAppBladeUniversal.a is also added to the list if it hasn't been added by Xcode.

8. Progress! Next we add your property lists.

###2. Add Your Property Lists.### Okay, so you added our library, either by binary or source. The AppBlade library will now build and link to your project on each build of this target, but you'll need to add property lists (.plists) in order for AppBlade.com to use your builds.

1. First, grab your property lists. Again, these are from the folder on AppBlade.com

!

2. Open your Xcode project in Finder and drag or copy both plist files into the base folder of your project. The plists must be in this base folder and nowhere else.

!

3. Navigate to your Copy Bundle Resources section in your project settings.

!

4. Add your resources by selecting the + at the bottom of the Add Resources section and selecting "Add Other..."

!

5. Navigate out of the project file (which is where the file browser drops you for some reason) and into the base project folder.

!

6. Select the files you added earlier to the base project folder and click Open.

!

7. In the confirm panel, make sure the "Copy items" option is NOT checked and, if you have any build targets visible, that they are selected.

!

8. Looking back at the build settings, things should look something like this:

!

9. Your property lists are now added. Everything should work, time to build and run!

###3. Build and Run!### Home stretch! You've embedded the SDK and your property lists, now all you need to do is prove it's building properly.

  1. In your App Delegate file, import AppBlade.h, The Xcode auto-complete should be able to find it.

  2. Add the following lines to your - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method:

    AppBlade *blade = [AppBlade sharedManager];
    [blade registerWithAppBladePlist];
    

In the end everything should look something like this:

! (Notice that we moved our AppBlade files in our project for better organization, you can too.)

Now hit run. Congratulations!

!

##What Next?## Check out our Feature Implementation Guide to see what our SDK can do.

##Still having problems?## Check out our FAQ (Frequent AppBlade Questions).