Skip to content

Commit

Permalink
Merge pull request #404 from kishikawakatsumi/swift42
Browse files Browse the repository at this point in the history
Improve Swift 4.2 compatibility
  • Loading branch information
kishikawakatsumi committed Oct 7, 2018
2 parents d0c6d82 + 405888a commit f77a025
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 19 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Examples/Example-iOS/Example-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
14DAEE8F1A51E1BE0070B77E = {
CreatedOnToolsVersion = 6.2;
DevelopmentTeam = 27AEDK3C9F;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
22 changes: 22 additions & 0 deletions Examples/Example-iOS/Example-iOS/AccountsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,27 @@ class AccountsViewController: UITableViewController {
return cell
}

#if swift(>=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]
Expand All @@ -101,6 +122,7 @@ class AccountsViewController: UITableViewController {
tableView.deleteRows(at: [indexPath], with: .automatic)
}
}
#endif

// MARK:

Expand Down
7 changes: 6 additions & 1 deletion Examples/Example-iOS/Example-iOS/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
4 changes: 2 additions & 2 deletions Lib/Configurations/Base.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ 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;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;

SWIFT_VERSION = 4.1;
SWIFT_VERSION = 4.2;
3 changes: 2 additions & 1 deletion Lib/Configurations/TestHost.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Lib/KeychainAccess.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0930"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
52 changes: 43 additions & 9 deletions Lib/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
]
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -217,12 +242,19 @@ namespace :build do

task :carthage do
sh %[echo 'github \"kishikawakatsumi/KeychainAccess\"' > Cartfile]
if xcode_version.start_with?('8')
sh %[echo SWIFT_VERSION=\"3.0\" > swift3.xcconfig]
sh %[XCODE_XCCONFIG_FILE=`pwd`/swift3.xcconfig carthage update --no-use-binaries]
if xcode_version.start_with?('10')
sh %[echo SWIFT_VERSION=\"4.2\" > swift.xcconfig]
elsif xcode_version.start_with?('9.4')
sh %[echo SWIFT_VERSION=\"4.1\" > swift.xcconfig]
elsif xcode_version.start_with?('9.3')
sh %[echo SWIFT_VERSION=\"4.1\" > swift.xcconfig]
elsif xcode_version.start_with?('9')
sh %[echo SWIFT_VERSION=\"4.0\" > swift.xcconfig]
else
sh %[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

Expand Down Expand Up @@ -255,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')
Expand Down
6 changes: 6 additions & 0 deletions Lib/TestHost/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit f77a025

Please sign in to comment.