Skip to content

Commit

Permalink
Update swift4.1 and Xcode9.3 (Clipy#239)
Browse files Browse the repository at this point in the history
* Update gems

* Update Xcode9 recommend setting

* Update README.md

* Update dependency libraries

* Update Pods.xcodeproj swift4 setting

* Update swift4

* Wrap swift 3 style NSPasteboard.PasteboardType

* Remove deprecated characters

* Fix Xcode deprecate warning

* Update dependency gems

* Xcode9.3 and swift4.1 compatibility

* Update dependency libraries

* [skip ci] Update README.md
  • Loading branch information
Econa77 authored Apr 12, 2018
1 parent 2c55a9f commit a7f9276
Show file tree
Hide file tree
Showing 612 changed files with 24,756 additions and 14,167 deletions.
3 changes: 3 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ included:
excluded:
- Pods
line_length: 200
identifier_name:
excluded:
- i
70 changes: 31 additions & 39 deletions Clipy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/* Begin PBXBuildFile section */
242EC2327861D35B7C3AE84E /* Pods_ClipyTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00A4B450122D7FCE6BD57E77 /* Pods_ClipyTests.framework */; };
B7CC520B88EAA6AD38E93462 /* Pods_Clipy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 73A92F6DEE6CFF50A567CFEF /* Pods_Clipy.framework */; };
C5F1B7331FF74A2D00D2DA83 /* NSPasteboard+Deprecated.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5F1B7321FF74A2D00D2DA83 /* NSPasteboard+Deprecated.swift */; };
CAFD12B01F207DBC00DF1CEB /* Observable+Void.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAFD12AF1F207DBC00DF1CEB /* Observable+Void.swift */; };
FA08EDF81D1FED7D000D1D13 /* HotKeyServiceSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA08EDF71D1FED7D000D1D13 /* HotKeyServiceSpec.swift */; };
FA0D5CE81DDCC61600AC9052 /* ClipService.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA0D5CE71DDCC61600AC9052 /* ClipService.swift */; };
Expand Down Expand Up @@ -146,6 +147,7 @@
8460049F1FD5511A00BA733E /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
994536AAB91CE22186C3CFB1 /* Pods-ClipyTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ClipyTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ClipyTests/Pods-ClipyTests.debug.xcconfig"; sourceTree = "<group>"; };
9DBBF976436A0651CB8BD4B2 /* Pods-Clipy.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Clipy.release.xcconfig"; path = "Pods/Target Support Files/Pods-Clipy/Pods-Clipy.release.xcconfig"; sourceTree = "<group>"; };
C5F1B7321FF74A2D00D2DA83 /* NSPasteboard+Deprecated.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSPasteboard+Deprecated.swift"; sourceTree = "<group>"; };
CAFD12AF1F207DBC00DF1CEB /* Observable+Void.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+Void.swift"; sourceTree = "<group>"; };
FA08EDF71D1FED7D000D1D13 /* HotKeyServiceSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HotKeyServiceSpec.swift; sourceTree = "<group>"; };
FA0D5CE71DDCC61600AC9052 /* ClipService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClipService.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -369,6 +371,7 @@
FA1DB4B11DDCB452007F95C8 /* Realm+NoCatch.swift */,
FA1DB4B21DDCB452007F95C8 /* String+Substring.swift */,
FA431F011E6718CE00ACFF56 /* Collection+Safe.swift */,
C5F1B7321FF74A2D00D2DA83 /* NSPasteboard+Deprecated.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -560,7 +563,6 @@
FA4A5CDC1C7CAEDD0031BCEF /* Fabric */,
FAAD02201CA98E20007C6EEE /* SwiftLint */,
07B47785AE0AC2185B570C28 /* [CP] Embed Pods Frameworks */,
40BF6BFF1639341024558E7B /* [CP] Copy Pods Resources */,
FAAA88991E686CED0088FB34 /* BartyCrouch */,
);
buildRules = (
Expand All @@ -581,7 +583,6 @@
FAC43DD51B35D8B100C06102 /* Frameworks */,
FAC43DD61B35D8B100C06102 /* Resources */,
321A1AC02A519AFA3A4D43D2 /* [CP] Embed Pods Frameworks */,
80698BEE3B106BF31712F217 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand All @@ -601,17 +602,17 @@
attributes = {
CLASSPREFIX = CPY;
LastSwiftUpdateCheck = 0700;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 0930;
ORGANIZATIONNAME = "Shunsuke Furubayashi";
TargetAttributes = {
FAC43DC51B35D8B100C06102 = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = BBCHAJ584H;
LastSwiftMigration = 0810;
LastSwiftMigration = 0910;
};
FAC43DD71B35D8B100C06102 = {
CreatedOnToolsVersion = 6.3.2;
LastSwiftMigration = 0810;
LastSwiftMigration = 0910;
TestTargetID = FAC43DC51B35D8B100C06102;
};
};
Expand Down Expand Up @@ -736,21 +737,6 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ClipyTests/Pods-ClipyTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
40BF6BFF1639341024558E7B /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Clipy/Pods-Clipy-resources.sh\"\n";
showEnvVarsInLog = 0;
};
7BFBD366B210014B03083E71 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand All @@ -769,21 +755,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
80698BEE3B106BF31712F217 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ClipyTests/Pods-ClipyTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
8E8162F076D1C3115EAAB644 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -861,6 +832,7 @@
FA1DB4BA1DDCB452007F95C8 /* NSUserDefaults+ArchiveData.swift in Sources */,
FA1DB4D31DDCB479007F95C8 /* CPYClip.swift in Sources */,
FAC0DCE91DE15FD900309C49 /* DataCleanService.swift in Sources */,
C5F1B7331FF74A2D00D2DA83 /* NSPasteboard+Deprecated.swift in Sources */,
FA1DB4E61DDCB49C007F95C8 /* LocalizedString.swift in Sources */,
FA1DB4A31DDCB433007F95C8 /* Constants.swift in Sources */,
FA1DB4D61DDCB479007F95C8 /* CPYFolder.swift in Sources */,
Expand Down Expand Up @@ -1055,14 +1027,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -1103,14 +1083,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -1155,7 +1143,8 @@
PROVISIONING_PROFILE = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -1181,7 +1170,8 @@
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -1204,7 +1194,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.clipyapp.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Clipy.app/Contents/MacOS/Clipy";
};
name = Debug;
Expand All @@ -1224,7 +1215,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.clipyapp.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Clipy.app/Contents/MacOS/Clipy";
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Clipy.xcodeproj/xcshareddata/xcschemes/Clipy.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "0930"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 8 additions & 0 deletions Clipy.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
32 changes: 18 additions & 14 deletions Clipy/Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,21 @@ class AppDelegate: NSObject {
}

