generated from segment-integrations/analytics-swift-destination-template
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
87 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
} | ||
}, | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)() | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |