diff --git a/Package.swift b/Package.swift index 704ab87..21da2cd 100755 --- a/Package.swift +++ b/Package.swift @@ -36,7 +36,11 @@ let package = Package( "DictionaryCoder", "FigmaGenTools", "Expression", - "KeychainAccess" + .product( + name: "KeychainAccess", + package: "KeychainAccess", + condition: .when(platforms: [.macOS]) + ) ], path: "Sources/FigmaGen" ), @@ -46,7 +50,11 @@ let package = Package( "SwiftCLI", "PathKit", "PromiseKit", - "KeychainAccess" + .product( + name: "KeychainAccess", + package: "KeychainAccess", + condition: .when(platforms: [.macOS]) + ) ], path: "Sources/FigmaGenTools" ), diff --git a/Sources/FigmaGen/Resolvers/AccessToken/DefaultAccessTokenResolver.swift b/Sources/FigmaGen/Resolvers/AccessToken/DefaultAccessTokenResolver.swift index 34d708a..1fc3cdf 100644 --- a/Sources/FigmaGen/Resolvers/AccessToken/DefaultAccessTokenResolver.swift +++ b/Sources/FigmaGen/Resolvers/AccessToken/DefaultAccessTokenResolver.swift @@ -1,5 +1,7 @@ import Foundation +#if os(macOS) import KeychainAccess +#endif final class DefaultAccessTokenResolver: AccessTokenResolver { @@ -9,9 +11,13 @@ final class DefaultAccessTokenResolver: AccessTokenResolver { } else if let environmentVariable = configuration?.environmentVariable, let accessToken = ProcessInfo.processInfo.environment[environmentVariable] { return accessToken - } else if let parameters = configuration?.keychainParameters, - let accessToken = try? Keychain(service: parameters.service).getString(parameters.key) { + } else if let parameters = configuration?.keychainParameters { + #if os(macOS) + let accessToken = try? Keychain(service: parameters.service).getString(parameters.key) return accessToken + #else + return nil + #endif } else { return nil }