OBH iOS SDK Integration Guide
This guide explains step by step how to integrate the OBH SDK with your app.
The OBH SDK supports iOS 13 or later.
Requirements
- Minimum iOS SDK version :
13 - A github access to
obh-mobility/obh_ios_sdkrepository packages.
1. Generate a GitHub Personal Access Token
The OBH iOS SDK is available on a private GitHub repository. To be able to add it to your project, you will need access.
First, create a github access token by following github documentation.
Please make sure to grant obh_ios_sdk package at least a "read" permission.
This access token can be configured for building with two different methods:
- Create two environment variables with your GitHub username and GitHub token,
USERNAMEandGITHUB_TOKENin this documentation.
To make new developers onboarding easier, make sure to document the credentials configuration in your project's documentation (in a README.md file for example).
2. Add The SDK to Your Project
The use the OBH SDK in your iOS app, you need to add it to your Xcode project. You can use either Swift Package Manager (SPM) or CocoaPods as dependency managers.
2.1. Swift Package Manager
To integrate the SDK using Swift Package Manager:
- In Xcode, navigate to File --> Swift Packages --> Add Package Dependency
- In the search bar, enter the SDK's GitHub URL:
https://github.com/obh-mobility/obh_ios_sdk.git - Click Add Package, then select the desired version of the OBH SDK. You can check the releases page for the latest version.
- Confirm, and Xcode will fetch the package.
As the OBH SDK repository is private, ensure you have:
- An active GitHub authentication session in Xcode.
- A Personal Access Token (PAT) stored in your Keychain (for HTTPS authentication), as described at the beginning of this document.
Swift Package Manager UI only recognizes recognizes repositories via HTTPS, unless you declare the OBH SDK as a dependency of a Swift Package in its Package.swift file, where you can use the SSH URL.
2.2 CocoaPods
If you’re new to CocoaPods, refer to the CocoaPods Getting Started Guide for detailed installation and usage instructions.
To integrate the SDK using CocoaPods, add the following to your Podfile:
# Add OBH SDK from the private repository
pod 'OBHSDK',
:git => 'git@github.com:obh-mobility/obh_ios_sdk.git',
:tag => '1.0.0'In this case, using SSH is the recommended approach, as it ensures security and prevents the exposure of credentials in the Podfile, which could happen when using a Personal Access Token (PAT).
3. Integrate the OBH SDK
After adding the OBH SDK to your Xcode project, you need to integrate it in your app.
To do so, add the following import statement to your Swift files:
import OBHSDK4. Initialize the OBH SDK
To initialize the OBH SDK, create an instance of ObhSdk and provide the required parameters:
apiBaseUrl: The base URL of the OBH API, which defines the environment to use.token: Your API access token.
If you need to update the API configuration after initialization, use the setAuthCredentials method.
5. Permissions
To enable the OBH app to connect to and interact with the OBH base via Bluetooth, you must declare the appropriate permissions in your app’s configuration file (Info.plist).
These permissions:
- Inform users why Bluetooth access is required,
- Ensure compliance with Apple’s privacy guidelines,
- Are essential for establishing Bluetooth connections and performing related operations.
Without these permissions, the app will not be able to connect to the OBH base.
5.1. Adding Permissions to Info.plist
Add the following entries to your Info.plist file:
<dict>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Used to connect to the base</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Used to connect to the base</string>
</dict>Troubleshooting
Sandbox: rsync.samba(38808)
After integrating the OBH SDK via CocoaPods, you get the following compiler error:
Sandbox: rsync.samba(38808) deny(1) file-write-create /Users/myuser/Library/Developer/Xcode/DerivedData/MyApp-ID/Build/Products/Debug-iphoneos/MyApp.app/Frameworks/Alamofire.framework/.Alamofire.4bK2mBSolution: Disable ENABLE_USER_SCRIPT_SANDBOXING in your app's Build Settings.
You can view the source for this here.
CocoaPods: IPHONEOS_DEPLOYMENT_TARGE is set to 10.0 warning
After integrating the OBH SDK via CocoaPods, you get the following compiler warning:
The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 10.0, but the range of supported deployment target versions is 12.0 to 18.2.99.This warning happens because some pods (or your Podfile) still reference iOS 10.0, even though modern CocoaPods dependencies only support iOS 12+.
The OBHSDK requires iOS 13 or later. To fix this warning, add the following at the end of your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0’
end
end
endSet iOS 13.0 or later depending on the minimum deployment version of your iOS application.