Bladeren bron

Improvement for Xcode 10.2 and Swift 5 support

Kishikawa Katsumi 6 jaren geleden
bovenliggende
commit
41ce8d1b84

+ 4 - 2
Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj

@@ -157,7 +157,7 @@
 			isa = PBXProject;
 			attributes = {
 				LastSwiftUpdateCheck = 0700;
-				LastUpgradeCheck = 0930;
+				LastUpgradeCheck = 1020;
 				ORGANIZATIONNAME = "kishikawa katsumi";
 				TargetAttributes = {
 					14DAEE8F1A51E1BE0070B77E = {
@@ -169,7 +169,7 @@
 			};
 			buildConfigurationList = 14DAEE8B1A51E1BE0070B77E /* Build configuration list for PBXProject "Example-iOS" */;
 			compatibilityVersion = "Xcode 3.2";
-			developmentRegion = English;
+			developmentRegion = en;
 			hasScannedForEncodings = 0;
 			knownRegions = (
 				en,
@@ -265,6 +265,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;
@@ -321,6 +322,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;

+ 1 - 1
Examples/Example-iOS/Example-iOS.xcodeproj/xcshareddata/xcschemes/Example-iOS.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1000"
+   LastUpgradeVersion = "1020"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "YES"

+ 2 - 2
Lib/Configurations/Base.xcconfig

@@ -39,11 +39,11 @@ VERSIONING_SYSTEM = "apple-generic";
 VERSION_INFO_PREFIX = "";
 
 CODE_SIGN_IDENTITY = ;
-DEVELOPMENT_TEAM = ;
+DEVELOPMENT_TEAM = 27AEDK3C9F;
 
 IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 WATCHOS_DEPLOYMENT_TARGET = 2.0;
 TVOS_DEPLOYMENT_TARGET = 9.0;
 MACOSX_DEPLOYMENT_TARGET = 10.9;
 
-SWIFT_VERSION = 4.2;
+SWIFT_VERSION = 5.0;

+ 2 - 3
Lib/Configurations/TestHost.xcconfig

@@ -15,9 +15,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.KeychainAccess.TestHost;
 CODE_SIGN_ENTITLEMENTS = TestHost/TestHost.entitlements;
 
 CODE_SIGN_IDENTITY[sdk=iphone*] = iPhone Developer;
-CODE_SIGN_IDENTITY[sdk=macosx*] = Developer ID Application;
-PROVISIONING_PROFILE_SPECIFIER[sdk=iphone*] = iOS Development;
-PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*] = KeychainAccess Tests;
+CODE_SIGN_IDENTITY[sdk=macosx*] = Mac Developer;
+PROVISIONING_PROFILE_SPECIFIER = ;
 
 DEVELOPMENT_TEAM = 27AEDK3C9F;
 

+ 3 - 1
Lib/Configurations/Tests.xcconfig

@@ -19,4 +19,6 @@ EXCLUDED_SOURCE_FILE_NAMES[sdk=watch*] = *;
 EXCLUDED_SOURCE_FILE_NAMES[sdk=appletv*] = SharedCredentialTests.swift;
 EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = SharedCredentialTests.swift;
 
-DEVELOPMENT_TEAM = 27AEDK3C9F;
+CODE_SIGN_STYLE = Automatic;
+DEVELOPMENT_TEAM = ;
+PROVISIONING_PROFILE_SPECIFIER = ;

+ 7 - 5
Lib/KeychainAccess.xcodeproj/project.pbxproj

@@ -267,24 +267,26 @@
 			isa = PBXProject;
 			attributes = {
 				LastSwiftUpdateCheck = 0730;
-				LastUpgradeCheck = 1000;
+				LastUpgradeCheck = 1020;
 				ORGANIZATIONNAME = "kishikawa katsumi";
 				TargetAttributes = {
 					140F195B1A49D79400B0016A = {
 						CreatedOnToolsVersion = 6.1.1;
-						LastSwiftMigration = 1000;
+						DevelopmentTeam = 27AEDK3C9F;
+						LastSwiftMigration = 1020;
 						ProvisioningStyle = Automatic;
 					};
 					140F19661A49D79500B0016A = {
 						CreatedOnToolsVersion = 6.1.1;
 						DevelopmentTeam = 27AEDK3C9F;
-						LastSwiftMigration = 0900;
+						LastSwiftMigration = 1020;
+						ProvisioningStyle = Automatic;
 						TestTargetID = 14A62FFC1D32922C00809B3F;
 					};
 					14A630141D3293C700809B3F = {
 						CreatedOnToolsVersion = 7.3.1;
 						DevelopmentTeam = 27AEDK3C9F;
-						LastSwiftMigration = 0900;
+						LastSwiftMigration = 1020;
 						SystemCapabilities = {
 							com.apple.Keychain = {
 								enabled = 1;
@@ -295,7 +297,7 @@
 			};
 			buildConfigurationList = 140F19561A49D79400B0016A /* Build configuration list for PBXProject "KeychainAccess" */;
 			compatibilityVersion = "Xcode 3.2";
-			developmentRegion = English;
+			developmentRegion = en;
 			hasScannedForEncodings = 0;
 			knownRegions = (
 				en,

+ 1 - 1
Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1000"
+   LastUpgradeVersion = "1020"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "YES"

+ 1 - 1
Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/TestHost.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
-   LastUpgradeVersion = "1000"
+   LastUpgradeVersion = "1020"
    version = "1.3">
    <BuildAction
       parallelizeBuildables = "YES"

+ 12 - 0
Lib/KeychainAccess/Keychain.swift

@@ -653,7 +653,11 @@ public final class Keychain {
 
     public subscript(key: String) -> String? {
         get {
+            #if swift(>=5.0)
+            return try? get(key)
+            #else
             return (try? get(key)).flatMap { $0 }
+            #endif
         }
 
         set {
@@ -681,7 +685,11 @@ public final class Keychain {
 
     public subscript(data key: String) -> Data? {
         get {
+            #if swift(>=5.0)
+            return try? getData(key)
+            #else
             return (try? getData(key)).flatMap { $0 }
+            #endif
         }
 
         set {
@@ -699,7 +707,11 @@ public final class Keychain {
 
     public subscript(attributes key: String) -> Attributes? {
         get {
+            #if swift(>=5.0)
+            return try? get(key) { $0 }
+            #else
             return (try? get(key) { $0 }).flatMap { $0 }
+            #endif
         }
     }
 

+ 4 - 0
Lib/KeychainAccessTests/SharedCredentialTests.swift

@@ -73,7 +73,11 @@ class SharedCredentialTests: XCTestCase {
             for _ in 0...100_000 {
                 let password = Keychain.generatePassword()
 
+                #if swift(>=4.2)
+                XCTAssertEqual(password.count, "xxx-xxx-xxx-xxx".count)
+                #else
                 XCTAssertEqual(password.characters.count, "xxx-xxx-xxx-xxx".characters.count)
+                #endif
                 XCTAssertFalse(passwords.contains(password))
 
                 passwords.insert(password)

+ 1 - 1
Lib/TestHost/AppDelegate.swift

@@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     var window: UIWindow?
 
     #if swift(>=4.2)
-    private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
+    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
         return true
     }
     #else