Getting Started

Add the SDK to your iOS App

We recommend using CocoaPods to add the InMoment SDK. If you do not want to use CocoaPods, you can use Carthage to add the SDK, or integrate the SDK framework without CocoaPods or Carthage.

CocoaPods

  1. Install CocoaPods if you don’t have it installed.
  2. Create an Xcode project if you don’t have one.
  3. Create a Podfile if you don’t have one:

    $ pod init
    
  4. Add the InMoment pod to your Podfile:

    pod 'InMoment'
    
  5. Install the pod and open your project’s .xcworkspace file in Xcode:

    $ pod install
    

Carthage

  1. Install Carthage if you don’t have it installed.
  2. Create an Xcode project if you don’t have one.
  3. Create a Cartfile if you don’t have one:

    $ touch Cartfile
    
  4. Add the InMoment SDK to your Cartfile:

    binary "https://inmoment-ios-artifacts.s3.amazonaws.com/InMoment.json"
    
  5. Install the SDK and open your project in Xcode:

    $ carthage bootstrap
    
  6. On your app target’s General settings tab, drag InMoment.framework from the Carthage/Build folder into the Embedded binaries section.

  7. On your app target’s Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script in which your specify your shell (ex: bin/sh), and add the following contents to the script area below the shell:

    /usr/local/bin/carthage copy-frameworks
    

    and add the following line under Input Files:

    $(SRCROOT)/Carthage/Build/iOS/InMoment.framework
    

Remark

This script works around an App Store submission bug triggered by universal binaries and ensures that necessary bitcode-related files and dSYMs are copied when archiving.

Integrate without CocoaPods or Carthage

{{parameter1}}

  1. Download and unzip the latest release.
  2. Drag InMoment.framework into your Xcode project and choose Copy if needed.
  3. Click the + in the Embedded Binaries section of your application’s target, and select InMoment.framework.
  4. Add a Run Script build phase after Embed Frameworks. Copy and paste the following script:

    APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
    
    # This script loops through the frameworks embedded in the application and
    # removes unused architectures.
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    do
        FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
        FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
        echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
    
        EXTRACTED_ARCHS=()
    
        for ARCH in $ARCHS
        do
            echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
            lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
            EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
        done
    
        echo "Merging extracted architectures: ${ARCHS}"
        lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
        rm "${EXTRACTED_ARCHS[@]}"
    
        echo "Replacing original executable with thinned version"
        rm "$FRAMEWORK_EXECUTABLE_PATH"
        mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
    
    done
    

Remark

This script is a workaround for a feature in Xcode 7+ that prevents users from uploading apps referencing frameworks that contain simulator slices to iTunes Connect (click here to learn more). We wanted you to still be able to use your app with the simulators, so we intentionally included these slices.

Prepare Your App

Privacy

Some surveys may include features that require to access the device’s camera, microphone, and/or photo library. The following entries must be added to the application’s Info.plist to ensure that these features work properly and to comply with App Store guidelines:

  • NSCameraUsageDescription: (Privacy - Camera Usage Description)
  • NSMicrophoneUsageDescription: (Privacy - Microphone Usage Description)
  • NSPhotoLibraryUsageDescription: (Privacy - Photo Library Usage Description)

  • Warning

    Failure to add these entries to the application’s Info.plist may result in the app being rejected during App Store submission, or may result in a crash at runtime. These entries must be added to your application’s Info.plist regardless of the installation method used.

    Next Steps