Skip to content

Commit

Permalink
Version 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lowip committed Oct 21, 2024
1 parent 0f1fb36 commit 7698d9c
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 5.0.0

#### Breaking
- Updates the Braze Swift SDK bindings to require releases from the `11.1.1+` SemVer denomination.
- This allows compatibility with any version of the Braze SDK from `11.1.1` up to, but not including, `12.0.0`.
- Refer to the changelog entry for [`11.1.1`](https://github.com/braze-inc/braze-swift-sdk/blob/main/CHANGELOG.md#1111) for more information on potential breaking changes.

## 4.0.0

#### Breaking
Expand Down
17 changes: 13 additions & 4 deletions Example/BasicExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
46EDC6FA27C6B8D200B870D7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46EDC6F927C6B8D200B870D7 /* Assets.xcassets */; };
46EDC6FD27C6B8D200B870D7 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46EDC6FC27C6B8D200B870D7 /* Preview Assets.xcassets */; };
46EDC72127C6B92C00B870D7 /* Segment in Frameworks */ = {isa = PBXBuildFile; productRef = 46EDC72027C6B92C00B870D7 /* Segment */; };
662990A72A760B8E003DE911 /* SegmentBraze in Frameworks */ = {isa = PBXBuildFile; productRef = 662990A62A760B8E003DE911 /* SegmentBraze */; };
70D4F5DE2CC2576F0071AB53 /* SegmentBrazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 70D4F5DD2CC2576F0071AB53 /* SegmentBrazeUI */; };
70D4F5E02CC257BD0071AB53 /* SegmentBraze in Frameworks */ = {isa = PBXBuildFile; productRef = 70D4F5DF2CC257BD0071AB53 /* SegmentBraze */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -31,8 +32,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
70D4F5E02CC257BD0071AB53 /* SegmentBraze in Frameworks */,
46EDC72127C6B92C00B870D7 /* Segment in Frameworks */,
662990A72A760B8E003DE911 /* SegmentBraze in Frameworks */,
70D4F5DE2CC2576F0071AB53 /* SegmentBrazeUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -111,7 +113,8 @@
name = BasicExample;
packageProductDependencies = (
46EDC72027C6B92C00B870D7 /* Segment */,
662990A62A760B8E003DE911 /* SegmentBraze */,
70D4F5DD2CC2576F0071AB53 /* SegmentBrazeUI */,
70D4F5DF2CC257BD0071AB53 /* SegmentBraze */,
);
productName = BasicExample;
productReference = 46EDC6F227C6B8D100B870D7 /* BasicExample.app */;
Expand Down Expand Up @@ -320,6 +323,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.segment.BasicExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -351,6 +355,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.segment.BasicExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
Expand Down Expand Up @@ -396,7 +401,11 @@
package = 46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */;
productName = Segment;
};
662990A62A760B8E003DE911 /* SegmentBraze */ = {
70D4F5DD2CC2576F0071AB53 /* SegmentBrazeUI */ = {
isa = XCSwiftPackageProductDependency;
productName = SegmentBrazeUI;
};
70D4F5DF2CC257BD0071AB53 /* SegmentBraze */ = {
isa = XCSwiftPackageProductDependency;
productName = SegmentBraze;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
"location" : "https://github.com/segmentio/analytics-swift",
"state" : {
"branch" : "main",
"revision" : "72415f4e702117eaa17483d9f1aec2cf93593a56"
"revision" : "98f13168a56db726796c9420f02d5b53a258fe40"
}
},
{
"identity" : "braze-swift-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/braze-inc/braze-swift-sdk",
"state" : {
"revision" : "d54bd0676c6dcc630793f1c4e3be53bb5b51b67e",
"version" : "10.2.0"
"revision" : "66bf1d9b55ec697c82eaa9b499296aa317de26b4",
"version" : "11.1.1"
}
},
{
"identity" : "jsonsafeencoder-swift",
"identity" : "jsonsafeencoding-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/jsonsafeencoder-swift.git",
"location" : "https://github.com/segmentio/jsonsafeencoding-swift.git",
"state" : {
"revision" : "8b70dc8c01b7b041912e30e29d2b488a43f782ac",
"version" : "1.0.1"
"revision" : "af6a8b360984085e36c6341b21ecb35c12f47ebd",
"version" : "2.0.0"
}
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "[email protected]:SDWebImage/SDWebImage.git",
"state" : {
"revision" : "5642d1ffe3dbe628592443bd14154e31929727b4",
"version" : "5.19.2"
"revision" : "8a1be70a625683bc04d6903e2935bf23f3c6d609",
"version" : "5.19.7"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions Example/BasicExample/BasicExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct BasicExampleApp: App {
}

extension Analytics {

@MainActor
static var main: Analytics = {
let analytics = Analytics(
configuration: Configuration(writeKey: segmentWriteKey)
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9

import PackageDescription

Expand All @@ -25,7 +25,7 @@ let package = Package(
),
.package(
url:"https://github.com/braze-inc/braze-swift-sdk",
"10.2.0"..<"11.0.0"
"11.1.1"..<"12.0.0"
),
],
targets: [
Expand Down
13 changes: 9 additions & 4 deletions Sources/SegmentBraze/BrazeDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ public class BrazeDestination: DestinationPlugin, VersionedPlugin {
#if canImport(BrazeUI)
/// The Braze in-app message UI, available when `automaticInAppMessageRegistrationEnabled` is
/// set to `true` on the Segment dashboard.
@MainActor
public internal(set) var inAppMessageUI: BrazeInAppMessageUI? = nil
#endif

private let additionalConfiguration: ((Braze.Configuration) -> Void)?
private let additionalSetup: ((Braze) -> Void)?
private let additionalSetup: (@MainActor (Braze) -> Void)?

/// The IDFA plugin. This is a no-op if no IDFA is provided.
private var idfaPlugin = BrazeIDFAPlugin()
Expand All @@ -93,7 +94,7 @@ public class BrazeDestination: DestinationPlugin, VersionedPlugin {
/// register UI delegates, messaging subscriptions, etc.)
public init(
additionalConfiguration: ((Braze.Configuration) -> Void)? = nil,
additionalSetup: ((Braze) -> Void)? = nil
additionalSetup: (@MainActor (Braze) -> Void)? = nil
) {
self.additionalConfiguration = additionalConfiguration
self.additionalSetup = additionalSetup
Expand Down Expand Up @@ -305,13 +306,17 @@ public class BrazeDestination: DestinationPlugin, VersionedPlugin {
let braze = Braze(configuration: configuration)

#if canImport(BrazeUI)
if settings.automaticInAppMessageRegistrationEnabled == true {
if settings.automaticInAppMessageRegistrationEnabled == true {
MainActor.synchronousRun {
inAppMessageUI = BrazeInAppMessageUI()
braze.inAppMessagePresenter = inAppMessageUI
}
}
#endif

additionalSetup?(braze)
MainActor.synchronousRun {
additionalSetup?(braze)
}

// This is a no-op if no IDFA configuration is provided.
idfaPlugin.braze = braze
Expand Down
44 changes: 44 additions & 0 deletions Sources/SegmentBraze/ConcurrencyExt.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import Foundation

extension MainActor {

/// Runs the given closure on the main actor, blocking the current actor until it completes.
/// - Parameter body: The closure to run.
/// - Returns: The result of the closure.
@_unavailableFromAsync
static func synchronousRun<T>(_ body: @MainActor () throws -> T) rethrows -> T {
if Thread.isMainThread {
return try runUnsafely(body)
} else {
return try DispatchQueue.main.sync {
try runUnsafely(body)
}
}
}

/// Runs the given closure on the main actor unsafely. This function crashes when not called from
/// the main actor serial executor.
///
/// Adapted from https://archive.is/uNlAU#post_2.
///
/// - Parameter body: The closure to run.
/// - Returns: The result of the closure.
@_unavailableFromAsync
private static func runUnsafely<T>(_ body: @MainActor () throws -> T) rethrows -> T {
#if compiler(>=5.9)
if #available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *) {
return try assumeIsolated(body)
}
#elseif compiler(>=5.10)
return try assumeIsolated(body)
#endif

dispatchPrecondition(condition: .onQueue(.main))
return try withoutActuallyEscaping(body) { fn in
// Remove the `@MainActor` / `@Sendable` annotations and execute the closure.
try unsafeBitCast(fn, to: (() throws -> T).self)()
}
}

}

2 changes: 1 addition & 1 deletion Sources/SegmentBraze/Version.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
extension BrazeDestination {
public static let _version = "4.0.0"
public static let _version = "5.0.0"
}

0 comments on commit 7698d9c

Please sign in to comment.