Skip to content

Commit

Permalink
Upgrade to Swift 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 14, 2018
1 parent e122ae5 commit 75a9506
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 41 deletions.
19 changes: 11 additions & 8 deletions Gifski.xcodeproj/project.pbxproj
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 51;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -212,9 +212,12 @@
E3AE62821E5CD2F300035A2F = {
CreatedOnToolsVersion = 8.2.1;
DevelopmentTeam = YG56YK5RN5;
LastSwiftMigration = 0920;
LastSwiftMigration = 1000;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.HardenedRuntime = {
enabled = 1;
};
com.apple.Sandbox = {
enabled = 1;
};
Expand All @@ -223,7 +226,7 @@
};
};
buildConfigurationList = E3AE627E1E5CD2F300035A2F /* Build configuration list for PBXProject "Gifski" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 10.0";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down Expand Up @@ -297,7 +300,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed\"\nfi";
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -452,6 +455,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "$(SRCROOT)/Gifski/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -467,8 +471,7 @@
SWIFT_COMPILATION_MODE = singlefile;
SWIFT_OBJC_BRIDGING_HEADER = "Gifski/Gifski-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
USER_HEADER_SEARCH_PATHS = "";
};
name = Debug;
Expand All @@ -482,6 +485,7 @@
CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = YG56YK5RN5;
ENABLE_HARDENED_RUNTIME = YES;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = "$(SRCROOT)/Gifski/Info.plist";
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -495,8 +499,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.sindresorhus.Gifski;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Gifski/Gifski-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
USER_HEADER_SEARCH_PATHS = "";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Gifski/AppDelegate.swift
@@ -1,7 +1,7 @@
import Cocoa

extension NSColor {
static let appTheme = NSColor.controlAccentPolyfill
static let appTheme = NSColor.controlAccentColorPolyfill
}

extension Defaults.Keys {
Expand Down
7 changes: 4 additions & 3 deletions Gifski/MainWindowController.swift
Expand Up @@ -143,14 +143,15 @@ final class MainWindowController: NSWindowController {
}
}
}
}

@objc
override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
extension MainWindowController: NSMenuItemValidation {
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
switch menuItem.action {
case #selector(open)?:
return !isRunning
default:
return super.validateMenuItem(menuItem)
return validateMenuItem(menuItem)
}
}
}
6 changes: 4 additions & 2 deletions Gifski/SavePanelAccessoryViewController.xib
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14113" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14113"/>
<deployment identifier="macosx"/>
<development version="10000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down
12 changes: 6 additions & 6 deletions Gifski/Vendor/CircularProgress.swift
Expand Up @@ -24,7 +24,7 @@ public final class CircularProgress: NSView {
$0.frame = bounds
$0.fontSize = bounds.width * 0.2
$0.position.y = bounds.midY * 0.25
$0.alignmentMode = kCAAlignmentCenter
$0.alignmentMode = .center
$0.font = NSFont.helveticaNeueLight // Not using the system font as it has too much number width variance
}

Expand Down Expand Up @@ -243,7 +243,7 @@ private final class ProgressCircleShapeLayer: CAShapeLayer {
convenience init(radius: Double, center: CGPoint) {
self.init()
fillColor = nil
lineCap = kCALineCapRound
lineCap = .round
path = NSBezierPath.progressCircle(radius: radius, center: center).cgPath
}

Expand All @@ -267,13 +267,13 @@ extension NSBezierPath {
for i in 0..<elementCount {
let type = element(at: i, associatedPoints: &points)
switch type {
case .moveToBezierPathElement:
case .moveTo:
path.move(to: points[0])
case .lineToBezierPathElement:
case .lineTo:
path.addLine(to: points[0])
case .curveToBezierPathElement:
case .curveTo:
path.addCurve(to: points[2], control1: points[0], control2: points[1])
case .closePathBezierPathElement:
case .closePath:
path.closeSubpath()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Gifski/Vendor/DockProgress.swift
Expand Up @@ -147,7 +147,7 @@ private final class ProgressCircleShapeLayer: CAShapeLayer {
convenience init(radius: Double, center: CGPoint) {
self.init()
fillColor = nil
lineCap = kCALineCapRound
lineCap = .round
path = NSBezierPath.progressCircle(radius: radius, center: center).cgPath
}

Expand Down
8 changes: 4 additions & 4 deletions Gifski/VideoDropView.swift
Expand Up @@ -14,7 +14,7 @@ class DropView: SSView {
}

var highlightColor: NSColor {
return .controlAccentPolyfill
return .controlAccentColorPolyfill
}

var acceptedTypes: [NSPasteboard.PasteboardType] {
Expand Down Expand Up @@ -63,7 +63,7 @@ class DropView: SSView {
}

override func draggingEntered(_ sender: NSDraggingInfo) -> NSDragOperation {
if sender.draggingSourceOperationMask().contains(.copy) && onEntered(sender) {
if sender.draggingSourceOperationMask.contains(.copy) && onEntered(sender) {
isDraggingHighlighted = true
return .copy
} else {
Expand Down Expand Up @@ -102,11 +102,11 @@ final class VideoDropView: DropView {
}

override func onEntered(_ sender: NSDraggingInfo) -> Bool {
return sender.draggingPasteboard().fileURLs(types: System.supportedVideoTypes).count == 1
return sender.draggingPasteboard.fileURLs(types: System.supportedVideoTypes).count == 1
}

override func onPerform(_ sender: NSDraggingInfo) -> Bool {
if let url = sender.draggingPasteboard().fileURLs(types: System.supportedVideoTypes).first {
if let url = sender.draggingPasteboard.fileURLs(types: System.supportedVideoTypes).first {
onComplete?([url])
return true
}
Expand Down
24 changes: 8 additions & 16 deletions Gifski/util.swift
Expand Up @@ -45,11 +45,9 @@ struct Meta {

/// macOS 10.14 polyfills
extension NSColor {
static let controlAccentPolyfill: NSColor = {
static let controlAccentColorPolyfill: NSColor = {
if #available(macOS 10.14, *) {
/// TODO: Enable this again when using the 10.14 SDK
// return NSColor.controlAccent
return NSColor(red: 0.10, green: 0.47, blue: 0.98, alpha: 1)
return NSColor.controlAccentColor
} else {
return NSColor(red: 0.10, green: 0.47, blue: 0.98, alpha: 1)
}
Expand Down Expand Up @@ -287,12 +285,6 @@ extension AVAssetImageGenerator {
}
}

/// Remove this when targeting macOS 10.14
extension CMTime {
static var zero: CMTime = kCMTimeZero
static var invalid: CMTime = kCMTimeInvalid
}


extension CMTimeScale {
/**
Expand Down Expand Up @@ -378,7 +370,7 @@ extension AVURLAsset {
let dimensions = track.naturalSize.applying(track.preferredTransform)

return VideoMetadata(
dimensions: CGSize(width: fabs(dimensions.width), height: fabs(dimensions.height)),
dimensions: CGSize(width: abs(dimensions.width), height: abs(dimensions.height)),
duration: duration.seconds,
frameRate: Double(track.nominalFrameRate),
fileSize: url.fileSize
Expand Down Expand Up @@ -688,11 +680,11 @@ extension NSControl {


extension CAMediaTimingFunction {
static let `default` = CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault)
static let linear = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
static let easeIn = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
static let easeOut = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
static let easeInOut = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
static let `default` = CAMediaTimingFunction(name: .default)
static let linear = CAMediaTimingFunction(name: .linear)
static let easeIn = CAMediaTimingFunction(name: .easeIn)
static let easeOut = CAMediaTimingFunction(name: .easeOut)
static let easeInOut = CAMediaTimingFunction(name: .easeInEaseOut)
}


Expand Down

0 comments on commit 75a9506

Please sign in to comment.