Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct OAuthTokenResult: Codable {
}
}

final class KeychainHelper: Sendable {
@MainActor
final class KeychainHelper {
static let shared = KeychainHelper()

private let logger = OSLogger(prefix: "Keychain", logLevel: ShopifyCheckoutKit.configuration.logLevel)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Foundation
import ShopifyCheckoutKit

final class FileLogger: Logger {
final class FileLogger: Logger, @unchecked Sendable {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to remove this @unchecked

private let fileHandle: FileHandle?
private let lock = NSLock()

let logFileUrl: URL

Expand All @@ -24,6 +25,9 @@ final class FileLogger: Logger {
}

public func log(_ message: String) {
lock.lock()
defer { lock.unlock() }

guard let fileHandle else {
print("File handle is nil")
return
Expand All @@ -43,6 +47,9 @@ final class FileLogger: Logger {
}

public func clearLogs() {
lock.lock()
defer { lock.unlock() }

do {
try "".write(toFile: logFileUrl.path, atomically: false, encoding: .utf8)
} catch let error as NSError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@ public enum EnvironmentVariables {
}

private static func getKey(for key: String) -> String {
guard let value = EnvironmentVariables.infoDictionary[key] as? String else {
guard let value = Bundle.main.infoDictionary?[key] as? String else {
fatalError("Environment variable \(key) must be set in the Storefront.xcconfig file")
}
return value
}

private static let infoDictionary: [String: Any] = {
guard let dict = Bundle.main.infoDictionary else {
fatalError("Plist file not found")
}
return dict
}()

public static let storefrontAccessToken: String = getKey(for: Keys.storefrontAccessToken)

public static let storefrontDomain: String = getKey(for: Keys.storefrontDomain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ typealias ProductVariants = Storefront.GetProductsQuery.Data.Products.Node.Varia
typealias ProductVariant = Storefront.GetProductsQuery.Data.Products.Node.Variants.Node
typealias ProductPrice = Storefront.GetProductsQuery.Data.Products.Node.Variants.Node.Price

class Network {
@MainActor
final class Network {
static let shared = Network()

/// Get the device's language code mapped to Shopify's LanguageCode enum
Expand Down
Loading