Skip to content

Commit

Permalink
Merge branch 'swift4'
Browse files Browse the repository at this point in the history
  • Loading branch information
kgn committed Sep 22, 2018
2 parents 9574a1f + 5835d5e commit 41f2f58
Show file tree
Hide file tree
Showing 40 changed files with 50 additions and 62 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: objective-c
osx_image: xcode9.3
osx_image: xcode10

env:
global:
- PROJECT=KGNAutoLayout
matrix:
- DESTINATION="OS=11.0,name=iPhone 6s Plus" SCHEME=$PROJECT-iOS SDK=iphonesimulator TEST=test
- DESTINATION="OS=11.0,name=Apple TV 1080p" SCHEME=$PROJECT-tvOS SDK=appletvsimulator TEST=test
- DESTINATION="OS=12.0,name=iPhone 6s Plus" SCHEME=$PROJECT-iOS SDK=iphonesimulator TEST=test
- DESTINATION="OS=12.0,name=Apple TV 1080p" SCHEME=$PROJECT-tvOS SDK=appletvsimulator TEST=test

script:
- xcodebuild $TEST -project $PROJECT.xcodeproj -scheme $SCHEME -sdk $SDK -destination "$DESTINATION"
Expand Down
8 changes: 4 additions & 4 deletions Example/AlbumViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class AlbumViewController: UIViewController, UITableViewDataSource, UITableViewD
let statusBarHeight = UIApplication.shared.statusBarFrame.height
let tableView = UITableView(frame: CGRect.zero, style: .plain)
tableView.register(TrackTableViewCell.self, forCellReuseIdentifier: TrackTableViewCell.identifier())
tableView.scrollIndicatorInsets = UIEdgeInsetsMake(statusBarHeight+self.navbarHeight, 0, 0, 0)
tableView.scrollIndicatorInsets = UIEdgeInsets.init(top: statusBarHeight+self.navbarHeight, left: 0, bottom: 0, right: 0)
tableView.separatorColor = UIColor.white.withAlphaComponent(0.1)
tableView.backgroundColor = .clear
tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: screenWidth+statusBarHeight+self.navbarHeight))
Expand Down Expand Up @@ -122,7 +122,7 @@ class AlbumViewController: UIViewController, UITableViewDataSource, UITableViewD
// Becuase we're making a totally custom "nav bar" handle the status bar frame change
NotificationCenter.default.addObserver(
self, selector: .statusBarFrameDidChange,
name: .UIApplicationDidChangeStatusBarFrame,
name: UIApplication.didChangeStatusBarFrameNotification,
object: nil
)
}
Expand All @@ -134,9 +134,9 @@ class AlbumViewController: UIViewController, UITableViewDataSource, UITableViewD
@objc func statusBarFrameDidChange(_ notification: Notification) {
let screenWidth = UIScreen.main.bounds.width
let statusBarHeight = UIApplication.shared.statusBarFrame.height
if let frame = (notification as NSNotification).userInfo?[UIApplicationStatusBarFrameUserInfoKey] as? CGRect {
if let frame = (notification as NSNotification).userInfo?[UIApplication.statusBarFrameUserInfoKey] as? CGRect {
let height = frame.height
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(height+self.navbarHeight, 0, 0, 0)
self.tableView.scrollIndicatorInsets = UIEdgeInsets.init(top: height+self.navbarHeight, left: 0, bottom: 0, right: 0)
self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: screenWidth+statusBarHeight+self.navbarHeight))
}
}
Expand Down
2 changes: 1 addition & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return window
}()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window?.rootViewController = PageViewController()
self.window?.makeKeyAndVisible()
return true
Expand Down
4 changes: 2 additions & 2 deletions Example/PageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PageViewController: UIViewController {
}

