Skip to content
Merged
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
8 changes: 8 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Swift Package, Sources, and Tests into an
// Android Gradle Project with Kotlin sources and JUnit tests.
import PackageDescription
import Foundation

let package = Package(
name: "skip-keychain",
Expand All @@ -22,3 +23,10 @@ let package = Package(
.testTarget(name: "SkipKeychainTests", dependencies: ["SkipKeychain", .product(name: "SkipTest", package: "skip")], plugins: [.plugin(name: "skipstone", package: "skip")]),
]
)

if ProcessInfo.processInfo.environment["SKIP_BRIDGE"] ?? "0" != "0" {
package.dependencies += [.package(url: "https://source.skip.tools/skip-bridge.git", "0.0.0"..<"2.0.0")]
package.targets.forEach({ target in
target.dependencies += [.product(name: "SkipBridge", package: "skip-bridge")]
})
}
3 changes: 3 additions & 0 deletions Sources/SkipKeychain/Skip/skip.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Configuration file for https://skip.tools project
#
# Kotlin dependencies and Gradle build options for this module can be configured here
skip:
bridging: true

build:
contents:
- block: 'dependencies'
Expand Down
6 changes: 3 additions & 3 deletions Sources/SkipKeychain/SkipKeychain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This is free software: you can redistribute and/or modify it
// under the terms of the GNU Lesser General Public License 3.0
// as published by the Free Software Foundation https://fsf.org
#if !SKIP_BRIDGE
import Foundation
#if !SKIP
import Security
Expand Down Expand Up @@ -187,8 +188,7 @@ public struct Keychain {
#endif

/// Return the set of all stored keys.
public var keys: [String] {
get throws {
public func keys() throws -> [String] {
#if !SKIP
lock.lock()
defer { lock.unlock() }
Expand All @@ -213,7 +213,6 @@ public struct Keychain {
#else
return Array(initializePreferences().getAll().keys)
#endif
}
}

/// Remove all stored key value pairs.
Expand Down Expand Up @@ -292,3 +291,4 @@ public struct KeychainError: Error, CustomStringConvertible {
return message
}
}
#endif
4 changes: 2 additions & 2 deletions Tests/SkipKeychainTests/SkipKeychainTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ final class SkipKeychainTests: XCTestCase {
try skipiOSSimulator()
let keychain = Keychain.shared
try keychain.removeValue(forKey: key)
try XCTAssertFalse(keychain.keys.contains(key))
try XCTAssertFalse(keychain.keys().contains(key))
try keychain.set("value", forKey: key)
try XCTAssertTrue(keychain.keys.contains(key))
try XCTAssertTrue(keychain.keys().contains(key))
}

func testBool() throws {
Expand Down
Loading