Explorar o código

Add ObjC bridge and instructions

Evgenii Neumerzhitckii %!s(int64=9) %!d(string=hai) anos
pai
achega
ab69741b3e
Modificáronse 2 ficheiros con 10 adicións e 0 borrados
  1. 6 0
      Demo/KeychainSwiftCBridge.swift
  2. 4 0
      README.md

+ 6 - 0
Demo/KeychainSwiftCBridge.swift

@@ -1,3 +1,7 @@
+import Security
+import Foundation
+import KeychainSwift // You might need to remove these imports in your project
+
 /**
 /**
  
  
  This file can be used in your ObjC project if you want to use KeychainSwift Swift library.
  This file can be used in your ObjC project if you want to use KeychainSwift Swift library.
@@ -19,6 +23,8 @@
  [keychain set:@"Hello World" forKey:@"my key"];
  [keychain set:@"Hello World" forKey:@"my key"];
  NSString *value = [keychain get:@"my key"];
  NSString *value = [keychain get:@"my key"];
  
  
+ 3. You might need to remove `import KeychainSwift` import from this file in your project.
+ 
  */
  */
 @objc public class KeychainSwiftCBridge: NSObject {
 @objc public class KeychainSwiftCBridge: NSObject {
   let keychain = KeychainSwift()
   let keychain = KeychainSwift()

+ 4 - 0
README.md

@@ -204,6 +204,10 @@ keychain.set("hello world", forKey: "my key")
 if keychain.lastResultCode != noErr { /* Report error */ }
 if keychain.lastResultCode != noErr { /* Report error */ }
 ```
 ```
 
 
+## Using KeychainSwift from Objective-C
+
+[This manual](https://github.com/evgenyneu/Auk/wiki/Using-Auk-in-Objective-C-project) describes how to use KeychainSwift in Objective-C apps.
+
 ## Known serious issue
 ## Known serious issue
 
 
 It [has been reported](https://github.com/marketplacer/keychain-swift/issues/15) that the library sometimes returns `nil`  instead of the stored Keychain value. The issue seems to be random and hard to reproduce. It may be connected with [the Keychain issue](https://forums.developer.apple.com/thread/4743) reported on Apple developer forums. If you experienced this problem feel free to create an issue so we can discuss it and find solutions.
 It [has been reported](https://github.com/marketplacer/keychain-swift/issues/15) that the library sometimes returns `nil`  instead of the stored Keychain value. The issue seems to be random and hard to reproduce. It may be connected with [the Keychain issue](https://forums.developer.apple.com/thread/4743) reported on Apple developer forums. If you experienced this problem feel free to create an issue so we can discuss it and find solutions.