Swiftpack.co - optimizely/swift-sdk as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by optimizely.
optimizely/swift-sdk v4.0.0
Swift SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
⭐️ 21
🕓 6 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/optimizely/swift-sdk.git", from: "v4.0.0")

Optimizely Swift SDK

Apache 2.0 Carthage compatible Build Status Coverage Status Platforms Podspec

This repository houses the Swift SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy) for Mobile and OTT.

Optimizely Feature Experimentation is an A/B testing and feature management tool for product development teams, enabling you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at Optimizely.com, or see the developer documentation.

Optimizely Rollouts is free feature flags for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.

Get started

Use the Swift SDK

Refer to the Swift SDK's developer documentation for detailed instructions on getting started with using the SDK.

Requirements

  • iOS 10.0+ / tvOS 10.0+ / watchOS 3.0+
  • Swift 5+

Install the SDK

Please note below that <platform> is used to represent the platform on which you are building your app. Currently, we support iOS, tvOS, and watchOS platforms.

Swift Package Manager

Add the dependency on the Optimizely Swift SDK with Swift Package Manager in Xcode

  1. File -> Swift Packages -> Add Package Dependency
  2. Enter https://github.com/optimizely/swift-sdk.
  3. Accept the default rules (Version: 'Up to Next Major').

If you have a name conflict with other swift packages when you add the Optimizely swift-sdk dependency to Xcode, you can also try with its aliased repo: "https://github.com/optimizely/optimizely-swift-sdk.git".

CocoaPods

  1. Add the following lines to the Podfile:
    use_frameworks!
    pod 'OptimizelySwiftSDK', '~> 4.0.0'
  1. Run the following command:
    pod install

Further installation instructions for Cocoapods: https://guides.cocoapods.org/using/getting-started.html

Carthage

  1. Add the following lines to the Cartfile:

    github "optimizely/swift-sdk" ~> 4.0.0

  2. Run the following command:

    carthage update

  3. Link the frameworks to your project. Go to your project target's Link Binary With Libraries and drag over the following from the Carthage/Build/<platform> folder:

    Optimizely.framework

  4. To ensure that proper bitcode-related files and dSYMs are copied when archiving your app, you will need to install a Carthage build script:

    • Add a new Run Script phase in your target's Build Phase.
    • In the script area include:
      /usr/local/bin/carthage copy-frameworks
    • Add the frameworks to the Input Files list:
      $(SRCROOT)/Carthage/Build/<platform>/Optimizely.framework
    • Add the paths to the copied frameworks to the Output Files list:
      $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/Optimizely.framework

Futher installation instructions for Carthage: https://github.com/Carthage/Carthage

Feature Management Access

To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely customer success manager.

Use the Swift SDK

Samples

A sample code for SDK initialization and experiments:

let optimizely = OptimizelyClient(sdkKey:"somesdkkey")

optimizely.start{ result in
    do {
        let variation = try optimizely.activate(experimentKey: "background_experiment", userId: "userId", attributes: ["doubleKey":5])
        try optimizely.track(eventKey: "sample_conversion", userId: "userId")
    } catch {
        print(error)
    }
}

See the Optimizely Feature Experimentation developer documentation to learn how to set up your first Swift project and use the SDK.

Contributing

Please see CONTRIBUTING.

Credits

First-party code (under OptimizelySwiftSDK is copyright Optimizely, Inc. and contributors, licensed under Apache 2.0.)

Additional Code

This software incorporates code from the following open source projects:

MurmurHash3:https://github.com/jpedrosa/sua/blob/master/Sources/murmurhash3.swift License (Apache 2.0):https://github.com/jpedrosa/sua/blob/master/LICENSE.txt Ported to Swift4.

SwiftLint:https://github.com/realm/SwiftLint License (MIT):https://github.com/realm/SwiftLint/blob/master/LICENSE Used to enforce Swift style and conventions.

Other Optimizely SDKs

GitHub

link
Stars: 21
Last commit: 6 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Release 4.0.0
6 weeks ago

4.0.0

Jan 18, 2024

New Features

The 4.0.0 release introduces a new primary feature, Advanced Audience Targeting enabled through integration with Optimizely Data Platform (ODP) (#455, #470, #471, #477,#512).

You can use ODP, a high-performance Customer Data Platform (CDP), to easily create complex real-time segments (RTS) using first-party and 50+ third-party data sources out of the box. You can create custom schemas that support the user attributes important for your business, and stitch together user behavior done on different devices to better understand and target your customers for personalized user experiences. ODP can be used as a single source of truth for these segments in any Optimizely or 3rd party tool.

With ODP accounts integrated into Optimizely projects, you can build audiences using segments pre-defined in ODP. The SDK will fetch the segments for given users and make decisions using the segments. For access to ODP audience targeting in your Feature Experimentation account, please contact your Customer Success Manager.

This version includes the following changes:

  • New API added to OptimizelyUserContext:

    • fetchQualifiedSegments(): this API will retrieve user segments from the ODP server. The fetched segments will be used for audience evaluation. The fetched data will be stored in the local cache to avoid repeated network delays.

    • When an OptimizelyUserContext is created, the SDK will automatically send an identify request to the ODP server to facilitate observing user activities.

  • New APIs added to OptimizelyClient:

    • sendOdpEvent(): customers can build/send arbitrary ODP events that will bind user identifiers and data to user profiles in ODP.

    • createUserContext() with anonymous user IDs: user-contexts can be created without a userId. The SDK will create and use a persistent VUID specific to a device when userId is not provided.

For details, refer to our documentation pages:

Breaking Changes

  • ODPManager in the SDK is enabled by default. Unless an ODP account is integrated into the Optimizely projects, most ODPManager functions will be ignored. If needed, ODPManager can be disabled when OptimizelyClient is instantiated.

Bug Fixes

  • Adds a check to only save valid datafile in cache. (#514)
  • Remove redundant post request body in upload task. (#521).
  • Privacy manifest file value for required reason API fixed. (#541)
  • Add coccoapods support for privacy manifest. (#542)
  • Add SPM support added to process privacy manifest. (#544)

Functionality Enhancement

  • Adds support to override sdkName and sdkVersion for events. (#512)
  • Swift async-await support. (#513)
  • Update Github Issue Templates. (#516)
  • Handle duplicate keys in experiment (#523).
  • Add privacy manifest file (#522).

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics