Install Nativebrik SDK to your Apple project
System Requirements:
- minimum iOS version: 15.0 or higher
- minimum XCode version: 15 or higher
- minimum Swift version: 5.9 or higher
Step 1. Install Nativebrik SDK to your app
Nativebrik SDK can be installed using some options below:
Swift Package Manager
Nativebrik is available through Swift Package Manager. To install it, follow the steps below:
- In Xcode, install the SDK by navigating to
File > Add Packages
- In the prompt that appears, select the Nativebrik SDK GitHub repository:
SDK Repository
https://github.com/plaidev/nativebrik-sdk
- Select the version of Nativebrik SDK you want to use. For new projects, we recommend using the newest version of Nativebrik SDK.
- Once you're finished, Xcode will begin resolving your package dependencies and downloading them in the background.
CocoaPods
Nativebrik is available through CocoaPods. To install it, simply add the following line to your Podfile:
project/Podfile
target 'YourAppTarget' do
pod 'Nativebrik'
end
and run pod install
from the terminal.
project/
pod install
XCode build failure could be solved, when it occurs.
Step 2 (SwiftUI). Initialize Nativebrik SDK in your app
Import the Nativebrik
module in your root swfit code:
swift
import SwiftUI
import Nativebrik
Initialize Nativebrik SDK in your root App
struct:
swift
import SwiftUI
import Nativebrik
let nativebrik = {
return NativebrikClient(projectId: "<YOUR_NATIVEBRIK_PROJECT_ID>")
}()
@main
struct YourApp: App {
var body: some Scene {
WindowGroup {
NativebrikProvider(client: nativebrik) {
ContentView()
}
}
}
}
and in #Preview
, add NativebrikProvider
to it if needed:
swift
struct ContentView: View {
@EnvironmentObject var nativebrik: NativebrikClient
var body: some View {
VStack {
nativebrik
.experiment
.embedding("ID_OF_YOUR_EMBEDDING")
.frame(height: 240)
}
}
}
#Preview {
NativebrikProvider(client: nativebrik) {
ContentView()
}
}
Step 2 (UIKit). Initialize Nativebrik SDK in your app
Import the Nativebrik
module in your root swfit code:
swift
import UIKit
import Nativebrik
Initialize Nativebrik SDK in your root view controller:
swift
import UIKit
import Nativebrik
let nativebrik = {
return NativebrikClient(projectId: "<YOUR_NATIVEBRIK_PROJECT_ID>")
}()
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let overlay = nativebrik.experiment.overlayViewController()
self.addChild(overlay)
self.view.addSubview(overlay.view)
}
}