Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to Swift 4.2 #199

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adding @available modifiers and updating projects
benlachman committed May 22, 2019
commit 8bff9ff77f76576ed062799c3b2db1a397f5438f
Original file line number Diff line number Diff line change
@@ -263,25 +263,25 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Matthew Palmer";
TargetAttributes = {
056F2A6E1BA42E3C00B24B65 = {
CreatedOnToolsVersion = 7.0;
};
056F2A7A1BA42E3C00B24B65 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
0E13A99F1BA3EE8700A06FF9 = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = 0E13A99B1BA3EE8600A06FF9 /* Build configuration list for PBXProject "Locksmith iOS Example" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -448,7 +448,7 @@
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
@@ -464,7 +464,7 @@
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
@@ -474,6 +474,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
@@ -529,6 +530,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
@@ -583,7 +585,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -597,7 +599,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
14 changes: 10 additions & 4 deletions Locksmith.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -407,12 +407,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 1010;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Mathew Palmer";
TargetAttributes = {
0EC25C581BA385AA004191AF = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
0EC25C611BA385AB004191AF = {
CreatedOnToolsVersion = 7.0;
@@ -427,7 +427,7 @@
};
0EC25CA61BA39C9F004191AF = {
CreatedOnToolsVersion = 7.0;
LastSwiftMigration = 1010;
LastSwiftMigration = 1020;
};
E3DD3B331D84356500A59312 = {
CreatedOnToolsVersion = 8.0;
@@ -446,7 +446,7 @@
};
buildConfigurationList = BFFB19CA1A4870A300CCFFC3 /* Build configuration list for PBXProject "Locksmith" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
@@ -663,6 +663,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "net.matthewpalmer.Locksmith-iOS";
PRODUCT_NAME = Locksmith;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
@@ -685,6 +686,7 @@
PRODUCT_NAME = Locksmith;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
};
name = Release;
};
@@ -820,6 +822,7 @@
PRODUCT_NAME = Locksmith;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
@@ -844,6 +847,7 @@
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
@@ -854,6 +858,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
@@ -916,6 +921,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
8 changes: 8 additions & 0 deletions Source/Locksmith.swift
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ public struct Locksmith {
return request.readFromSecureStore()?.data
}

@available(OSX 10.11, *)
public static func saveData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {
struct CreateRequest: GenericPasswordSecureStorable, CreateableSecureStorable {
let service: String
@@ -38,6 +39,7 @@ public struct Locksmith {
return try request.deleteFromSecureStore()
}

@available(OSX 10.11, *)
public static func updateData(data: [String: Any], forUserAccount userAccount: String, inService service: String = LocksmithDefaultService) throws {
struct UpdateRequest: GenericPasswordSecureStorable, CreateableSecureStorable {
let service: String
@@ -532,6 +534,7 @@ extension CreateableSecureStorable {
}

public extension CreateableSecureStorable where Self : GenericPasswordSecureStorable {
@available(OSX 10.11, *)
var asCreateableSecureStoragePropertyDictionary: [String: Any] {
var old = genericPasswordBaseStoragePropertyDictionary
old[String(kSecValueData)] = NSKeyedArchiver.archivedData(withRootObject: data)
@@ -540,15 +543,18 @@ public extension CreateableSecureStorable where Self : GenericPasswordSecureStor
}

public extension CreateableSecureStorable where Self : GenericPasswordSecureStorable {
@available(OSX 10.11, *)
func createInSecureStore() throws {
try performSecureStorageAction(closure: performCreateRequestClosure, secureStoragePropertyDictionary: asCreateableSecureStoragePropertyDictionary)
}
@available(OSX 10.11, *)
func updateInSecureStore() throws {
try self.updateInSecureStore(query: self.asCreateableSecureStoragePropertyDictionary)
}
}

public extension CreateableSecureStorable where Self : InternetPasswordSecureStorable {
@available(OSX 10.11, *)
var asCreateableSecureStoragePropertyDictionary: [String: Any] {
var old = internetPasswordBaseStoragePropertyDictionary
old[String(kSecValueData)] = NSKeyedArchiver.archivedData(withRootObject: data)
@@ -567,9 +573,11 @@ public extension CreateableSecureStorable {
}

public extension CreateableSecureStorable where Self : InternetPasswordSecureStorable {
@available(OSX 10.11, *)
func createInSecureStore() throws {
try performSecureStorageAction(closure: performCreateRequestClosure, secureStoragePropertyDictionary: asCreateableSecureStoragePropertyDictionary)
}
@available(OSX 10.11, *)
func updateInSecureStore() throws {
try self.updateInSecureStore(query: self.asCreateableSecureStoragePropertyDictionary)
}