func addSubViewController(_ viewController: UIViewController, toView: UIView? = nil, belowSubview: UIView? = nil) {
self.addChildViewController(viewController)
self.addChild(viewController)
var parentView = self.view
if let view = toView {
parentView = view
Expand All @@ -57,7 +57,7 @@ class PageViewController: UIViewController {
} else {
parentView?.addSubview(viewController.view)
}
viewController.didMove(toParentViewController: self)
viewController.didMove(toParent: self)
viewController.view.pinToEdgesOfSuperview()
}

Expand Down
2 changes: 1 addition & 1 deletion Example/ReadmeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ReadmeViewController: UIViewController {

var lastTitle: String!
for snapshot in self.snapshots {
let values = snapshot.characters.split{$0 == "-"}.map(String.init)
let values = snapshot.split{$0 == "-"}.map(String.init)
let title = values.first!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
let selector = values.last!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)

Expand Down
2 changes: 1 addition & 1 deletion Example/SnapshotView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SnapshotView: UIView {
UIGraphicsEndImageContext()

let cachePath = "\(SnapshotView.cacheDirectory())/\(imageName).png"
let imageData = UIImagePNGRepresentation(image)
let imageData = image.pngData()
_ = try? imageData?.write(to: URL(fileURLWithPath: cachePath), options: [])

print("")
Expand Down
Binary file modified Example/Snapshots/centerHorizontallyToItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/centerViewsVertically_separation20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/fillVertically_separation20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/pinBottomEdgeToBottomEdgeOfItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/pinToSideEdgesOfSuperview_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/pinToTopAndBottomEdgesOfSuperview_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/pinTopEdgeToTopEdgeOfItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionAboveItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionBelowItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionToTheLeftOfItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionToTheRightOfItem_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionViewsAbove_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionViewsBelow_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionViewsToTheLeft_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/positionViewsToTheRight_offset20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeToMinHeight40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeToMinWidth40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeToMinWidthAndHeight40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeToWidth80.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeWidthToHeightAspectRatio16by9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Example/Snapshots/sizeWidthToWidthOfItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Example/SpringView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class SpringView: UIView {

override var intrinsicContentSize: CGSize {
if direction == .horizontal {
return CGSize(width: UIViewNoIntrinsicMetric, height: 20)
return CGSize(width: UIView.noIntrinsicMetric, height: 20)
} else {
return CGSize(width: 20, height: UIViewNoIntrinsicMetric)
return CGSize(width: 20, height: UIView.noIntrinsicMetric)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Example/TrackTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TrackTableViewCell: UITableViewCell {
return "\(self)"
}

override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)

self.backgroundColor = .clear
Expand Down
26 changes: 13 additions & 13 deletions KGNAutoLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0800;
LastUpgradeCheck = 0930;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "David Keegan";
TargetAttributes = {
64D31D151D2B0A0D009B93CA = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
};
64D31D221D2B0A72009B93CA = {
CreatedOnToolsVersion = 7.3.1;
Expand All @@ -466,20 +466,20 @@
64EF095D1D3043D400274984 = {
CreatedOnToolsVersion = 8.0;
DevelopmentTeamName = "David Keegan";
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
};
83720E201BCB973700C8A14D = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
};
83720E2A1BCB973700C8A14D = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
};
8376BBFD1BD6AA290084754D = {
CreatedOnToolsVersion = 7.0.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -684,7 +684,7 @@
PRODUCT_NAME = KGNAutoLayout;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -708,7 +708,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand Down Expand Up @@ -757,7 +757,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 10.0;
};
Expand All @@ -777,7 +777,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 10.0;
};
Expand Down Expand Up @@ -910,7 +910,7 @@
PRODUCT_NAME = KGNAutoLayout;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -932,7 +932,7 @@
PRODUCT_NAME = KGNAutoLayout;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -970,7 +970,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.davidkeegan.KGNAutoLayoutExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -985,7 +985,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.davidkeegan.KGNAutoLayoutExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,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
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
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
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
2 changes: 1 addition & 1 deletion ReadmeExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
return window
}()

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window?.rootViewController = ReadmeViewController() // Generate readme examples
self.window?.makeKeyAndVisible()
return true
Expand Down
8 changes: 4 additions & 4 deletions Source/KGNAutoLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ extension UIView {
- Returns: The constraint object.
*/
@discardableResult
public func constrain(item: LayoutItem, attribute itemAttribute: NSLayoutAttribute, toItem: LayoutItem? = nil, attribute toAttribute: NSLayoutAttribute = .notAnAttribute, relatedBy: NSLayoutRelation = .equal, multiplier: CGFloat = 1, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint {
public func constrain(item: LayoutItem, attribute itemAttribute: NSLayoutConstraint.Attribute, toItem: LayoutItem? = nil, attribute toAttribute: NSLayoutConstraint.Attribute = .notAnAttribute, relatedBy: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint {
if let view = item as? UIView {
view.translatesAutoresizingMaskIntoConstraints = false
}
Expand Down Expand Up @@ -906,11 +906,11 @@ extension Array where Element: UIView {
// MARK: - Private
extension UIView {

fileprivate func constrain(sizeAttribute: NSLayoutAttribute, size: CGFloat = 0, relatedBy: NSLayoutRelation = .equal, priority: UILayoutPriority? = nil) -> NSLayoutConstraint {
fileprivate func constrain(sizeAttribute: NSLayoutConstraint.Attribute, size: CGFloat = 0, relatedBy: NSLayoutConstraint.Relation = .equal, priority: UILayoutPriority? = nil) -> NSLayoutConstraint {
return self.constrain(item: self, attribute: sizeAttribute, relatedBy: relatedBy, multiplier: 0, offset: size, priority: priority)
}

fileprivate func constrain(edgeAttribute: NSLayoutAttribute, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint? {
fileprivate func constrain(edgeAttribute: NSLayoutConstraint.Attribute, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint? {
assert(self.superview != nil, "Can't create constraints without a super view")
guard let superview = self.superview else {
return nil
Expand All @@ -919,7 +919,7 @@ extension UIView {
return superview.constrain(item: self, attribute: edgeAttribute, toItem: superview, attribute: edgeAttribute, offset: offset, priority: priority)
}

fileprivate func constrain(attribute: NSLayoutAttribute, toAttribute itemAttribute: NSLayoutAttribute, ofItem item: LayoutItem, relatedBy: NSLayoutRelation = .equal, multiplier: CGFloat = 1, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint? {
fileprivate func constrain(attribute: NSLayoutConstraint.Attribute, toAttribute itemAttribute: NSLayoutConstraint.Attribute, ofItem item: LayoutItem, relatedBy: NSLayoutConstraint.Relation = .equal, multiplier: CGFloat = 1, offset: CGFloat = 0, priority: UILayoutPriority? = nil) -> NSLayoutConstraint? {
let commonSuperview: UIView? = {
guard let view = item as? UIView else {
return self.superview
Expand Down
Loading

0 comments on commit 41f2f58

Please sign in to comment.