Skip to content

Commit 51aa8fc

Browse files
Merge pull request #419 from kishikawakatsumi/xcode102
Improvement for Xcode 10.2 and Swift 5 support
2 parents ae32ab7 + aa6306f commit 51aa8fc

File tree

11 files changed

+47
-16
lines changed

11 files changed

+47
-16
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ script:
1111
- "(cd Lib && travis_retry bundle exec rake $ACTION)"
1212
matrix:
1313
include:
14+
- osx_image: xcode10.2
15+
env: ACTION=build
16+
- osx_image: xcode10.2
17+
env: ACTION='build:carthage'
18+
- osx_image: xcode10.2
19+
env: ACTION='test:iphonesimulator'
20+
- osx_image: xcode10.2
21+
env: ACTION='test:appletvsimulator'
22+
- osx_image: xcode10.2
23+
env: ACTION='test:macosx'
24+
1425
- osx_image: xcode10
1526
env: ACTION=build
1627
- osx_image: xcode10

Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
isa = PBXProject;
158158
attributes = {
159159
LastSwiftUpdateCheck = 0700;
160-
LastUpgradeCheck = 0930;
160+
LastUpgradeCheck = 1020;
161161
ORGANIZATIONNAME = "kishikawa katsumi";
162162
TargetAttributes = {
163163
14DAEE8F1A51E1BE0070B77E = {
@@ -169,7 +169,7 @@
169169
};
170170
buildConfigurationList = 14DAEE8B1A51E1BE0070B77E /* Build configuration list for PBXProject "Example-iOS" */;
171171
compatibilityVersion = "Xcode 3.2";
172-
developmentRegion = English;
172+
developmentRegion = en;
173173
hasScannedForEncodings = 0;
174174
knownRegions = (
175175
en,
@@ -265,6 +265,7 @@
265265
isa = XCBuildConfiguration;
266266
buildSettings = {
267267
ALWAYS_SEARCH_USER_PATHS = NO;
268+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
268269
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
269270
CLANG_CXX_LIBRARY = "libc++";
270271
CLANG_ENABLE_MODULES = YES;
@@ -321,6 +322,7 @@
321322
isa = XCBuildConfiguration;
322323
buildSettings = {
323324
ALWAYS_SEARCH_USER_PATHS = NO;
325+
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
324326
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
325327
CLANG_CXX_LIBRARY = "libc++";
326328
CLANG_ENABLE_MODULES = YES;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1000"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Lib/Configurations/Base.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ WATCHOS_DEPLOYMENT_TARGET = 2.0;
4646
TVOS_DEPLOYMENT_TARGET = 9.0;
4747
MACOSX_DEPLOYMENT_TARGET = 10.9;
4848

49-
SWIFT_VERSION = 4.2;
49+
SWIFT_VERSION = 5.0;

Lib/KeychainAccess.xcodeproj/project.pbxproj

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,24 +267,26 @@
267267
isa = PBXProject;
268268
attributes = {
269269
LastSwiftUpdateCheck = 0730;
270-
LastUpgradeCheck = 1000;
270+
LastUpgradeCheck = 1020;
271271
ORGANIZATIONNAME = "kishikawa katsumi";
272272
TargetAttributes = {
273273
140F195B1A49D79400B0016A = {
274274
CreatedOnToolsVersion = 6.1.1;
275-
LastSwiftMigration = 1000;
275+
DevelopmentTeam = 27AEDK3C9F;
276+
LastSwiftMigration = 1020;
276277
ProvisioningStyle = Automatic;
277278
};
278279
140F19661A49D79500B0016A = {
279280
CreatedOnToolsVersion = 6.1.1;
280281
DevelopmentTeam = 27AEDK3C9F;
281-
LastSwiftMigration = 0900;
282+
LastSwiftMigration = 1020;
283+
ProvisioningStyle = Automatic;
282284
TestTargetID = 14A62FFC1D32922C00809B3F;
283285
};
284286
14A630141D3293C700809B3F = {
285287
CreatedOnToolsVersion = 7.3.1;
286288
DevelopmentTeam = 27AEDK3C9F;
287-
LastSwiftMigration = 0900;
289+
LastSwiftMigration = 1020;
288290
SystemCapabilities = {
289291
com.apple.Keychain = {
290292
enabled = 1;
@@ -295,7 +297,7 @@
295297
};
296298
buildConfigurationList = 140F19561A49D79400B0016A /* Build configuration list for PBXProject "KeychainAccess" */;
297299
compatibilityVersion = "Xcode 3.2";
298-
developmentRegion = English;
300+
developmentRegion = en;
299301
hasScannedForEncodings = 0;
300302
knownRegions = (
301303
en,

Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1000"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/TestHost.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1000"
3+
LastUpgradeVersion = "1020"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Lib/KeychainAccess/Keychain.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,11 @@ public final class Keychain {
653653

654654
public subscript(key: String) -> String? {
655655
get {
656+
#if swift(>=5.0)
657+
return try? get(key)
658+
#else
656659
return (try? get(key)).flatMap { $0 }
660+
#endif
657661
}
658662

659663
set {
@@ -681,7 +685,11 @@ public final class Keychain {
681685

682686
public subscript(data key: String) -> Data? {
683687
get {
688+
#if swift(>=5.0)
689+
return try? getData(key)
690+
#else
684691
return (try? getData(key)).flatMap { $0 }
692+
#endif
685693
}
686694

687695
set {
@@ -699,7 +707,11 @@ public final class Keychain {
699707

700708
public subscript(attributes key: String) -> Attributes? {
701709
get {
710+
#if swift(>=5.0)
711+
return try? get(key) { $0 }
712+
#else
702713
return (try? get(key) { $0 }).flatMap { $0 }
714+
#endif
703715
}
704716
}
705717

Lib/KeychainAccessTests/KeychainAccessTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ class KeychainAccessTests: XCTestCase {
13761376
let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
13771377

13781378
XCTAssertNil(error)
1379-
XCTAssertNotNil(accessControl)
1379+
XCTAssertTrue(accessControl != nil)
13801380
}
13811381
do {
13821382
let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1424,7 +1424,7 @@ class KeychainAccessTests: XCTestCase {
14241424
let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
14251425

14261426
XCTAssertNil(error)
1427-
XCTAssertNotNil(accessControl)
1427+
XCTAssertTrue(accessControl != nil)
14281428
}
14291429
do {
14301430
let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1460,7 +1460,7 @@ class KeychainAccessTests: XCTestCase {
14601460
let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
14611461

14621462
XCTAssertNil(error)
1463-
XCTAssertNotNil(accessControl)
1463+
XCTAssertTrue(accessControl != nil)
14641464
}
14651465
do {
14661466
let accessibility: Accessibility = .whenPasscodeSetThisDeviceOnly
@@ -1472,7 +1472,7 @@ class KeychainAccessTests: XCTestCase {
14721472
let accessControl = SecAccessControlCreateWithFlags(kCFAllocatorDefault, accessibility.rawValue as CFTypeRef, flags, &error)
14731473

14741474
XCTAssertNil(error)
1475-
XCTAssertNotNil(accessControl)
1475+
XCTAssertTrue(accessControl != nil)
14761476
}
14771477
#endif
14781478
#if os(OSX)

Lib/KeychainAccessTests/SharedCredentialTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ class SharedCredentialTests: XCTestCase {
7373
for _ in 0...100_000 {
7474
let password = Keychain.generatePassword()
7575

76+
#if swift(>=4.2)
77+
XCTAssertEqual(password.count, "xxx-xxx-xxx-xxx".count)
78+
#else
7679
XCTAssertEqual(password.characters.count, "xxx-xxx-xxx-xxx".characters.count)
80+
#endif
7781
XCTAssertFalse(passwords.contains(password))
7882

7983
passwords.insert(password)

0 commit comments

Comments
 (0)