From 2321c7916f012c1e8ab706d565510b089ae43ed4 Mon Sep 17 00:00:00 2001 From: kyleduo Date: Wed, 28 Mar 2018 15:47:25 +0800 Subject: [PATCH] update to swift4 --- source/Podfile | 2 + source/Podfile.lock | 4 +- source/tinypng4mac.xcodeproj/project.pbxproj | 38 ++++++++++++++--- source/tinypng4mac/AppDelegate.swift | 2 +- source/tinypng4mac/Base.lproj/Main.storyboard | 41 ++++++++++--------- source/tinypng4mac/MainViewController.swift | 22 +++++----- source/tinypng4mac/MainWindowController.swift | 2 +- .../extensions/PasteboardTypeExtension.swift | 19 +++++++++ source/tinypng4mac/views/DragContainer.swift | 20 +++++---- source/tinypng4mac/views/InputKeyAlert.swift | 16 ++++---- source/tinypng4mac/views/TPWindow.swift | 13 ++++++ 11 files changed, 122 insertions(+), 57 deletions(-) create mode 100644 source/tinypng4mac/extensions/PasteboardTypeExtension.swift create mode 100644 source/tinypng4mac/views/TPWindow.swift diff --git a/source/Podfile b/source/Podfile index 09aa501..1881231 100644 --- a/source/Podfile +++ b/source/Podfile @@ -1,7 +1,9 @@ # Uncomment this line to define a global platform for your project # platform :ios, '8.0' # Uncomment this line if you're using Swift +platform :osx, '10.11' use_frameworks! +inhibit_all_warnings! target 'TinyPNG4Mac' do diff --git a/source/Podfile.lock b/source/Podfile.lock index 0911b65..8c6124e 100644 --- a/source/Podfile.lock +++ b/source/Podfile.lock @@ -10,6 +10,6 @@ SPEC CHECKSUMS: Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d SwiftyJSON: c2842d878f95482ffceec5709abc3d05680c0220 -PODFILE CHECKSUM: c9af21cda856e6764e07e379db8e1727351883dd +PODFILE CHECKSUM: 52e07e7158f2fa7bd16153c6015742d83879ff4e -COCOAPODS: 1.1.1 +COCOAPODS: 1.4.0 diff --git a/source/tinypng4mac.xcodeproj/project.pbxproj b/source/tinypng4mac.xcodeproj/project.pbxproj index 5092e34..7a0029c 100644 --- a/source/tinypng4mac.xcodeproj/project.pbxproj +++ b/source/tinypng4mac.xcodeproj/project.pbxproj @@ -27,6 +27,8 @@ 277AAF781D269D7C00788F37 /* IOHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 277AAF771D269D7C00788F37 /* IOHelper.swift */; }; 27A949C81D2C00120043DECE /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27A949C71D2C00120043DECE /* MainWindowController.swift */; }; 27C12A171D35411800F0FD81 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 27C12A151D35411800F0FD81 /* Localizable.strings */; }; + 27F5BA4B206B7021008529C9 /* TPWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F5BA4A206B7021008529C9 /* TPWindow.swift */; }; + 27F5BA4E206B7373008529C9 /* PasteboardTypeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27F5BA4D206B7373008529C9 /* PasteboardTypeExtension.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -53,6 +55,8 @@ 27A949CC1D2C07290043DECE /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 27C12A191D35414500F0FD81 /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = ""; }; 27C12A1A1D3541DA00F0FD81 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; + 27F5BA4A206B7021008529C9 /* TPWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TPWindow.swift; sourceTree = ""; }; + 27F5BA4D206B7373008529C9 /* PasteboardTypeExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardTypeExtension.swift; sourceTree = ""; }; 3EC4E906FA6863DD0D5839DA /* Pods-TinyPNG4Mac.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TinyPNG4Mac.release.xcconfig"; path = "Pods/Target Support Files/Pods-TinyPNG4Mac/Pods-TinyPNG4Mac.release.xcconfig"; sourceTree = ""; }; 811CF203124A83759CC63BFF /* Pods_TinyPNG4Mac.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_TinyPNG4Mac.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B8A32DFEB3E5214A1AADE38D /* Pods-TinyPNG4Mac.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TinyPNG4Mac.debug.xcconfig"; path = "Pods/Target Support Files/Pods-TinyPNG4Mac/Pods-TinyPNG4Mac.debug.xcconfig"; sourceTree = ""; }; @@ -91,6 +95,7 @@ 277AAF511D23F24900788F37 /* tinypng4mac */ = { isa = PBXGroup; children = ( + 27F5BA4C206B735B008529C9 /* extensions */, 277AAF721D267CEC00788F37 /* utils */, 277AAF6D1D2646CE00788F37 /* views */, 277AAF681D254D2E00788F37 /* model */, @@ -133,6 +138,7 @@ 272C509F1D2D545300EEECC2 /* SpinnerProgressIndicator.swift */, 272C50AC1D2EB03100EEECC2 /* InputKeyAlert.swift */, 272AC1AE1ED335470005E7D5 /* GradientView.swift */, + 27F5BA4A206B7021008529C9 /* TPWindow.swift */, ); path = views; sourceTree = ""; @@ -147,6 +153,14 @@ path = utils; sourceTree = ""; }; + 27F5BA4C206B735B008529C9 /* extensions */ = { + isa = PBXGroup; + children = ( + 27F5BA4D206B7373008529C9 /* PasteboardTypeExtension.swift */, + ); + path = extensions; + sourceTree = ""; + }; 598597DBDE3F9EA48148E86C /* Pods */ = { isa = PBXGroup; children = ( @@ -199,7 +213,7 @@ TargetAttributes = { 277AAF4E1D23F24900788F37 = { CreatedOnToolsVersion = 7.3; - LastSwiftMigration = 0800; + LastSwiftMigration = 0920; }; }; }; @@ -243,13 +257,16 @@ files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-TinyPNG4Mac-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../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"; + 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; }; 5B420B6B1C8EFF2B07BE8D63 /* [CP] Embed Pods Frameworks */ = { @@ -258,9 +275,14 @@ files = ( ); inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-TinyPNG4Mac/Pods-TinyPNG4Mac-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework", + "${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Alamofire.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -294,10 +316,12 @@ 272AC1AF1ED335470005E7D5 /* GradientView.swift in Sources */, 277AAF711D26478A00788F37 /* TaskTableCell.swift in Sources */, 27A949C81D2C00120043DECE /* MainWindowController.swift in Sources */, + 27F5BA4B206B7021008529C9 /* TPWindow.swift in Sources */, 277AAF641D25201900788F37 /* TPClient.swift in Sources */, 277AAF531D23F24900788F37 /* AppDelegate.swift in Sources */, 277AAF741D267CF700788F37 /* Formator.swift in Sources */, 272AC1AD1ED2BA5C0005E7D5 /* MainViewController.swift in Sources */, + 27F5BA4E206B7373008529C9 /* PasteboardTypeExtension.swift in Sources */, 277AAF671D254C0700788F37 /* TPQueue.swift in Sources */, 277AAF6A1D254D4F00788F37 /* TPTaskInfo.swift in Sources */, 277AAF6C1D25517E00788F37 /* TPStore.swift in Sources */, @@ -424,14 +448,15 @@ isa = XCBuildConfiguration; baseConfigurationReference = B8A32DFEB3E5214A1AADE38D /* Pods-TinyPNG4Mac.debug.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = tinypng4mac/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.kyleduo.tinypngmac; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -439,14 +464,15 @@ isa = XCBuildConfiguration; baseConfigurationReference = 3EC4E906FA6863DD0D5839DA /* Pods-TinyPNG4Mac.release.xcconfig */; buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; INFOPLIST_FILE = tinypng4mac/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.kyleduo.tinypngmac; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/source/tinypng4mac/AppDelegate.swift b/source/tinypng4mac/AppDelegate.swift index b5332e4..dfb90be 100644 --- a/source/tinypng4mac/AppDelegate.swift +++ b/source/tinypng4mac/AppDelegate.swift @@ -27,7 +27,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @IBAction func viewInGithub(_ sender: AnyObject) { - NSWorkspace.shared().open(URL.init(string: "https://github.com/kyleduo/TinyPNG4Mac")!) + NSWorkspace.shared.open(URL.init(string: "https://github.com/kyleduo/TinyPNG4Mac")!) } @IBAction func clearConfiguration(_ sender: AnyObject) { TPConfig.removeKey() diff --git a/source/tinypng4mac/Base.lproj/Main.storyboard b/source/tinypng4mac/Base.lproj/Main.storyboard index 6656d2d..757b498 100644 --- a/source/tinypng4mac/Base.lproj/Main.storyboard +++ b/source/tinypng4mac/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -138,12 +138,15 @@ - + + + + @@ -164,7 +167,7 @@ - + @@ -172,7 +175,7 @@ - + @@ -180,7 +183,7 @@ - + @@ -188,8 +191,8 @@ - - + + @@ -197,10 +200,9 @@ - + @@ -219,9 +221,8 @@