nav_title | article_title | platform | page_order | description | toc_headers |
---|---|---|---|---|---|
Manual Integration |
Manual Integration for iOS |
Swift |
3 |
This reference article shows how to integrate the Braze Swift SDK using manual installation. |
h2 |
If you don't have access to a package manager, such as Swift Package Manager or CocoaPods, you can manually integrate the Swift SDK instead.
Go to the Braze SDK release page on GitHub, then download braze-swift-sdk-prebuilt.zip
.
!["The Braze SDK release page on GitHub."]({% image_buster /assets/img/swift/sdk_integration/download-braze-swift-sdk-prebuilt.png %})
The Braze Swift SDK contains a variety of standalone XCFrameworks, which gives you the freedom to integrate the features you want—without needing to integrate them all. Reference the following table to choose your XCFrameworks:
Package | Required? | Description |
---|---|---|
BrazeKit |
Yes | Main SDK library that provides support for analytics and push notifications. |
BrazeLocation |
No | Location library that provides support for location analytics and geofence monitoring. |
BrazeUI |
No | Braze-provided user interface library for in-app messages and Content Cards. |
BrazeNotificationService |
No | Notification service extension library that provides support for rich push notifications. Do not add this library directly to your main application target, instead add the BrazeNotificationService library separately. |
BrazePushStory |
No | Notification content extension library that provides support for Push Stories. Do not add this library directly to your main application target, instead add the BrazePushStory library separately. |
BrazeKitCompat |
No | Compatibility library containing all the Appboy and ABK* classes and methods that were available in the Appboy-iOS-SDK version 4.X.X. For usage details, refer to the minimal migration scenario in the migration guide. |
BrazeUICompat |
No | Compatibility library containing all the ABK* classes and methods that were available in the AppboyUI library from Appboy-iOS-SDK version 4.X.X. For usage details, refer to the minimal migration scenario in the migration guide. |
SDWebImage |
No | Dependency used only by BrazeUICompat in the minimal migration scenario. |
{: .ws-td-nw-1 .reset-td-br-1 .reset-td-br-2}
Decide whether you want to use Static or Dynamic XCFrameworks, then prepare your files:
{% tabs %} {% tab dynamic %}
- Create a temporary directory for your XCFrameworks.
- In
braze-swift-sdk-prebuilt
, open thedynamic
directory and moveBrazeKit.xcframework
into your directory. Your directory should be similar to the following:temp_dir └── BrazeKit.xcframework
- Move each of your chosen XCFrameworks into your temporary directory. Your directory should be similar to the following:
temp_dir ├── BrazeKit.xcframework ├── BrazeKitCompat.xcframework ├── BrazeLocation.xcframework └── SDWebImage.xcframework
{% endtab %}
{% tab static %}
- Create a temporary directory for your XCFrameworks.
- In
braze-swift-sdk-prebuilt
, open thestatic
directory and moveBrazeKit.xcframework
into your directory. Your directory should be similar to the following:temp_frameworks_dir └── BrazeKit.xcframework
- Move each of your chosen XCFrameworks into your temporary directory. Your directory should be similar to the following:
temp_frameworks_dir ├── BrazeKit.xcframework ├── BrazeKitCompat.xcframework ├── BrazeLocation.xcframework └── SDWebImage.xcframework
- Create a temporary directory for your bundles.
- Open the
bundles
directory and moveBrazeKit.bundle
into your directory. Your directory should be similar to the following:temp_bundles_dir └── BrazeKit.bundle
- If you're using the
BrazeLocation
,BrazeUI
,BrazeUICompat
, orSDWebImage
XCFrameworks, move their corresponding bundles into your temporary directory. Your directory should be similar to the following:temp_bundles_dir ├── BrazeLocation.bundle ├── BrazeUI.bundle ├── BrazeUICompat.bundle └── SDWebImage.bundle
{% alert note %} Only move over bundles for the frameworks you prepared. {% endalert %} {% endtab %} {% endtabs %}
Next, integrate the Dynamic or Static XCFrameworks you prepared previously:
{% tabs %} {% tab dynamic %} In your Xcode project, select your build target, then General. Under Frameworks, Libraries, and Embedded Content, drag and drop the files you prepared previously.
!["An example Xcode project with each Braze library set to 'Embed & Sign.'"]({% image_buster /assets/img/swift/sdk_integration/embed-and-sign.png %})
{% alert tip %}
To enable GIF support, add SDWebImage.xcframework
, located in braze-swift-sdk-prebuilt/dynamic
.
{% endalert %}
{% endtab %}
{% tab static %} In your Xcode project, select your build target, then General. Under Frameworks, Libraries, and Embedded Content, drag and drop the frameworks you prepared previously. Next to each framework, choose Do Not Embed.
!["An example Xcode project with each Braze library set to 'Do Not Embed.'"]({% image_buster /assets/img/swift/sdk_integration/do-not-embed-and-sign.png %})
{% alert tip %}
To enable GIF support, add SDWebImage.xcframework
, located in braze-swift-sdk-prebuilt/static
.
{% endalert %}
While in your build target, select Build Phases. Under Copy Bundle Resources drag and drop the bundles you prepared previously.
!["An example Xcode project with bundles added under 'Copy Bundle Resources.'"]({% image_buster /assets/img/swift/sdk_integration/copy-bundle-resources.png %}) {% endtab %} {% endtabs %}
If your Xcode project only contains Objective-C files, you may get "missing symbol" errors when you try to build your project. To fix these errors, open your project and add an empty Swift file to your file tree. This will force your build toolchain to embed Swift Runtime and link to the appropriate frameworks during build time.
FILE_NAME.swift
Replace FILE_NAME
with any non-spaced string. Your file should look similar to the following:
empty_swift_file.swift