This repository hosts the Package.swift
Swift Package Manager file for the Moonsense iOS SDK. The Moonsense iOS SDK is available as two variants: a dynamically linked .xcframework
and a statically linked .xcframework
. This repository also hosts sample applications that demonstrate the use of the Moonsense iOS SDK.
MoonsenseSDK.xcframework
The MoonsenseSDK.xcframework
contains the dynamically linked variant of the Moonsense iOS SDK. When using the dynamically linked variant of the SDK, you must embed the framework within your target so the OS can load it at runtime. This approach works fine if you are building an application that directly consumes the SDK or are building your own framework that is being used internally. If you are building a framework that you are providing to another party and you don't wish for them to see that your framework depends on the Moonsense iOS SDK, see the MoonsenseSDK-static.xcframework
section below.
MoonsenseSDK-static.xcframework
The MoonsenseSDK-static.xcframework
contains the statically linked variant of the Moonsense iOS SDK. When using the statically linked variant of the SDK, the linker will embed the necessary code from the SDK into your target. The Moonsense-static.xcframework
should NOT be embedded into your target. If you are building a framework that you are providing to another party, they will only see your public API and not the Moonsense iOS SDK public API.
.netrc
file with your REPO_ACCESS_TOKEN
.MoonsenseSamples.xcworkspace
Xcode workspace in Xcode.publicToken
variable in ViewController.swift
in the SampleApp
.SampleApp
on your iOS device.The latest release of the SDK is 1.6.0
. Details about the current and past releases can be found here.
.netrc
for Authorizing DownloadsDownloading the Moonsense iOS SDK artifacts requires a REPO_ACCESS_TOKEN
for dl.moonsense.io
. This token is associated to your Moonsense Account and should have been provided to you. In case you do not have one contact [email protected]. Add the following to your ~/.netrc
file:
machine dl.moonsense.io
login token
password <REPO_ACCESS_TOKEN>
protocol https
The Moonsense iOS SDK is available as a Swift Package. Simply use the link to the moonsense-ios-sdk
repo, https://github.com/moonsense/moonsense-ios-sdk, as the Package URL when adding the Swift Package to your project.
Cocoapods distribution is not currently available but will be supported in an upcoming release.
The MoonsenseSDK.xcframework.zip
, MoonsenseSDK-static.xcframework.zip
and MoonsenseSDK.doccarchive.zip
artifacts can also be manually integrated into your project. You can download the latest versions from the following links:
Once downloaded, unzip the files and drop the expanded files into your project.
Note: The downloads require the authorization token as outlined above. For best results download the artifacts using curl
with the -n
option. For example:
curl -n -o MoonsenseSDK.xcframework.zip https://dl.moonsense.io/basic/sdk/raw/names/MoonsenseSDK.xcframework/versions/1.6.0/MoonsenseSDK.xcframework-1.6.0.zip
The SDK requires some configuration information to be setup and associate correctly with your app. To continue, you will need to create a publicToken
for you app on the Moonsense Console.
In order to obtain a token you need to:
Create token
button to obtain the secret and public token to use. The SDK requires the public token as a part of the initialize(publicToken:delegate:)
invocation. You can hold on to the secret token to read from the Moonsense Cloud later.The SDK needs to be initialized before it can be used. Call the Moonsense.initialize(publicToken:delegate:)
method prior to recording. The initialize(publicToken:delegate:)
method also accepts an optional MoonsenseDelegate
to receive events from the SDK. For example:
import MoonsenseSDK
class ViewController: UIViewController {
let publicToken = "<YOUR_TOKEN_HERE>"
...
override func viewDidLoad() {
super.viewDidLoad()
...
Moonsense.initialize(publicToken: publicToken, delegate: self)
}
}
extension ViewController: MoonsenseDelegate {
func didStartSession(_ session: Session) {
// Called each time a session has started
}
func didStopSession(_ session: Session) {
// Called each time a session has stopped
}
func errorDidOccur(error: MoonsenseError) {
// Called each time the Moonsense SDK experiences an error
print("Moonsense Error occurred: \(error.localizedDescription)")
}
}
The SDK records in Session
s. A Session
is defined as a single start and stop point in time. Once the SDK initialized you can use the startSession()
and stopAllSessions()
methods to start and stop recording sessions respectively. If you need finer control over stopping individual sessions, the startSession()
call returns a Session
object that includes a stopSession()
method. For example:
import MoonsenseSDK
class ViewController: UIViewController {
var session: Session?
...
@IBAction func startSession(_ sender: Any) {
session = try? Moonsense.startSession(duration: 30, labels: ["SampleApp"])
}
@IBAction func stopAllSessions(_ sender: Any) {
Moonsense.stopAllSessions()
}
@IBAction func stopLastSession(_ sender: Any) {
if let session = session {
session.stopSession()
session = nil
}
}
}
The moonsense-ios-sdk
GitHub repository contains sample applications and a sample SDK that demonstrate the integration and use of the Moonsense iOS SDK. To get started, open the MoonsenseSamples.xcworkspace
Xcode Workspace.
SampleApp
- This sample app demonstrates the use of the Moonsense iOS SDK within a simple application. The example in this case is quite simple and minimal and can serve as a good starting point for developers looking for a quick integration. The SampleApp
Xcode project contains two targets, SampleApp
and SampleApp-Static
. The SampleApp
target consumes the MoonsenseSDK.xcframework
dynamically linked variant. The SampleApp-Static
target consumes the MoonsenseSDK-static.xcframework
target.SamplePaymentApp
- This sample app demonstrates the library usage of the Moonsense iOS SDK. Note that the SamplePaymentApp
does not directly depend on the Moonsense iOS SDK. Instead it includes a dependency to the SamplePaymentSDK
which consumes the Moonsense iOS SDK statically linked variant. The app developer here does not have any visibility into the Moonsense iOS SDK as they only interface with the SamplePaymentSDK
. The example is useful for SDK/library developers looking to integrate the Moonsense iOS SDK.SampleCoreApp
- This sample app shows how to integrate a variation of the Moonsense iOS SDK called the Core SDK. For all intents and purposes the standard iOS SDK (referred to as the Cloud SDK) should suffice for a majority of use cases. In case you do need specialized use of the Moonsense SDK contact [email protected] for access. Additional information regarding the Core SDK can be found here - Advanced Usage.The Moonsense iOS SDK is distributed under the Moonsense Terms Of Service.
Feel free to raise an Issue around bugs, usage, concerns or feedback.
link |
Stars: 4 |
Last commit: 2 weeks ago |
The full feature list for this release includes:
journeyId
creation that resets at 15 minutes without an active session. journeyId
can still be specified manually as well. See the Moonsense.startSession()
documentation for further details.Int64
values are now represented as String
values when encoded for JSON. This was done to support interoperation with services that are still expecting Protobuf definitions. This is accomplished with the use of the StringRepresentedFixedWidthInt
and StringRepresentedOptionalFixedWidthInt
Swift Property Wrappers.let
properties to public internal(set) var
properties.Architecture & iOS Version | Compressed Size | Uncompressed Size |
---|---|---|
arm64 - (11.0, 12.0) | 362.2 KB | 969.8 KB |
arm64 - (12.2) | 362.2 KB | 969.8 KB |
arm64 - (13.0, 14.0) | 362.2 KB | 969.8 KB |
arm64 - (15.0, 16.0) | 362.2 KB | 969.8 KB |
universal - (all) | 362.2 KB | 969.8 KB |
Architecture & iOS Version | Compressed Size | Uncompressed Size |
---|---|---|
arm64 - (11.0, 12.0) | 248.2 KB | 675.5 KB |
arm64 - (12.2) | 248.2 KB | 675.5 KB |
arm64 - (13.0, 14.0) | 248.2 KB | 675.5 KB |
arm64 - (15.0, 16.0) | 248.2 KB | 675.5 KB |
universal - (all) | 248.2 KB | 675.5 KB |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics