Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Swift 4.2 #529

Merged
merged 12 commits into from
Nov 8, 2018
46 changes: 39 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
version: 2
jobs:
build-and-test-swift-4.0:
build-and-test-swift-4.2:
macos:
xcode: "10.0.0"
environment:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
steps:
- checkout
- run: |
- run: |
brew install swiftlint
bundle install --without=development
grep -lR "shouldUseLaunchSchemeArgsEnv" *.* --null | xargs -0 sed -i '' -e 's/shouldUseLaunchSchemeArgsEnv = "YES"/shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"/g'
sed -i "" 's/SWIFT_VERSION = 3.0/SWIFT_VERSION = 4.0/g' "Lock.xcodeproj/project.pbxproj"
- run:
name: Bootstrap
command: bundle exec fastlane ios bootstrap
Expand All @@ -24,7 +23,36 @@ jobs:
DEVICE: iPhone 8
FASTLANE_EXPLICIT_OPEN_SIMULATOR: 2
- run: |
bash <(curl -s https://codecov.io/bash) -J 'Lock'
bash <(curl -s https://codecov.io/bash) -J 'Lock'
- save_cache:
key: dependency-cache
paths:
- Carthage/Build
- store_test_results:
path: fastlane/test_output
build-and-test-swift-4.0:
macos:
xcode: "10.0.0"
environment:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
steps:
- checkout
- run: |
brew install swiftlint
bundle install --without=development
grep -lR "shouldUseLaunchSchemeArgsEnv" *.* --null | xargs -0 sed -i '' -e 's/shouldUseLaunchSchemeArgsEnv = "YES"/shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"/g'
sed -i "" 's/SWIFT_VERSION = 4.2/SWIFT_VERSION = 4.0/g' "Lock.xcodeproj/project.pbxproj"
- run:
name: Bootstrap
command: bundle exec fastlane ios bootstrap
- run:
name: Run test suite
command: bundle exec fastlane ios ci
environment:
SCHEME: Lock
DEVICE: iPhone 8
FASTLANE_EXPLICIT_OPEN_SIMULATOR: 2
- save_cache:
key: dependency-cache
paths:
Expand All @@ -39,11 +67,12 @@ jobs:
LANG: en_US.UTF-8
steps:
- checkout
- run: |
- run: |
brew install swiftlint
sudo gem install bundler
bundle install --without=development
grep -lR "shouldUseLaunchSchemeArgsEnv" *.* --null | xargs -0 sed -i '' -e 's/shouldUseLaunchSchemeArgsEnv = "YES"/shouldUseLaunchSchemeArgsEnv = "YES" codeCoverageEnabled = "YES"/g'
sed -i "" 's/SWIFT_VERSION = 4.2/SWIFT_VERSION = 3.0/g' "Lock.xcodeproj/project.pbxproj"
- run:
name: Bootstrap
command: bundle exec fastlane ios bootstrap
Expand All @@ -63,9 +92,12 @@ jobs:

workflows:
version: 2
build-test-report:
build-test-4.2:
jobs:
- build-and-test-swift-4.2
build-test-4.0:
jobs:
- build-and-test-swift-4.0
build-test:
build-test-3.0:
jobs:
- build-and-test-swift-3.0
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build/
!default.mode2v3
*.perspectivev3
!default.perspectivev3
IDEWorkspaceChecks.plist
xcuserdata
*.xccheckout
profile
Expand Down Expand Up @@ -53,4 +54,4 @@ fastlane/screenshots/
vendor/

#Entitlements
LockApp.entitlements
LockApp.entitlements
13 changes: 10 additions & 3 deletions App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@

import UIKit
import Lock
import Auth0

#if swift(>=4.2)
typealias A0RestorationHandler = UIUserActivityRestoring
#else
typealias A0RestorationHandler = Any
#endif

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [A0ApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
func application(_ app: UIApplication, open url: URL, options: [A0URLOptionsKey : Any]) -> Bool {
return Lock.resumeAuth(url, options: options)
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([A0RestorationHandler]?) -> Void) -> Bool {
return Lock.continueAuth(using: userActivity)
}

Expand Down
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
github "AliSoftware/OHHTTPStubs" "6.1.0"
github "Quick/Nimble" "v7.3.0"
github "Quick/Quick" "v1.3.1"
github "Quick/Nimble" "v7.3.1"
github "Quick/Quick" "v1.3.2"
github "auth0/Auth0.swift" "1.13.0"
github "auth0/SimpleKeychain" "0.8.1"
github "emaloney/CleanroomLogger" "5.1.2"
26 changes: 7 additions & 19 deletions Lock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1023,14 +1023,14 @@
TargetAttributes = {
5BEDE1391EC0A9750007300D = {
CreatedOnToolsVersion = 8.3.2;
LastSwiftMigration = 0930;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
TestTargetID = 5FEADCF31D1A7EBC0032D810;
};
5FEADCF31D1A7EBC0032D810 = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 86WQXF56BC;
LastSwiftMigration = 0930;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.SafariKeychain = {
Expand All @@ -1040,11 +1040,11 @@
};
5FEAE1C51D1A5154005C0028 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0930;
LastSwiftMigration = 1000;
};
5FEAE1CF1D1A5154005C0028 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0920;
LastSwiftMigration = 1000;
ProvisioningStyle = Manual;
TestTargetID = 5FEADCF31D1A7EBC0032D810;
};
Expand Down Expand Up @@ -1135,7 +1135,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\nif [ -f $AUTH0_PLIST ];\nthen\ncp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi";
shellScript = "AUTH0_PLIST=\"${SRCROOT}/Auth0.plist\"\nif [ -f \"$AUTH0_PLIST\" ];\nthen\ncp \"$AUTH0_PLIST\" \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app\"\nfi\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot about this, why was this an issue for you? I do not have a problem here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script fails if the file path has a space. That's why you always need quotes around it.

};
5FEADD061D1A7ECA0032D810 /* Carthage */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -1411,7 +1411,6 @@
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = LockApp;
};
name = Debug;
Expand All @@ -1430,7 +1429,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 4.0;
TEST_TARGET_NAME = LockApp;
};
name = Release;
Expand All @@ -1454,8 +1452,6 @@
PROVISIONING_PROFILE = "97f7985c-a5ce-42be-a3e5-39a6c818bc78";
PROVISIONING_PROFILE_SPECIFIER = "match Development com.auth0.Lock";
REEXPORTED_LIBRARY_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1478,8 +1474,6 @@
PROVISIONING_PROFILE = "97f7985c-a5ce-42be-a3e5-39a6c818bc78";
PROVISIONING_PROFILE_SPECIFIER = "match Development com.auth0.Lock";
REEXPORTED_LIBRARY_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1536,6 +1530,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1588,6 +1583,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand Down Expand Up @@ -1618,8 +1614,6 @@
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1644,8 +1638,6 @@
PRODUCT_NAME = Lock;
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1661,8 +1653,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.auth0.LockTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LockApp.app/LockApp";
};
name = Debug;
Expand All @@ -1679,8 +1669,6 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.auth0.LockTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LockApp.app/LockApp";
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions Lock/AuthButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class AuthButton: UIView {
public var normalColor: UIColor = UIColor.a0_orange {
didSet {
let normal = image(withColor: self.normalColor)
self.button?.setBackgroundImage(normal, for: UIControlState())
self.button?.setBackgroundImage(normal, for: .normal)
}
}

Expand Down Expand Up @@ -150,9 +150,9 @@ public class AuthButton: UIView {
iconView.contentMode = .center
iconView.tintColor = self.titleColor

button.setBackgroundImage(image(withColor: self.color), for: UIControlState())
button.setBackgroundImage(image(withColor: self.color), for: .normal)
button.setBackgroundImage(image(withColor: self.color.a0_darker(0.3)), for: .highlighted)
button.setTitleColor(self.titleColor, for: UIControlState())
button.setTitleColor(self.titleColor, for: .normal)
button.titleLabel?.font = .systemFont(ofSize: 13.33, weight: UIFont.weightMedium)
button.titleLabel?.adjustsFontSizeToFitWidth = true
button.titleLabel?.minimumScaleFactor = 0.5
Expand All @@ -161,7 +161,7 @@ public class AuthButton: UIView {
button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside)

if case .big = self.size {
button.setTitle(self.title, for: UIControlState())
button.setTitle(self.title, for: .normal)
}

self.button = button
Expand Down
2 changes: 1 addition & 1 deletion Lock/AuthCollectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AuthCollectionView: UIView, View {
}

public override var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: self.height)
return CGSize(width: viewNoIntrinsicMetric, height: self.height)
}

