Skip to content

Commit

Permalink
Migrate to Swift 5 (#27)
Browse files Browse the repository at this point in the history
* upgrade to Swift 5

* fix Xcode 10.2 localization warnings

* remove redundant public modifier from extensions

* update .swift-version
  • Loading branch information
DivineDominion authored and Econa77 committed Aug 27, 2019
1 parent 9f11aa2 commit 6a4e97e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2
5.0
13 changes: 7 additions & 6 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Clipy Project";
TargetAttributes = {
312C0FC01D13AA0300973348 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
};
};
Expand All @@ -153,6 +153,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -236,6 +237,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -291,6 +293,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -345,8 +348,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -360,8 +362,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
13 changes: 7 additions & 6 deletions Lib/KeyHolder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "Clipy Project";
TargetAttributes = {
312C0FDA1D13AA1F00973348 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
};
312C0FE41D13AA1F00973348 = {
CreatedOnToolsVersion = 7.3.1;
Expand All @@ -249,6 +249,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 312C0FD11D13AA1F00973348;
Expand Down Expand Up @@ -357,6 +358,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -415,6 +417,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -480,8 +483,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -502,8 +504,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.clipy-app.KeyHolder";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
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 = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
20 changes: 10 additions & 10 deletions Lib/KeyHolder/RecordView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ public protocol RecordViewDelegate: class {
}

// MARK: - Text Attributes
private extension RecordView {
func modifierTextAttributes(_ modifiers: NSEvent.ModifierFlags, checkModifier: NSEvent.ModifierFlags) -> [NSAttributedString.Key: Any] {
extension RecordView {
fileprivate func modifierTextAttributes(_ modifiers: NSEvent.ModifierFlags, checkModifier: NSEvent.ModifierFlags) -> [NSAttributedString.Key: Any] {
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.alignment = .center
paragraphStyle.lineBreakMode = .byTruncatingTail
Expand Down Expand Up @@ -350,7 +350,7 @@ private extension RecordView {
}

// MARK: - Recording
public extension RecordView {
extension RecordView {
public func beginRecording() -> Bool {
if !isEnabled { return false }
if isRecording { return true }
Expand Down Expand Up @@ -391,7 +391,7 @@ public extension RecordView {
}

// MARK: - Clear Keys
public extension RecordView {
extension RecordView {
public func clear() {
keyCombo = nil
inputModifiers = NSEvent.ModifierFlags(rawValue: 0)
Expand All @@ -407,24 +407,24 @@ public extension RecordView {
}

// MARK: - Modifiers
private extension RecordView {
func validateModifiers(_ modifiers: NSEvent.ModifierFlags?) -> Bool {
extension RecordView {
fileprivate func validateModifiers(_ modifiers: NSEvent.ModifierFlags?) -> Bool {
guard let modifiers = modifiers else { return false }
return KeyTransformer.carbonFlags(from: modifiers) != 0
}
}

// MARK: - Bool Extension
private extension Bool {
var intValue: Int {
extension Bool {
fileprivate var intValue: Int {
return NSNumber(value: self).intValue
}
}

// MARK: - NSColor Extensio
// nmacOS 10.14 polyfill
private extension NSColor {
static let controlAccentPolyfill: NSColor = {
extension NSColor {
fileprivate static let controlAccentPolyfill: NSColor = {
if #available(macOS 10.14, *) {
return NSColor.controlAccentColor
} else {
Expand Down

0 comments on commit 6a4e97e

Please sign in to comment.