From c5d4bbadd02aefa0fc117249e04c45b0a302f314 Mon Sep 17 00:00:00 2001 From: Kishikawa Katsumi Date: Sun, 7 Oct 2018 10:15:31 +0900 Subject: [PATCH 1/2] Test with Xcode 10.0 on CI --- .travis.yml | 11 +++++++++++ Lib/Rakefile | 49 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b114b0163..777eb949d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,17 @@ script: - "(cd Lib && travis_retry bundle exec rake $ACTION)" matrix: include: + - osx_image: xcode10 + env: ACTION=build + - osx_image: xcode10 + env: ACTION='build:carthage' + - osx_image: xcode10 + env: ACTION='test:iphonesimulator' + - osx_image: xcode10 + env: ACTION='test:appletvsimulator' + - osx_image: xcode10 + env: ACTION='test:macosx' + - osx_image: xcode9.4 env: ACTION=build - osx_image: xcode9.4 diff --git a/Lib/Rakefile b/Lib/Rakefile index 67a3a4719..187653b9e 100644 --- a/Lib/Rakefile +++ b/Lib/Rakefile @@ -7,7 +7,16 @@ end def destinations(platform: 'iphonesimulator') if platform == 'iphonesimulator' - if xcode_version.start_with?('9.4') + if xcode_version.start_with?('10') + [ 'name=iPhone 5s,OS=12.0', + 'name=iPhone 6,OS=12.0', + 'name=iPhone 6s Plus,OS=12.0', + 'name=iPhone SE,OS=12.0', + 'name=iPad Air 2,OS=12.0', + 'name=iPad Pro (9.7-inch),OS=12.0', + 'name=iPad Pro (12.9-inch),OS=12.0' + ] + elsif xcode_version.start_with?('9.4') [ 'name=iPhone 5s,OS=11.4', 'name=iPhone 6,OS=11.4', 'name=iPhone 6s Plus,OS=11.4', @@ -70,7 +79,11 @@ def destinations(platform: 'iphonesimulator') ] end elsif platform == 'watchsimulator' - if xcode_version.start_with?('9.4') + if xcode_version.start_with?('10') + [ 'name=Apple Watch Series 4 - 40mm,OS=5.0', + 'name=Apple Watch Series 4 - 44mm,OS=5.0' + ] + elsif xcode_version.start_with?('9.4') [ 'name=Apple Watch Series 3 - 38mm,OS=4.3', 'name=Apple Watch Series 3 - 42mm,OS=4.3' ] @@ -100,7 +113,10 @@ def destinations(platform: 'iphonesimulator') ] end elsif platform == 'appletvsimulator' - if xcode_version.start_with?('9.4') + if xcode_version.start_with?('10') + [ 'name=Apple TV 4K,OS=12.0' + ] + elsif xcode_version.start_with?('9.4') [ 'name=Apple TV 4K,OS=11.4' ] elsif xcode_version.start_with?('9.3') @@ -157,7 +173,16 @@ namespace :build do t.add_build_setting('CODE_SIGN_IDENTITY', '') t.add_build_setting('CODE_SIGNING_REQUIRED', 'NO') end - if xcode_version.start_with?('9.4') + if xcode_version.start_with?('10') + t.add_build_setting('SWIFT_VERSION', '4.2') + if platform == 'iphonesimulator' + t.add_destination('name=iPhone 7,OS=12.0') + elsif platform == 'watchsimulator' + t.add_destination('name=Apple Watch Series 4 - 44mm,OS=5.0') + elsif platform == 'appletvsimulator' + t.add_destination('name=Apple TV 4K,OS=12.0') + end + elsif xcode_version.start_with?('9.4') t.add_build_setting('SWIFT_VERSION', '4.1') if platform == 'iphonesimulator' t.add_destination('name=iPhone 7,OS=11.4') @@ -217,11 +242,21 @@ namespace :build do task :carthage do sh %[echo 'github \"kishikawakatsumi/KeychainAccess\"' > Cartfile] - if xcode_version.start_with?('8') + if xcode_version.start_with?('10') + sh %[echo SWIFT_VERSION=\"4.2\" > swift42.xcconfig] + sh %[XCODE_XCCONFIG_FILE=`pwd`/swift42.xcconfig carthage update --no-use-binaries] + elsif xcode_version.start_with?('9.4') + sh %[echo SWIFT_VERSION=\"4.1\" > swift41.xcconfig] + sh %[XCODE_XCCONFIG_FILE=`pwd`/swift41.xcconfig carthage update --no-use-binaries] + elsif xcode_version.start_with?('9.3') + sh %[echo SWIFT_VERSION=\"4.1\" > swift41.xcconfig] + sh %[XCODE_XCCONFIG_FILE=`pwd`/swift41.xcconfig carthage update --no-use-binaries] + elsif xcode_version.start_with?('9') + sh %[echo SWIFT_VERSION=\"4.0\" > swift40.xcconfig] + sh %[XCODE_XCCONFIG_FILE=`pwd`/swift40.xcconfig carthage update --no-use-binaries] + else sh %[echo SWIFT_VERSION=\"3.0\" > swift3.xcconfig] sh %[XCODE_XCCONFIG_FILE=`pwd`/swift3.xcconfig carthage update --no-use-binaries] - else - sh %[carthage update --no-use-binaries] end end end From 405888a2e3eee651116be858daaf3fbe56ce1c95 Mon Sep 17 00:00:00 2001 From: Kishikawa Katsumi Date: Sun, 7 Oct 2018 10:43:33 +0900 Subject: [PATCH 2/2] Improve Swift 4.2 compatibility --- .../Example-iOS.xcodeproj/project.pbxproj | 3 +++ .../xcschemes/Example-iOS.xcscheme | 2 +- .../Example-iOS/AccountsViewController.swift | 22 +++++++++++++++++++ .../Example-iOS/Example-iOS/AppDelegate.swift | 7 +++++- .../AppIcon.appiconset/Contents.json | 5 +++++ Lib/Configurations/Base.xcconfig | 4 ++-- Lib/Configurations/TestHost.xcconfig | 3 ++- Lib/KeychainAccess.xcodeproj/project.pbxproj | 4 ++-- .../xcschemes/KeychainAccess.xcscheme | 2 +- .../xcshareddata/xcschemes/TestHost.xcscheme | 2 +- Lib/Rakefile | 21 +++++++++--------- Lib/TestHost/AppDelegate.swift | 6 +++++ README.md | 3 ++- 13 files changed, 63 insertions(+), 21 deletions(-) diff --git a/Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj b/Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj index ccc51694e..608f7bc11 100644 --- a/Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj +++ b/Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj @@ -163,6 +163,7 @@ 14DAEE8F1A51E1BE0070B77E = { CreatedOnToolsVersion = 6.2; DevelopmentTeam = 27AEDK3C9F; + LastSwiftMigration = 1000; }; }; }; @@ -374,6 +375,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.kishikawakatsumi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -386,6 +388,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.kishikawakatsumi.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Examples/Example-iOS/Example-iOS.xcodeproj/xcshareddata/xcschemes/Example-iOS.xcscheme b/Examples/Example-iOS/Example-iOS.xcodeproj/xcshareddata/xcschemes/Example-iOS.xcscheme index 5ec4478ae..492933c3d 100644 --- a/Examples/Example-iOS/Example-iOS.xcodeproj/xcshareddata/xcschemes/Example-iOS.xcscheme +++ b/Examples/Example-iOS/Example-iOS.xcodeproj/xcshareddata/xcschemes/Example-iOS.xcscheme @@ -1,6 +1,6 @@ =4.2) + override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { + let services = Array(itemsGroupedByService!.keys) + let service = services[indexPath.section] + + let keychain = Keychain(service: service) + let items = keychain.allItems() + + let item = items[indexPath.row] + let key = item["key"] as! String + + keychain[key] = nil + + if items.count == 1 { + reloadData() + tableView.deleteSections(IndexSet(integer: indexPath.section), with: .automatic) + } else { + tableView.deleteRows(at: [indexPath], with: .automatic) + } + } + #else override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { let services = Array(itemsGroupedByService!.keys) let service = services[indexPath.section] @@ -101,6 +122,7 @@ class AccountsViewController: UITableViewController { tableView.deleteRows(at: [indexPath], with: .automatic) } } + #endif // MARK: diff --git a/Examples/Example-iOS/Example-iOS/AppDelegate.swift b/Examples/Example-iOS/Example-iOS/AppDelegate.swift index 375db5662..9d8baeffb 100644 --- a/Examples/Example-iOS/Example-iOS/AppDelegate.swift +++ b/Examples/Example-iOS/Example-iOS/AppDelegate.swift @@ -29,8 +29,13 @@ import UIKit class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? + #if swift(>=4.2) + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + return true + } + #else func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { return true } - + #endif } diff --git a/Examples/Example-iOS/Example-iOS/Images.xcassets/AppIcon.appiconset/Contents.json b/Examples/Example-iOS/Example-iOS/Images.xcassets/AppIcon.appiconset/Contents.json index b8236c653..19882d568 100644 --- a/Examples/Example-iOS/Example-iOS/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Examples/Example-iOS/Example-iOS/Images.xcassets/AppIcon.appiconset/Contents.json @@ -39,6 +39,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Lib/Configurations/Base.xcconfig b/Lib/Configurations/Base.xcconfig index ae1663130..fb0cf3722 100644 --- a/Lib/Configurations/Base.xcconfig +++ b/Lib/Configurations/Base.xcconfig @@ -38,7 +38,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; -CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer; +CODE_SIGN_IDENTITY = ; DEVELOPMENT_TEAM = ; IPHONEOS_DEPLOYMENT_TARGET = 8.0; @@ -46,4 +46,4 @@ WATCHOS_DEPLOYMENT_TARGET = 2.0; TVOS_DEPLOYMENT_TARGET = 9.0; MACOSX_DEPLOYMENT_TARGET = 10.9; -SWIFT_VERSION = 4.1; +SWIFT_VERSION = 4.2; diff --git a/Lib/Configurations/TestHost.xcconfig b/Lib/Configurations/TestHost.xcconfig index 0f370183e..e2f9584ba 100644 --- a/Lib/Configurations/TestHost.xcconfig +++ b/Lib/Configurations/TestHost.xcconfig @@ -13,9 +13,10 @@ EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; PRODUCT_BUNDLE_IDENTIFIER = com.kishikawakatsumi.KeychainAccess.TestHost; CODE_SIGN_ENTITLEMENTS = TestHost/TestHost.entitlements; -PROVISIONING_PROFILE_SPECIFIER[sdk=iphone*] = iOS Development; +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; DEVELOPMENT_TEAM = 27AEDK3C9F; diff --git a/Lib/KeychainAccess.xcodeproj/project.pbxproj b/Lib/KeychainAccess.xcodeproj/project.pbxproj index 6a2fab59a..2b0686d4c 100644 --- a/Lib/KeychainAccess.xcodeproj/project.pbxproj +++ b/Lib/KeychainAccess.xcodeproj/project.pbxproj @@ -267,12 +267,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0930; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "kishikawa katsumi"; TargetAttributes = { 140F195B1A49D79400B0016A = { CreatedOnToolsVersion = 6.1.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; 140F19661A49D79500B0016A = { diff --git a/Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme b/Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme index 7ac666d9e..b10e88d0c 100644 --- a/Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme +++ b/Lib/KeychainAccess.xcodeproj/xcshareddata/xcschemes/KeychainAccess.xcscheme @@ -1,6 +1,6 @@ Cartfile] if xcode_version.start_with?('10') - sh %[echo SWIFT_VERSION=\"4.2\" > swift42.xcconfig] - sh %[XCODE_XCCONFIG_FILE=`pwd`/swift42.xcconfig carthage update --no-use-binaries] + sh %[echo SWIFT_VERSION=\"4.2\" > swift.xcconfig] elsif xcode_version.start_with?('9.4') - sh %[echo SWIFT_VERSION=\"4.1\" > swift41.xcconfig] - sh %[XCODE_XCCONFIG_FILE=`pwd`/swift41.xcconfig carthage update --no-use-binaries] + sh %[echo SWIFT_VERSION=\"4.1\" > swift.xcconfig] elsif xcode_version.start_with?('9.3') - sh %[echo SWIFT_VERSION=\"4.1\" > swift41.xcconfig] - sh %[XCODE_XCCONFIG_FILE=`pwd`/swift41.xcconfig carthage update --no-use-binaries] + sh %[echo SWIFT_VERSION=\"4.1\" > swift.xcconfig] elsif xcode_version.start_with?('9') - sh %[echo SWIFT_VERSION=\"4.0\" > swift40.xcconfig] - sh %[XCODE_XCCONFIG_FILE=`pwd`/swift40.xcconfig carthage update --no-use-binaries] + sh %[echo SWIFT_VERSION=\"4.0\" > swift.xcconfig] else - sh %[echo SWIFT_VERSION=\"3.0\" > swift3.xcconfig] - sh %[XCODE_XCCONFIG_FILE=`pwd`/swift3.xcconfig carthage update --no-use-binaries] + sh %[echo SWIFT_VERSION=\"3.0\" > swift.xcconfig] end + sh %[XCODE_XCCONFIG_FILE=`pwd`/swift.xcconfig carthage update --no-use-binaries] + sh %[find . -name '*.bcsymbolmap' | xargs grep swiftlang] end end @@ -290,8 +287,10 @@ namespace :test do t.coverage = true t.build_dir = 'build' t.hide_shell_script_environment = true - if xcode_version.start_with?('9.4') + if xcode_version.start_with?('10') t.add_build_setting('SWIFT_VERSION', '4.2') + elsif xcode_version.start_with?('9.4') + t.add_build_setting('SWIFT_VERSION', '4.1') elsif xcode_version.start_with?('9.3') t.add_build_setting('SWIFT_VERSION', '4.1') elsif xcode_version.start_with?('9') diff --git a/Lib/TestHost/AppDelegate.swift b/Lib/TestHost/AppDelegate.swift index b76711721..17bf91269 100644 --- a/Lib/TestHost/AppDelegate.swift +++ b/Lib/TestHost/AppDelegate.swift @@ -42,8 +42,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? + #if swift(>=4.2) + private func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + return true + } + #else func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { return true } + #endif } #endif diff --git a/README.md b/README.md index 20458c842..838ef2ca4 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [![Swift 3.x](https://img.shields.io/badge/Swift-3.x-orange.svg?style=flat)](https://swift.org/) [![Swift 4.0](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](https://swift.org/) [![Swift 4.1](https://img.shields.io/badge/Swift-4.1-orange.svg?style=flat)](https://swift.org/) +[![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://swift.org/) KeychainAccess is a simple Swift wrapper for Keychain that works on iOS and OS X. Makes using Keychain APIs extremely easy and much more palatable to use in Swift. @@ -540,7 +541,7 @@ item: [authenticationType: Default, key: honeylemon, server: github.com, class: | **v2.3.x** | iOS 8+, OSX 10.9+, watchOS 2+, tvOS 9+ | 2.0, 2.1, 2.2 | | **v2.4.x** | iOS 8+, OSX 10.9+, watchOS 2+, tvOS 9+ | 2.2, 2.3 | | **v3.0.x** | iOS 8+, OSX 10.9+, watchOS 2+, tvOS 9+ | 3.x | -| **v3.1.x** | iOS 8+, OSX 10.9+, watchOS 2+, tvOS 9+ | 4.0, 4.1 | +| **v3.1.x** | iOS 8+, OSX 10.9+, watchOS 2+, tvOS 9+ | 4.0, 4.1, 4.2 | ## Installation