Skip to content

Commit

Permalink
Updated all code in chapter-security to Swift 2.0 (Xcode 7)
Browse files Browse the repository at this point in the history
  • Loading branch information
vandadnp committed Jun 23, 2015
1 parent 4f7d4c3 commit 44b8748
Show file tree
Hide file tree
Showing 59 changed files with 325 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
9D356250196B111800600CD7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Pixolity Ltd.";
TargetAttributes = {
9D356257196B111800600CD7 = {
Expand Down Expand Up @@ -263,6 +264,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -329,6 +331,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = "Authenticating the User with Touch ID/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -340,6 +343,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = "Authenticating the User with Touch ID/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand All @@ -359,6 +363,7 @@
INFOPLIST_FILE = "Authenticating the User with Touch IDTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -375,6 +380,7 @@
INFOPLIST_FILE = "Authenticating the User with Touch IDTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -399,6 +405,7 @@
9D356276196B111800600CD7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9D356277196B111800600CD7 /* Build configuration list for PBXNativeTarget "Authenticating the User with Touch IDTests" */ = {
isa = XCConfigurationList;
Expand All @@ -407,6 +414,7 @@
9D356279196B111800600CD7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,8 @@
ReferencedContainer = "container:Authenticating the User with Touch ID.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -57,8 +59,10 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D356257196B111800600CD7"
Expand All @@ -76,7 +80,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D356257196B111800600CD7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@ class ViewController: UIViewController {
@IBAction func checkTouchIdAvailability(sender: AnyObject) {

let context = LAContext()
var error: NSError?

let isTouchIdAvailable = context.canEvaluatePolicy(
.DeviceOwnerAuthenticationWithBiometrics,
error: &error)

buttonUseTouchId.enabled = isTouchIdAvailable

/* Touch ID is not available */
if isTouchIdAvailable == false{
do {
try context.canEvaluatePolicy(
.DeviceOwnerAuthenticationWithBiometrics)

buttonUseTouchId.enabled = true

let alertController = UIAlertController(title: "Touch ID",
message: "Touch ID is not available",
Expand All @@ -53,6 +49,8 @@ class ViewController: UIViewController {

presentViewController(alertController, animated: true, completion: nil)

} catch {
buttonUseTouchId.enabled = false
}

}
Expand All @@ -61,12 +59,11 @@ class ViewController: UIViewController {
/* We will code this soon */

let context = LAContext()
var error: NSError?
let reason = "Please authenticate with Touch ID " +
"to access your private information"

context.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: reason, reply: {(success: Bool, error: NSError!) in
localizedReason: reason, reply: {success, error in

if success{
/* The user was successfully authenticated */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
9D356146196AF60A00600CD7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Pixolity Ltd.";
TargetAttributes = {
9D35614D196AF60A00600CD7 = {
Expand Down Expand Up @@ -271,6 +272,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -340,6 +342,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vandad Nahavandipoor (J54K6K24Z3)";
INFOPLIST_FILE = "Deleting Exiting Values in the Keychain/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "16B110EE-4B5A-4B6C-9D22-9F18B7FFC1FA";
};
Expand All @@ -355,6 +358,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vandad Nahavandipoor (J54K6K24Z3)";
INFOPLIST_FILE = "Deleting Exiting Values in the Keychain/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "16B110EE-4B5A-4B6C-9D22-9F18B7FFC1FA";
};
Expand All @@ -375,6 +379,7 @@
INFOPLIST_FILE = "Deleting Exiting Values in the KeychainTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -391,6 +396,7 @@
INFOPLIST_FILE = "Deleting Exiting Values in the KeychainTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,8 @@
ReferencedContainer = "container:Deleting Exiting Values in the Keychain.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -57,8 +59,10 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D35614D196AF60A00600CD7"
Expand All @@ -76,7 +80,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D35614D196AF60A00600CD7"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
let service = NSBundle.mainBundle().bundleIdentifier!

let query = [
kSecClass as! String :
kSecClassGenericPassword as! String,
kSecClass as String :
kSecClassGenericPassword as String,

kSecAttrService as! String : service,
kSecAttrAccount as! String : keyToSearchFor,
kSecAttrService as String : service,
kSecAttrAccount as String : keyToSearchFor,
]


Expand All @@ -51,13 +51,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

let deleted = Int(SecItemDelete(query))
if deleted == Int(errSecSuccess){
println("Successfully deleted the item")
print("Successfully deleted the item")
} else {
println("Failed to delete the item")
print("Failed to delete the item")
}

} else {
println("Error happened with code: \(foundExisting)")
print("Error happened with code: \(foundExisting)")
}

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.pixolity.ios.cookbook.app</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
9D428968196AB4DF00B75A99 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Pixolity Ltd.";
TargetAttributes = {
9D42896F196AB4DF00B75A99 = {
Expand Down Expand Up @@ -263,6 +264,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
Expand Down Expand Up @@ -330,6 +332,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Vandad Nahavandipoor (J54K6K24Z3)";
INFOPLIST_FILE = "Enabling Security and Protection for Your Apps/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "16B110EE-4B5A-4B6C-9D22-9F18B7FFC1FA";
};
Expand All @@ -342,6 +345,7 @@
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = "Enabling Security and Protection for Your Apps/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "16B110EE-4B5A-4B6C-9D22-9F18B7FFC1FA";
};
Expand All @@ -362,6 +366,7 @@
INFOPLIST_FILE = "Enabling Security and Protection for Your AppsTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand All @@ -378,6 +383,7 @@
INFOPLIST_FILE = "Enabling Security and Protection for Your AppsTests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
METAL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.pixolity.ios.cookbook.app;
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUNDLE_LOADER)";
};
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0600"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,8 @@
ReferencedContainer = "container:Enabling Security and Protection for Your Apps.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
Expand All @@ -57,8 +59,10 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D42896F196AB4DF00B75A99"
Expand All @@ -76,7 +80,8 @@
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "9D42896F196AB4DF00B75A99"
Expand Down
Loading

0 comments on commit 44b8748

Please sign in to comment.