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
- Install CocoaPods if you don’t have it installed.
- Create an Xcode project if you don’t have one.
Create a
Podfileif you don’t have one:$ pod initAdd the InMoment pod to your
Podfile:pod 'InMoment'Install the pod and open your project’s
.xcworkspacefile in Xcode:$ pod install
Carthage
- Install Carthage if you don’t have it installed.
- Create an Xcode project if you don’t have one.
Create a
Cartfileif you don’t have one:$ touch CartfileAdd the InMoment SDK to your
Cartfile:binary "https://inmoment-ios-artifacts.s3.amazonaws.com/InMoment.json"Install the SDK and open your project in Xcode:
$ carthage bootstrapOn your app target’s
Generalsettings tab, dragInMoment.frameworkfrom theCarthage/Buildfolder into theEmbedded binariessection.On your app target’s
Build Phasessettings tab, click the+icon and chooseNew 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-frameworksand 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}}
- Download and unzip the latest release.
- Drag
InMoment.frameworkinto your Xcode project and chooseCopy if needed
. - Click the
+in theEmbedded Binariessection of your application’s target, and selectInMoment.framework. Add a
Run Script
build phase afterEmbed 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.
Getting Started Reference