// MARK: - Menu Actions
func showPreferenceWindow() {
@objc func showPreferenceWindow() {
NSApp.activate(ignoringOtherApps: true)
CPYPreferencesWindowController.sharedController.showWindow(self)
}

func showSnippetEditorWindow() {
@objc func showSnippetEditorWindow() {
NSApp.activate(ignoringOtherApps: true)
CPYSnippetsEditorWindowController.sharedController.showWindow(self)
}

func clearAllHistory() {
@objc func terminate() {
terminateApplication()
}

@objc func clearAllHistory() {
let isShowAlert = AppEnvironment.current.defaults.bool(forKey: Constants.UserDefaults.showAlertBeforeClearHistory)
if isShowAlert {
let alert = NSAlert()
Expand All @@ -71,9 +75,9 @@ class AppDelegate: NSObject {
NSApp.activate(ignoringOtherApps: true)

let result = alert.runModal()
if result != NSAlertFirstButtonReturn { return }
if result != NSApplication.ModalResponse.alertFirstButtonReturn { return }

if alert.suppressionButton?.state == NSOnState {
if alert.suppressionButton?.state == NSControl.StateValue.on {
AppEnvironment.current.defaults.set(false, forKey: Constants.UserDefaults.showAlertBeforeClearHistory)
}
AppEnvironment.current.defaults.synchronize()
Expand All @@ -82,42 +86,42 @@ class AppDelegate: NSObject {
AppEnvironment.current.clipService.clearAll()
}

func selectClipMenuItem(_ sender: NSMenuItem) {
@objc func selectClipMenuItem(_ sender: NSMenuItem) {
CPYUtilities.sendCustomLog(with: "selectClipMenuItem")
guard let primaryKey = sender.representedObject as? String else {
CPYUtilities.sendCustomLog(with: "Cannot fetch clip primary key")
NSBeep()
NSSound.beep()
return
}
let realm = try! Realm()
guard let clip = realm.object(ofType: CPYClip.self, forPrimaryKey: primaryKey) else {
CPYUtilities.sendCustomLog(with: "Cannot fetch clip data")
NSBeep()
NSSound.beep()
return
}

AppEnvironment.current.pasteService.paste(with: clip)
}

func selectSnippetMenuItem(_ sender: AnyObject) {
@objc func selectSnippetMenuItem(_ sender: AnyObject) {
CPYUtilities.sendCustomLog(with: "selectSnippetMenuItem")
guard let primaryKey = sender.representedObject as? String else {
CPYUtilities.sendCustomLog(with: "Cannot fetch snippet primary key")
NSBeep()
NSSound.beep()
return
}
let realm = try! Realm()
guard let snippet = realm.object(ofType: CPYSnippet.self, forPrimaryKey: primaryKey) else {
CPYUtilities.sendCustomLog(with: "Cannot fetch snippet data")
NSBeep()
NSSound.beep()
return
}
AppEnvironment.current.pasteService.copyToPasteboard(with: snippet.content)
AppEnvironment.current.pasteService.paste()
}

func terminateApplication() {
NSApplication.shared().terminate(nil)
NSApplication.shared.terminate(nil)
}

// MARK: - Login Item Methods
Expand All @@ -131,12 +135,12 @@ class AppDelegate: NSObject {
NSApp.activate(ignoringOtherApps: true)

// Launch on system startup
if alert.runModal() == NSAlertFirstButtonReturn {
if alert.runModal() == NSApplication.ModalResponse.alertFirstButtonReturn {
AppEnvironment.current.defaults.set(true, forKey: Constants.UserDefaults.loginItem)
toggleLoginItemState()
}
// Do not show this message again
if alert.suppressionButton?.state == NSOnState {
if alert.suppressionButton?.state == NSControl.StateValue.on {
AppEnvironment.current.defaults.set(true, forKey: Constants.UserDefaults.suppressAlertForLoginItem)
}
AppEnvironment.current.defaults.synchronize()
Expand Down
2 changes: 1 addition & 1 deletion Clipy/Sources/Extensions/Collection+Safe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

extension Collection {
subscript(safe index: Index) -> _Element? {
subscript(safe index: Index) -> Element? {
return index >= startIndex && index < endIndex ? self[index] : nil
}
}
2 changes: 1 addition & 1 deletion Clipy/Sources/Extensions/NSColor+Clipy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ extension NSColor {
}

static func tabTitleColor() -> NSColor {
return NSColor(white:0.6, alpha: 1)
return NSColor(white: 0.6, alpha: 1)
}
}
6 changes: 3 additions & 3 deletions Clipy/Sources/Extensions/NSColor+Hex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ extension NSColor {

public convenience init?(hex rgba: String) {
let hexString: String
let hexCount = rgba.characters.count
let hexCount = rgba.count
if rgba.hasPrefix("#") {
hexString = rgba.substring(from: rgba.characters.index(rgba.startIndex, offsetBy: 1))
hexString = String(rgba[String.Index.init(encodedOffset: 1)...])
} else if hexCount == 3 || hexCount == 6 {
hexString = rgba
} else {
Expand All @@ -63,7 +63,7 @@ extension NSColor {
/**
* Images with alpha cannot be previewed and not be created
*/
switch hexString.characters.count {
switch hexString.count {
case 3:
self.init(hex3: UInt16(hexValue))
case 6:
Expand Down
2 changes: 1 addition & 1 deletion Clipy/Sources/Extensions/NSImage+AssetCatalog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension NSImage {

// MARK: - Initialize
convenience init(assetIdentifier: AssetIdentifier) {
self.init(named: assetIdentifier.rawValue)!
self.init(named: NSImage.Name(rawValue: assetIdentifier.rawValue))!
}

}
Loading

0 comments on commit a7f9276

Please sign in to comment.