Skip to content

Commit

Permalink
Swift 5 (#108)
Browse files Browse the repository at this point in the history
* migrate to Swift 5 and Xcode 10.2

* Bump podspec

* Bump CI Xcode version
  • Loading branch information
designatednerd authored May 6, 2019
1 parent 48f8e51 commit 0f2a919
Show file tree
Hide file tree
Showing 24 changed files with 93 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
jobs:
build-and-test:
macos:
xcode: "10.0.0"
xcode: "10.2.0"
# Use custom shell per https://circleci.com/docs/2.0/testing-ios/#using-custom-versions-of-cocoapods-and-other-ruby-gems
shell: /bin/bash --login -o pipefail
steps:
Expand Down
24 changes: 13 additions & 11 deletions Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -680,13 +680,13 @@
attributes = {
CLASSPREFIX = "";
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "";
TargetAttributes = {
140124C01DBF582900EA92FB = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeam = 29X3GG489T;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
14028E261E9285BE00EEE567 = {
Expand All @@ -701,7 +701,7 @@
};
146D72AB1AB782920058798C = {
CreatedOnToolsVersion = 6.2;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
};
149D81381DBD2A5E00A9EB1A = {
CreatedOnToolsVersion = 8.0;
Expand All @@ -710,7 +710,7 @@
};
149D81511DBD2ADD00A9EB1A = {
CreatedOnToolsVersion = 8.0;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
149D816B1DBD2AFB00A9EB1A = {
Expand All @@ -722,7 +722,7 @@
};
buildConfigurationList = 146D728E1AB782920058798C /* Build configuration list for PBXProject "Demo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Expand Down Expand Up @@ -1057,7 +1057,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1080,7 +1080,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.usesweet.iOSDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down Expand Up @@ -1166,6 +1166,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;
Expand Down Expand Up @@ -1219,6 +1220,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;
Expand Down Expand Up @@ -1278,7 +1280,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.sample.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSDemo.app/iOSDemo";
};
name = Debug;
Expand All @@ -1294,7 +1296,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.sample.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSDemo.app/iOSDemo";
};
name = Release;
Expand Down Expand Up @@ -1362,7 +1364,7 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -1390,7 +1392,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.demo.SweetUIKit;
PRODUCT_NAME = SweetUIKit;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
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 = "1020"
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 = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Demo.xcodeproj/xcshareddata/xcschemes/UITests-App.xcscheme
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 = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Demo.xcodeproj/xcshareddata/xcschemes/iOSDemo.xcscheme
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 = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
11 changes: 10 additions & 1 deletion Demo.xcodeproj/xcshareddata/xcschemes/iOSTests.xcscheme
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 = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -80,6 +80,15 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "146D72AB1AB782920058798C"
BuildableName = "iOSTests.xctest"
BlueprintName = "iOSTests"
ReferencedContainer = "container:Demo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
2 changes: 1 addition & 1 deletion Demo.xcodeproj/xcshareddata/xcschemes/tvOSTests.xcscheme
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 = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
18 changes: 9 additions & 9 deletions Sources/CaseIterable+Sweet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
public extension CaseIterable {

/// Returns the `allCases` static var as an array so it can be accessed based on index.
public static var allCasesArray: [Self] {
static var allCasesArray: [Self] {
if let asArray = self.allCases as? [Self] {
return asArray
} else {
Expand All @@ -25,7 +25,7 @@ public extension CaseIterable {
///
/// - Parameter index: The index in the list of cases for which an enum value is desired.
/// - Returns: The enum value at the given index.
public static func forIndex(_ index: Int) -> Self {
static func forIndex(_ index: Int) -> Self {
guard let item = self.optionalForIndex(index) else {
fatalError("SweetUIKit: Enum \(Self.self) does not contain index \(index)")
}
Expand All @@ -42,7 +42,7 @@ public extension CaseIterable {
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index.
public static func forSection(at indexPath: IndexPath) -> Self {
static func forSection(at indexPath: IndexPath) -> Self {
return forIndex(indexPath.section)
}

Expand All @@ -55,7 +55,7 @@ public extension CaseIterable {
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index.
public static func forRow(at indexPath: IndexPath) -> Self {
static func forRow(at indexPath: IndexPath) -> Self {
return forIndex(indexPath.row)
}

Expand All @@ -68,7 +68,7 @@ public extension CaseIterable {
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index.
public static func forItem(in indexPath: IndexPath) -> Self {
static func forItem(in indexPath: IndexPath) -> Self {
return forIndex(indexPath.item)
}

Expand All @@ -78,7 +78,7 @@ public extension CaseIterable {
///
/// - Parameter index: The index in the list of cases for which an enum value is desired.
/// - Returns: The enum value at the given index, or nil if `allCases` does not contain the given index.
public static func optionalForIndex(_ index: Int) -> Self? {
static func optionalForIndex(_ index: Int) -> Self? {
guard allCasesArray.indices.contains(index) else {
return nil
}
Expand All @@ -95,23 +95,23 @@ public extension CaseIterable {
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index, or nil if `allCases` does not contain the given index.
public static func optionalForSection(at indexPath: IndexPath) -> Self? {
static func optionalForSection(at indexPath: IndexPath) -> Self? {
return optionalForIndex(indexPath.section)
}

/// Gets the enum at the index in `allCases` of the `row` of the passed-in `IndexPath`
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index, or nil if `allCases` does not contain the given index.
public static func optionalForRow(at indexPath: IndexPath) -> Self? {
static func optionalForRow(at indexPath: IndexPath) -> Self? {
return optionalForIndex(indexPath.row)
}

/// Gets the enum at the index in `allCases` of the `item` of the passed-in `IndexPath`
///
/// - Parameter index: The indexPath for which you want the `section` property to be used to retrieve the enum value from `allCases`.
/// - Returns: The enum value at the given index, or nil if `allCases` does not contain the given index.
public static func optionalForItem(at indexPath: IndexPath) -> Self? {
static func optionalForItem(at indexPath: IndexPath) -> Self? {
return optionalForIndex(indexPath.item)
}
}
2 changes: 1 addition & 1 deletion Sources/Identifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public protocol Identifiable {
}

public extension Identifiable {
public static var reuseIdentifier: String {
static var reuseIdentifier: String {
return String(describing: self)
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/IndexPath+Sweet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import UIKit

public extension IndexPath {

public enum Direction {
enum Direction {
case same
case before
case ahead
Expand All @@ -18,7 +18,7 @@ public extension IndexPath {
}
}

public func comparePosition(to indexPath: IndexPath) -> Direction {
func comparePosition(to indexPath: IndexPath) -> Direction {
if section == indexPath.section {
return comparePosition(row, otherRow: indexPath.row)
} else if section < indexPath.section {
Expand All @@ -28,7 +28,7 @@ public extension IndexPath {
}
}

public static func firstIndexPathForIndex(collectionView: UICollectionView, index: Int) -> IndexPath? {
static func firstIndexPathForIndex(collectionView: UICollectionView, index: Int) -> IndexPath? {
var count = 0
let sections = collectionView.numberOfSections
for section in 0 ..< sections {
Expand All @@ -43,7 +43,7 @@ public extension IndexPath {
return nil
}

public func totalRowCount(collectionView: UICollectionView) -> Int {
func totalRowCount(collectionView: UICollectionView) -> Int {
var count = 0
let sections = collectionView.numberOfSections
for section in 0 ..< sections {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jiggly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public extension Jiggly {
return Double.pi * degrees / 180.0
}

public func startBouncing() {
func startBouncing() {
let animationRotationDegrees = 1.25
let random = Double(arc4random_uniform(500))
let r = (random / 500.0) + 0.5
Expand All @@ -33,7 +33,7 @@ public extension Jiggly {
})
}

public func stopBouncing() {
func stopBouncing() {
layer.removeAllAnimations()
transform = .identity
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/String+Sweet.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit

public extension String {
public func width(for font: UIFont) -> CGFloat {
func width(for font: UIFont) -> CGFloat {
let attributes = [NSAttributedString.Key.font: font]
let rect = (self as NSString).boundingRect(with: CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude), options: .usesLineFragmentOrigin, attributes: attributes, context: nil)

Expand Down
8 changes: 4 additions & 4 deletions Sources/UIAlertController+Sweet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public extension UIAlertController {
- parameter message: The message.
- returns: The alert controller.
*/
public static func dismissableAlert(title: String, message: String? = nil) -> UIAlertController {
static func dismissableAlert(title: String, message: String? = nil) -> UIAlertController {
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: NSLocalizedString("Dismiss", comment: ""), style: .cancel, handler: nil))

Expand All @@ -23,7 +23,7 @@ public extension UIAlertController {
- parameter destructiveBlock: The block to be run when the destructive action gets triggered.
- returns: The alert controller.
*/
public static func destructiveConfirmationAlert(title: String? = nil, message: String, destructiveActionTitle: String? = nil, destructiveBlock: (() -> Void)? = nil) -> UIAlertController {
static func destructiveConfirmationAlert(title: String? = nil, message: String, destructiveActionTitle: String? = nil, destructiveBlock: (() -> Void)? = nil) -> UIAlertController {
let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil))

Expand All @@ -41,7 +41,7 @@ public extension UIAlertController {
- parameter error: The error.
- returns: The alert controller.
*/
public static func errorAlert(_ error: NSError) -> UIAlertController {
static func errorAlert(_ error: NSError) -> UIAlertController {
let controller = UIAlertController(title: NSLocalizedString("Oops, something went wrong", comment: ""), message: error.localizedDescription, preferredStyle: .alert)
controller.addAction(UIAlertAction(title: NSLocalizedString("Dismiss", comment: ""), style: .cancel, handler: nil))

Expand All @@ -53,7 +53,7 @@ public extension UIAlertController {
- parameter title: The title.
- returns: The alert controller.
*/
public static func progressAlert(_ title: String) -> UIAlertController {
static func progressAlert(_ title: String) -> UIAlertController {
let controller = UIAlertController(title: title + "\n\n", message: nil, preferredStyle: .alert)
let indicator = UIActivityIndicatorView(style: .white)
indicator.color = UIColor.gray
Expand Down
Loading

0 comments on commit 0f2a919

Please sign in to comment.