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
Classes
folder into your project. Rename if needed. - Use SDK classes directly without importing them
- Copy
-
As
Xcode Project
dependency:Drag&drop
SDK XCode project to your project- Go to
Project settings
->TARGETS
-> Your target ->Build Phases
- Add SDK into
Dependencies
andLink Binary With Libraries
groups
-
As part of
Xcode Workspace
in form ofXcode Project
dependency- 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
XCFramework
making step from appropriateoutputs/platform_device.xcarchive
andoutputs/platform_simulator.xcarchive
files (in Finder tap Show Package Contents and go to Products->Library->Frameworks folder) - Refer
Embedding Frameworks In An App
document from list below - Pay attention to
Embed & Code Sign
option if needed
-
As
XCFramework
:- Build XCFramework (refer iOS SDK XCFramework How-To document)
Drag&drop
xcframework to your project- Refer
Embedding Frameworks In An App
document from list below - Pay attention to
Embed & Code Sign
option if needed - Please pay attention that in your exact case XCFramework may require additional configuration or rebuilding.
Important: At the moment the script
make_framework
contains 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
Configurable
functions:
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
AcousticContentSDKSample
folder - Find and open
AcousticContentSDKSample.xcworkspace
Important: since
AcousticContentSDKSample
is 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.swift
file - Find
AcousticContent
helper class and edit appropriatebaseUrl
andtenantId
Important please pay attention to existing form of every constant: baseURL - it is a domain name with preceding https://
- Select
AcousticContentSDKSample
scheme and clickRun
.