|
1 | | -// ClerkNativeBridge - Provides app-target Clerk SDK operations and SwiftUI view controllers to ClerkExpo. |
2 | | -// This file is injected into the app target by the config plugin. |
3 | | -// It uses the ClerkKit Swift package, which is only accessible from the app target. |
| 1 | +// ClerkNativeBridge - Provides Clerk SDK operations and SwiftUI view controllers to ClerkExpo. |
4 | 2 |
|
5 | 3 | import UIKit |
6 | 4 | import SwiftUI |
7 | 5 | import Observation |
8 | 6 | @_spi(FrameworkIntegration) import ClerkKit |
9 | 7 | import ClerkKitUI |
10 | | -import ClerkExpo // Import the pod to access ClerkNativeBridgeProtocol |
11 | 8 |
|
12 | 9 | private struct ClerkExpoHeaderMiddleware: ClerkRequestMiddleware { |
13 | | - // Replaced by the config plugin when this bridge is copied into the app target. |
14 | | - private static let hostSdkVersion = "__CLERK_EXPO_VERSION__" |
| 10 | + private static var hostSdkVersion: String? { |
| 11 | + Bundle.main.object(forInfoDictionaryKey: "ClerkExpoVersion") as? String |
| 12 | + } |
15 | 13 |
|
16 | 14 | func prepare(_ request: inout URLRequest) async throws { |
17 | 15 | request.addValue("expo", forHTTPHeaderField: "x-clerk-host-sdk") |
18 | | - request.addValue(Self.hostSdkVersion, forHTTPHeaderField: "x-clerk-host-sdk-version") |
| 16 | + if let hostSdkVersion = Self.hostSdkVersion, !hostSdkVersion.isEmpty { |
| 17 | + request.addValue(hostSdkVersion, forHTTPHeaderField: "x-clerk-host-sdk-version") |
| 18 | + } |
19 | 19 | } |
20 | 20 | } |
21 | 21 |
|
@@ -52,14 +52,10 @@ final class ClerkNativeBridge: ClerkNativeBridgeProtocol { |
52 | 52 | return Bundle.main.bundleIdentifier |
53 | 53 | } |
54 | 54 |
|
55 | | - // Register this app-target bridge with the ClerkExpo module. |
56 | | - @MainActor static func register() { |
57 | | - shared.loadThemes() |
58 | | - clerkNativeBridge = shared |
59 | | - } |
60 | | - |
61 | 55 | @MainActor |
62 | 56 | func configure(publishableKey: String, bearerToken: String? = nil) async throws { |
| 57 | + loadThemes() |
| 58 | + |
63 | 59 | if Self.shouldReconfigure(for: publishableKey) { |
64 | 60 | try await Clerk.reconfigure(publishableKey: publishableKey, options: Self.makeClerkOptions()) |
65 | 61 | Self.clerkConfigured = true |
|
0 commit comments