iOS SDK for the Acoustic Content Delivery API.
This SDK is designed to help utilize the content hosted in Acoustic Content libraries in mobile applications (headlessly).
This document is intended to help to understand how to use Acoustic Content SDK in your own projects.
-
There are several ways how to add the SDK to your own projects:
-
As source code:
- Copy
Classesfolder into your project. Rename if needed. - Use SDK classes directly without importing them
- Copy
-
As
Xcode Projectdependency:Drag&dropSDK XCode project to your project- Go to
Project settings->TARGETS-> Your target ->Build Phases - Add SDK into
DependenciesandLink Binary With Librariesgroups
-
As part of
Xcode Workspacein form ofXcode Projectdependency- perform actions from previous list but against
Project Workspace
- perform actions from previous list but against
-
As regular or emdedded
Framework:- Build regular Framework
- or build Fat Framework (refer iOS SDK Fat Framework How-To document)
- or extract framework on
XCFrameworkmaking step from appropriateoutputs/platform_device.xcarchiveandoutputs/platform_simulator.xcarchivefiles (in Finder tap Show Package Contents and go to Products->Library->Frameworks folder) - Refer
Embedding Frameworks In An Appdocument from list below - Pay attention to
Embed & Code Signoption if needed
-
As
XCFramework:- Build XCFramework (refer iOS SDK XCFramework How-To document)
Drag&dropxcframework to your project- Refer
Embedding Frameworks In An Appdocument from list below - Pay attention to
Embed & Code Signoption if needed - Please pay attention that in your exact case XCFramework may require additional configuration or rebuilding.
Important: At the moment the script
make_frameworkcontains the actual iOS version for the current iOS SDK installed. You may need to update it according to your current iOS SDK installed on your workstation.
-
-
This information about Frameworks may be helpful:
-
Import the SDK
import AcousticContentSDK- Create API URL:
let url = URL(string: "https://myX.content-cms.com/api/0000-0000-0000-0000-0000")!- Create configuration for SDK:
let config = AcousticContentSDK.Config(apiURL: url)- Create SDK instance:
let sdk = AcousticContentSDK(withConfig: config)- Use login in case SDK requires accessing authenticates resources:
sdk.login(username: "username",
password: "password")
{ (success, error) in
print("Login \(success ? "succeeded" : "failed")")
}- Use logout when needed:
sdk.logout()Now the SDK is ready to retireve data.
- Create instance of DeliverySearch class
let deliverySearch = sdk.deliverySearch()- Get artifact provider (ex.: contentItems), configure request by calling
Configurablefunctions:
deliverySearch.contentItems()
.filterByName("Peru*")
.rows(15)
.sortBy("name", ascending: false)
.get { (result) in
...
}- Retrieve result and process it:
.get { (result) in
// 1. Process error
guard result.error == nil else { return }
// 2. Use data
print("Retrieved \(result.numFound) items")
print("Items: \(result.documents.compactMap({$0.name}).joined(separator: ", "))")
// 3. Prepare next page request provider
nextItems = result.nextPage()
}- Retrieve next page:
nextItems?.get(completion: { (result) in
// ...
nextItems = result.nextPage()
})- Navigate to
AcousticContentSDKSamplefolder - Find and open
AcousticContentSDKSample.xcworkspace
Important: since
AcousticContentSDKSampleis organized in form of Xcode Workspace please pay attention that you do not need to openAcousticContentSDKSample.xcodeproj
- When Xcode with sdk workspace open - navigate to
AppDelegate.swiftfile - Find
AcousticContenthelper class and edit appropriatebaseUrlandtenantId
Important please pay attention to existing form of every constant: baseURL - it is a domain name with preceding https://
- Select
AcousticContentSDKSamplescheme and clickRun.