Forráskód Böngészése

Merge pull request #419 from kishikawakatsumi/xcode102

Improvement for Xcode 10.2 and Swift 5 support
Kishikawa Katsumi 6 éve
szülő
commit
51aa8fc582

+ 11 - 0
.travis.yml

@@ -11,6 +11,17 @@ script:
 - "(cd Lib && travis_retry bundle exec rake $ACTION)"
 matrix:
   include:
+  - osx_image: xcode10.2
+    env: ACTION=build
+  - osx_image: xcode10.2
+    env: ACTION='build:carthage'
+  - osx_image: xcode10.2
+    env: ACTION='test:iphonesimulator'
+  - osx_image: xcode10.2
+    env: ACTION='test:appletvsimulator'
+  - osx_image: xcode10.2
+    env: ACTION='test:macosx'
+
   - osx_image: xcode10
     env: ACTION=build
   - osx_image: xcode10

+ 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"

+ 1 - 1
Lib/Configurations/Base.xcconfig

@@ -46,4 +46,4 @@ WATCHOS_DEPLOYMENT_TARGET = 2.0;
 TVOS_DEPLOYMENT_TARGET = 9.0;
 MACOSX_DEPLOYMENT_TARGET = 10.9;
 
-SWIFT_VERSION = 4.2;
+SWIFT_VERSION = 5.0;

+ 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 - 4
Lib/KeychainAccessTests/KeychainAccessTests.swift

@@ -1376,7 +1376,7 @@ class KeychainAccessTests: XCTestCase {
             let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
 
             XCTAssertNil(error)
-            XCTAssertNotNil(accessControl)
+            XCTAssertTrue(accessControl != nil)
         }
         do {
             let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1424,7 +1424,7 @@ class KeychainAccessTests: XCTestCase {
             let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
 
             XCTAssertNil(error)
-            XCTAssertNotNil(accessControl)
+            XCTAssertTrue(accessControl != nil)
         }
         do {
             let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1460,7 +1460,7 @@ class KeychainAccessTests: XCTestCase {
             let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
 
             XCTAssertNil(error)
-            XCTAssertNotNil(accessControl)
+            XCTAssertTrue(accessControl != nil)
         }
         do {
             let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1472,7 +1472,7 @@ class KeychainAccessTests: XCTestCase {
             let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
 
             XCTAssertNil(error)
-            XCTAssertNotNil(accessControl)
+            XCTAssertTrue(accessControl != nil)
         }
         #endif
         #if os(OSX)

+ 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