private func layout(_ connections: [OAuth2Connection], mode: Mode, insets: UIEdgeInsets) {
Expand Down
14 changes: 7 additions & 7 deletions Lock/DatabaseModeSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ class DatabaseModeSwitcher: UIView {
dimension(dimension: segmented.heightAnchor, withValue: 45)
segmented.translatesAutoresizingMaskIntoConstraints = false

segmented.setDividerImage(image(named: "ic_switcher_left", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .selected, rightSegmentState: UIControlState(), barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_right", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: UIControlState(), rightSegmentState: .selected, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_left", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .selected, rightSegmentState: .normal, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_right", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .normal, rightSegmentState: .selected, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_both", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .selected, rightSegmentState: .selected, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_both", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .highlighted, rightSegmentState: .selected, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_both", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .selected, rightSegmentState: .highlighted, barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_none", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: UIControlState(), rightSegmentState: UIControlState(), barMetrics: .default)
segmented.setDividerImage(image(named: "ic_switcher_none", compatibleWithTraitCollection: self.traitCollection), forLeftSegmentState: .normal, rightSegmentState: .normal, barMetrics: .default)
segmented.setBackgroundImage(image(named: "ic_switcher_selected", compatibleWithTraitCollection: self.traitCollection), for: .selected, barMetrics: .default)
segmented.setBackgroundImage(image(named: "ic_switcher_selected", compatibleWithTraitCollection: self.traitCollection), for: .highlighted, barMetrics: .default)
segmented.setBackgroundImage(image(named: "ic_switcher_normal", compatibleWithTraitCollection: self.traitCollection), for: UIControlState(), barMetrics: .default)
segmented.setBackgroundImage(image(named: "ic_switcher_normal", compatibleWithTraitCollection: self.traitCollection), for: .normal, barMetrics: .default)
segmented.setTitleTextAttributes([
attributedKeyColor: Style.Auth0.tabTextColor,
attributedFont: mediumSystemFont(size: 15)
], for: UIControlState())
], for: .normal)
segmented.setTitleTextAttributes([
attributedKeyColor: Style.Auth0.tabTextColor,
attributedFont: semiBoldSystemFont(size: 15)
Expand All @@ -109,7 +109,7 @@ class DatabaseModeSwitcher: UIView {
}

override var intrinsicContentSize: CGSize {
return CGSize(width: UIViewNoIntrinsicMetric, height: 55)
return CGSize(width: viewNoIntrinsicMetric, height: 55)
}

// MARK: - Internal
Expand All @@ -126,7 +126,7 @@ extension DatabaseModeSwitcher: Stylable {
self.segmentedControl?.setTitleTextAttributes([
attributedKeyColor: style.tabTextColor,
attributedFont: mediumSystemFont(size: 15)
], for: UIControlState())
], for: .normal)
self.segmentedControl?.setTitleTextAttributes([
attributedKeyColor: style.tabTextColor,
attributedFont: semiBoldSystemFont(size: 15)
Expand Down
Loading