Browse Source

Merge branch 'feature/swift-2.0'

Evgenii Neumerzhitckii 10 years ago
parent
commit
d54ba2bed9

+ 1 - 1
Demo/Info.plist

@@ -7,7 +7,7 @@
 	<key>CFBundleExecutable</key>
 	<string>$(EXECUTABLE_NAME)</string>
 	<key>CFBundleIdentifier</key>
-	<string>com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)</string>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>

+ 4 - 2
Demo/ViewController.swift

@@ -21,8 +21,10 @@ class ViewController: UIViewController {
   }
   
   @IBAction func onSaveTapped(sender: AnyObject) {
-    KeychainSwift.set(textField.text, forKey: TegKeychainDemo_keyName)
-    updateValueLabel()
+    if let text = textField.text {
+      KeychainSwift.set(text, forKey: TegKeychainDemo_keyName)
+      updateValueLabel()
+    }
   }
   
   @IBAction func onDeleteTapped(sender: AnyObject) {

+ 15 - 15
Distrib/KeychainSwiftDistrib.swift

@@ -30,9 +30,9 @@ public class KeychainSwift {
   
   Stores the text value in the keychain item under the given key.
   
-  :param: key Key under which the text value is stored in the keychain.
-  :param: value Text string to be written to the keychain.
-  :param: withAccess Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
+  - parameter key: Key under which the text value is stored in the keychain.
+  - parameter value: Text string to be written to the keychain.
+  - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
 
   */
   public class func set(value: String, forKey key: String,
@@ -49,11 +49,11 @@ public class KeychainSwift {
   
   Stores the data in the keychain item under the given key.
   
-  :param: key Key under which the data is stored in the keychain.
-  :param: value Data to be written to the keychain.
-  :param: withAccess Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
+  - parameter key: Key under which the data is stored in the keychain.
+  - parameter value: Data to be written to the keychain.
+  - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
   
-  :returns: True if the text was successfully written to the keychain.
+  - returns: True if the text was successfully written to the keychain.
   
   */
   public class func set(value: NSData, forKey key: String,
@@ -81,8 +81,8 @@ public class KeychainSwift {
   
   Retrieves the text value from the keychain that corresponds to the given key.
   
-  :param: key The key that is used to read the keychain item.
-  :returns: The text value from the keychain. Returns nil if unable to read the item.
+  - parameter key: The key that is used to read the keychain item.
+  - returns: The text value from the keychain. Returns nil if unable to read the item.
   
   */
   public class func get(key: String) -> String? {
@@ -99,8 +99,8 @@ public class KeychainSwift {
   
   Retrieves the data from the keychain that corresponds to the given key.
   
-  :param: key The key that is used to read the keychain item.
-  :returns: The text value from the keychain. Returns nil if unable to read the item.
+  - parameter key: The key that is used to read the keychain item.
+  - returns: The text value from the keychain. Returns nil if unable to read the item.
   
   */
   public class func getData(key: String) -> NSData? {
@@ -125,8 +125,8 @@ public class KeychainSwift {
   
   Deletes the single keychain item specified by the key.
   
-  :param: key The key that is used to delete the keychain item.
-  :returns: True if the item was successfully deleted.
+  - parameter key: The key that is used to delete the keychain item.
+  - returns: True if the item was successfully deleted.
   
   */
   public class func delete(key: String) -> Bool {
@@ -143,7 +143,7 @@ public class KeychainSwift {
   
   Deletes all keychain items used by the app.
   
-  :returns: True if the keychain items were successfully deleted.
+  - returns: True if the keychain items were successfully deleted.
   
   */
   public class func clear() -> Bool {
@@ -296,7 +296,7 @@ public struct KeychainSwiftConstants {
   public static var accessible: String { return toString(kSecAttrAccessible) }
 
   static func toString(value: CFStringRef) -> String {
-    return (value as? String) ?? ""
+    return value as String
   }
 }
 

+ 11 - 9
KeychainSwift.xcodeproj/project.pbxproj

@@ -290,7 +290,8 @@
 		7ED6C9631B1C118F00FE8090 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				LastUpgradeCheck = 0640;
+				LastSwiftUpdateCheck = 0700;
+				LastUpgradeCheck = 0700;
 				ORGANIZATIONNAME = Marketplacer;
 				TargetAttributes = {
 					7ED6C96B1B1C118F00FE8090 = {
@@ -456,6 +457,7 @@
 				CURRENT_PROJECT_VERSION = 1;
 				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
 				ENABLE_STRICT_OBJC_MSGSEND = YES;
+				ENABLE_TESTABILITY = YES;
 				GCC_C_LANGUAGE_STANDARD = gnu99;
 				GCC_DYNAMIC_NO_PIC = NO;
 				GCC_NO_COMMON_BLOCKS = YES;
@@ -533,6 +535,7 @@
 				INFOPLIST_FILE = KeychainSwift/Info.plist;
 				INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 			};
@@ -548,6 +551,7 @@
 				INFOPLIST_FILE = KeychainSwift/Info.plist;
 				INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SKIP_INSTALL = YES;
 			};
@@ -557,16 +561,14 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
-				FRAMEWORK_SEARCH_PATHS = (
-					"$(SDKROOT)/Developer/Library/Frameworks",
-					"$(inherited)",
-				);
+				FRAMEWORK_SEARCH_PATHS = "$(inherited)";
 				GCC_PREPROCESSOR_DEFINITIONS = (
 					"DEBUG=1",
 					"$(inherited)",
 				);
 				INFOPLIST_FILE = KeychainSwiftTests/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_OBJC_BRIDGING_HEADER = "KeychainSwiftTests/KeychainSwiftTests-Bridging-Header.h";
 				SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -577,12 +579,10 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				CLANG_ENABLE_MODULES = YES;
-				FRAMEWORK_SEARCH_PATHS = (
-					"$(SDKROOT)/Developer/Library/Frameworks",
-					"$(inherited)",
-				);
+				FRAMEWORK_SEARCH_PATHS = "$(inherited)";
 				INFOPLIST_FILE = KeychainSwiftTests/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				SWIFT_OBJC_BRIDGING_HEADER = "KeychainSwiftTests/KeychainSwiftTests-Bridging-Header.h";
 			};
@@ -598,6 +598,7 @@
 				);
 				INFOPLIST_FILE = Demo/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Debug;
@@ -608,6 +609,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				INFOPLIST_FILE = Demo/Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
+				PRODUCT_BUNDLE_IDENTIFIER = "com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 			};
 			name = Release;

+ 15 - 1
KeychainSwift.xcodeproj/xcshareddata/xcschemes/KeychainSwift.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "0640"
+   LastUpgradeVersion = "0700"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "YES"
@@ -26,8 +26,19 @@
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       shouldUseLaunchSchemeArgsEnv = "YES"
+      codeCoverageEnabled = "YES"
       buildConfiguration = "Debug">
       <Testables>
+         <TestableReference
+            skipped = "NO">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
+               BuildableName = "KeychainSwiftTests.xctest"
+               BlueprintName = "KeychainSwiftTests"
+               ReferencedContainer = "container:KeychainSwift.xcodeproj">
+            </BuildableReference>
+         </TestableReference>
       </Testables>
       <MacroExpansion>
          <BuildableReference
@@ -38,6 +49,8 @@
             ReferencedContainer = "container:KeychainSwift.xcodeproj">
          </BuildableReference>
       </MacroExpansion>
+      <AdditionalOptions>
+      </AdditionalOptions>
    </TestAction>
    <LaunchAction
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
@@ -47,6 +60,7 @@
       buildConfiguration = "Debug"
       ignoresPersistentStateOnLaunch = "NO"
       debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
       allowLocationSimulation = "YES">
       <MacroExpansion>
          <BuildableReference

+ 0 - 96
KeychainSwift.xcodeproj/xcshareddata/xcschemes/KeychainSwiftTests.xcscheme

@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Scheme
-   LastUpgradeVersion = "0640"
-   version = "1.3">
-   <BuildAction
-      parallelizeBuildables = "YES"
-      buildImplicitDependencies = "YES">
-      <BuildActionEntries>
-         <BuildActionEntry
-            buildForTesting = "YES"
-            buildForRunning = "YES"
-            buildForProfiling = "NO"
-            buildForArchiving = "NO"
-            buildForAnalyzing = "YES">
-            <BuildableReference
-               BuildableIdentifier = "primary"
-               BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
-               BuildableName = "KeychainSwiftTests.xctest"
-               BlueprintName = "KeychainSwiftTests"
-               ReferencedContainer = "container:KeychainSwift.xcodeproj">
-            </BuildableReference>
-         </BuildActionEntry>
-      </BuildActionEntries>
-   </BuildAction>
-   <TestAction
-      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
-      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
-      shouldUseLaunchSchemeArgsEnv = "YES"
-      buildConfiguration = "Debug">
-      <Testables>
-         <TestableReference
-            skipped = "NO">
-            <BuildableReference
-               BuildableIdentifier = "primary"
-               BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
-               BuildableName = "KeychainSwiftTests.xctest"
-               BlueprintName = "KeychainSwiftTests"
-               ReferencedContainer = "container:KeychainSwift.xcodeproj">
-            </BuildableReference>
-         </TestableReference>
-      </Testables>
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
-            BuildableName = "KeychainSwiftTests.xctest"
-            BlueprintName = "KeychainSwiftTests"
-            ReferencedContainer = "container:KeychainSwift.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
-   </TestAction>
-   <LaunchAction
-      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
-      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
-      launchStyle = "0"
-      useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Debug"
-      ignoresPersistentStateOnLaunch = "NO"
-      debugDocumentVersioning = "YES"
-      allowLocationSimulation = "YES">
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
-            BuildableName = "KeychainSwiftTests.xctest"
-            BlueprintName = "KeychainSwiftTests"
-            ReferencedContainer = "container:KeychainSwift.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
-      <AdditionalOptions>
-      </AdditionalOptions>
-   </LaunchAction>
-   <ProfileAction
-      shouldUseLaunchSchemeArgsEnv = "YES"
-      savedToolIdentifier = ""
-      useCustomWorkingDirectory = "NO"
-      buildConfiguration = "Release"
-      debugDocumentVersioning = "YES">
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "7ED6C9761B1C118F00FE8090"
-            BuildableName = "KeychainSwiftTests.xctest"
-            BlueprintName = "KeychainSwiftTests"
-            ReferencedContainer = "container:KeychainSwift.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
-   </ProfileAction>
-   <AnalyzeAction
-      buildConfiguration = "Debug">
-   </AnalyzeAction>
-   <ArchiveAction
-      buildConfiguration = "Release"
-      revealArchiveInOrganizer = "YES">
-   </ArchiveAction>
-</Scheme>

+ 1 - 1
KeychainSwift/Info.plist

@@ -7,7 +7,7 @@
 	<key>CFBundleExecutable</key>
 	<string>$(EXECUTABLE_NAME)</string>
 	<key>CFBundleIdentifier</key>
-	<string>com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)</string>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>

+ 14 - 14
KeychainSwift/KeychainSwift.swift

@@ -15,9 +15,9 @@ public class KeychainSwift {
   
   Stores the text value in the keychain item under the given key.
   
-  :param: key Key under which the text value is stored in the keychain.
-  :param: value Text string to be written to the keychain.
-  :param: withAccess Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
+  - parameter key: Key under which the text value is stored in the keychain.
+  - parameter value: Text string to be written to the keychain.
+  - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
 
   */
   public class func set(value: String, forKey key: String,
@@ -34,11 +34,11 @@ public class KeychainSwift {
   
   Stores the data in the keychain item under the given key.
   
-  :param: key Key under which the data is stored in the keychain.
-  :param: value Data to be written to the keychain.
-  :param: withAccess Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
+  - parameter key: Key under which the data is stored in the keychain.
+  - parameter value: Data to be written to the keychain.
+  - parameter withAccess: Value that indicates when your app needs access to the text in the keychain item. By default the .AccessibleWhenUnlocked option is used that permits the data to be accessed only while the device is unlocked by the user.
   
-  :returns: True if the text was successfully written to the keychain.
+  - returns: True if the text was successfully written to the keychain.
   
   */
   public class func set(value: NSData, forKey key: String,
@@ -66,8 +66,8 @@ public class KeychainSwift {
   
   Retrieves the text value from the keychain that corresponds to the given key.
   
-  :param: key The key that is used to read the keychain item.
-  :returns: The text value from the keychain. Returns nil if unable to read the item.
+  - parameter key: The key that is used to read the keychain item.
+  - returns: The text value from the keychain. Returns nil if unable to read the item.
   
   */
   public class func get(key: String) -> String? {
@@ -84,8 +84,8 @@ public class KeychainSwift {
   
   Retrieves the data from the keychain that corresponds to the given key.
   
-  :param: key The key that is used to read the keychain item.
-  :returns: The text value from the keychain. Returns nil if unable to read the item.
+  - parameter key: The key that is used to read the keychain item.
+  - returns: The text value from the keychain. Returns nil if unable to read the item.
   
   */
   public class func getData(key: String) -> NSData? {
@@ -110,8 +110,8 @@ public class KeychainSwift {
   
   Deletes the single keychain item specified by the key.
   
-  :param: key The key that is used to delete the keychain item.
-  :returns: True if the item was successfully deleted.
+  - parameter key: The key that is used to delete the keychain item.
+  - returns: True if the item was successfully deleted.
   
   */
   public class func delete(key: String) -> Bool {
@@ -128,7 +128,7 @@ public class KeychainSwift {
   
   Deletes all keychain items used by the app.
   
-  :returns: True if the keychain items were successfully deleted.
+  - returns: True if the keychain items were successfully deleted.
   
   */
   public class func clear() -> Bool {

+ 1 - 1
KeychainSwift/TegKeychainConstants.swift

@@ -17,7 +17,7 @@ public struct KeychainSwiftConstants {
   public static var accessible: String { return toString(kSecAttrAccessible) }
 
   static func toString(value: CFStringRef) -> String {
-    return (value as? String) ?? ""
+    return value as String
   }
 }
 

+ 1 - 1
KeychainSwiftTests/Info.plist

@@ -7,7 +7,7 @@
 	<key>CFBundleExecutable</key>
 	<string>$(EXECUTABLE_NAME)</string>
 	<key>CFBundleIdentifier</key>
-	<string>com.marketplacer.$(PRODUCT_NAME:rfc1034identifier)</string>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>