Swift package manager integration

Requirements

Installing the iOS SDK via Swift Package Manager (SPM) automates the majority of the installation process for you. Before beginning this process, ensure that you are using Xcode 12 or greater.

Step 1: Adding the dependency to your project

Open your project and navigate to your project’s settings. Select the tab named Swift Packages and click on the add button (+) at the bottom left.

Swift Package Manager: Menu 1

When importing SDK version 3.33.1 and above, enter the URL of our iOS SDK repository (https://github.com/braze-inc/braze-ios-sdk) in the text field and click Next.

Swift Package Manager: Menu 2

On the next screen, select the SDK version and click Next.

Swift Package Manager: Menu 3

Select the package that best suits your needs and click Finish:

  • AppboyUI
    • Best suited if you plan to use UI components provided by Braze.
    • Includes AppboyKit automatically.
  • AppboyKit
    • Best suited if you don’t need to use any of the UI components provided by Braze (e.g. Content Cards, In-App Messages, etc.).
  • AppboyPushStory
    • Include this package if you have integrated Push Stories in your app. This is supported as of version 3.31.0.
    • In the dropdown under Add to Target, select your ContentExtension target instead of your main app’s target.

Make sure you select either AppboyKit or AppboyUI. Including both packages can lead to undesired behavior.

Swift Package Manager: Menu 4

Step 2: Configuring your project

Next, navigate to your project build settings and add the -ObjC flag to the Other Linker Flags setting.

Swift Package Manager: Menu 5

Step 3: Editing the target’s scheme

If you are using Xcode 12.4 or earlier, edit the scheme of the target including the Appboy package (Product > Scheme > Edit Scheme menu item):

  • Expand the Build menu and select Post-actions. Press the plus (+) button and select New Run Script Action.
  • In the Provide build settings from dropdown, select your app’s target.
  • Copy this script into the open field:
    1
    2
    3
    4
    
    # iOS
    bash "$BUILT_PRODUCTS_DIR/Appboy_iOS_SDK_AppboyKit.bundle/Appboy.bundle/appboy-spm-cleanup.sh"
    # macOS (if applicable)
    bash "$BUILT_PRODUCTS_DIR/Appboy_iOS_SDK_AppboyKit.bundle/Contents/Resources/Appboy.bundle/appboy-spm-cleanup.sh"
    

Swift Package Manager: Menu 7

Next steps

Follow the instructions for Completing the Integration.

WAS THIS PAGE HELPFUL?
New Stuff!