From c61d4371e39e243721d098ab55dd4c7d82df4d2f Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Tue, 6 Nov 2018 12:53:42 -0600 Subject: [PATCH 01/17] Switch to using Grand Central Dispatch instead of Timer for a small performance gain --- PlainPasta/PasteboardMonitor.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index aa56708..f1b04d4 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -14,12 +14,16 @@ class PasteboardMonitor { private let pasteboard = NSPasteboard.general private var internalChangeCount = NSPasteboard.general.changeCount private var previousPasteboard: String? - private var timer: Timer? + private var timer = DispatchSource.makeTimerSource() init() { startTimer() } + deinit { + stopTimer() + } + /// The current state of the pasteboard monitor var enabledState: Bool = true { didSet { enabledState ? startTimer() : stopTimer() } @@ -28,15 +32,18 @@ class PasteboardMonitor { /// Starts monitoring the pasteboard, and sets the menu item's state to enabled private func startTimer() { delegate?.enabledMenuItem.state = .on - timer = Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { _ in - self.checkPasteboard() + + timer.schedule(deadline: .now(), repeating: .milliseconds(100)) + timer.setEventHandler { [weak self] in + self?.checkPasteboard() } + timer.resume() } /// Stops monitoring the pasteboard, and sets the menu item's state to disabled private func stopTimer() { delegate?.enabledMenuItem.state = .off - timer?.invalidate() + timer.cancel() } /// Checks the pasteboard for textual contents, and strips the formatting if possible From 7b99dd840bfecff30d896886c2b5514f51e0d482 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Tue, 6 Nov 2018 12:55:17 -0600 Subject: [PATCH 02/17] Refactor timer starting code slightly --- PlainPasta/PasteboardMonitor.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index f1b04d4..0d1af8c 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -17,6 +17,11 @@ class PasteboardMonitor { private var timer = DispatchSource.makeTimerSource() init() { + timer.schedule(deadline: .now(), repeating: .milliseconds(100)) + timer.setEventHandler { [weak self] in + self?.checkPasteboard() + } + startTimer() } @@ -32,11 +37,6 @@ class PasteboardMonitor { /// Starts monitoring the pasteboard, and sets the menu item's state to enabled private func startTimer() { delegate?.enabledMenuItem.state = .on - - timer.schedule(deadline: .now(), repeating: .milliseconds(100)) - timer.setEventHandler { [weak self] in - self?.checkPasteboard() - } timer.resume() } From 96eddd6138959b480d394d5bd6075a7cc541e824 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Tue, 6 Nov 2018 13:00:56 -0600 Subject: [PATCH 03/17] Make timer a let constant --- PlainPasta/PasteboardMonitor.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index 0d1af8c..8647629 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -14,7 +14,7 @@ class PasteboardMonitor { private let pasteboard = NSPasteboard.general private var internalChangeCount = NSPasteboard.general.changeCount private var previousPasteboard: String? - private var timer = DispatchSource.makeTimerSource() + private let timer = DispatchSource.makeTimerSource() init() { timer.schedule(deadline: .now(), repeating: .milliseconds(100)) From efc34623af1aec77df9e2b230eaf4b2ac2b597ce Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Tue, 6 Nov 2018 13:03:12 -0600 Subject: [PATCH 04/17] Update changelog --- changelog.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 0dd019f..25afeb0 100644 --- a/changelog.md +++ b/changelog.md @@ -4,8 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Move to using GCD instead of `Timer` for repeat polling of the pasteboard. This provides a small increase in performance. + ## [1.0.0] - 2018-11-04 -Initial release! +Initial release! 🎉 +[Unreleased]: https://github.com/hisaac/PlainPasta/compare/master...development [1.0.0]: https://github.com/hisaac/PlainPasta/compare/3f3479bf1b417790735aa6cfb8850eb73fe74a07...1.0.0 From 9d476b14081f761e2bcaf12c458f2803357b6993 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 13:22:29 -0500 Subject: [PATCH 05/17] Update to Swift 5 --- PlainPasta.xcodeproj/project.pbxproj | 10 ++++++---- PlainPasta/{en.lproj => Base.lproj}/Main.storyboard | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) rename PlainPasta/{en.lproj => Base.lproj}/Main.storyboard (99%) diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index 45d8c1a..1cd99dd 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -23,7 +23,6 @@ 4A4E59302176AE7A002CF83D /* PlainPasta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PlainPasta.entitlements; sourceTree = ""; }; 4A5E9178217917A5001C378F /* swiftgen.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = swiftgen.yml; sourceTree = ""; }; 4A5E917B2179183E001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; - 4A5E917E2179186D001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Main.storyboard; sourceTree = ""; }; 4A5E917F217918A5001C378F /* Localizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localizable.swift; sourceTree = ""; }; 4A8A68162176C5F500A4F1D8 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 4A8A68172176C5F500A4F1D8 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; @@ -31,6 +30,7 @@ 4A8A68192176C5F500A4F1D8 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 4A8A681A2176C5F500A4F1D8 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardMonitor.swift; sourceTree = ""; }; + F2E4F2EC22AED734006313B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -124,6 +124,7 @@ TargetAttributes = { 4A4E59222176AE7A002CF83D = { CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1020; SystemCapabilities = { com.apple.Sandbox = { enabled = 0; @@ -138,6 +139,7 @@ hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = 4A4E591A2176AE7A002CF83D; productRefGroup = 4A4E59242176AE7A002CF83D /* Products */; @@ -218,7 +220,7 @@ 4A4E592C2176AE7A002CF83D /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - 4A5E917E2179186D001C378F /* en */, + F2E4F2EC22AED734006313B9 /* Base */, ); name = Main.storyboard; sourceTree = ""; @@ -366,7 +368,7 @@ PRODUCT_BUNDLE_IDENTIFIER = software.level.PlainPasta; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -387,7 +389,7 @@ PRODUCT_BUNDLE_IDENTIFIER = software.level.PlainPasta; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/PlainPasta/en.lproj/Main.storyboard b/PlainPasta/Base.lproj/Main.storyboard similarity index 99% rename from PlainPasta/en.lproj/Main.storyboard rename to PlainPasta/Base.lproj/Main.storyboard index 7a1a69d..528dbe3 100644 --- a/PlainPasta/en.lproj/Main.storyboard +++ b/PlainPasta/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -618,7 +618,7 @@ - + From 6425834dd089a25d22b8277efb1c74af473bd7d9 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 13:26:55 -0500 Subject: [PATCH 06/17] Remove SwiftGen --- .swiftlint.yml | 30 +------------------ PlainPasta.xcodeproj/project.pbxproj | 25 ---------------- PlainPasta/AppDelegate.swift | 19 +++++------- PlainPasta/Info.plist | 4 +-- PlainPasta/Localizable.swift | 39 ------------------------- PlainPasta/en.lproj/Localizable.strings | 5 ++-- swiftgen.yml | 7 ----- 7 files changed, 13 insertions(+), 116 deletions(-) delete mode 100644 PlainPasta/Localizable.swift delete mode 100644 swiftgen.yml diff --git a/.swiftlint.yml b/.swiftlint.yml index 9a64079..1a2de91 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -18,7 +18,7 @@ disabled_rules: - function_parameter_count - identifier_name - redundant_string_enum_value -- superfluous_disable_comman +- superfluous_disable_command - unused_closure_parameter excluded: @@ -31,31 +31,3 @@ line_length: file_length: ignore_comment_only_lines: true - -# via: https://github.com/SwiftGen/SwiftGen/blob/master/Documentation/Articles/SwiftLint-Integration.md -custom_rules: - swiftgen_assets: - name: "SwiftGen Assets" - regex: '(UIImage|UIColor)(\.init)?\(named: ?"?.+"?(, ?in:.+?, ?compatibleWith:.+?)?\)|#imageLiteral\(resourceName: ?".+"\)' - message: "Use Asset. instead" - severity: error - swiftgen_colors: - name: "SwiftGen Colors" - regex: '(UIColor(\.init)?|#colorLiteral)\(((red|displayP3Red):.+?,green:.+?,blue:.+?,alpha:.+?)|(white:.+?,alpha:.+?)|(hue:.+?,saturation:.+?,brightness:.+?,alpha:.+?)\)' - message: "Use ColorName. instead" - severity: error - swiftgen_fonts: - name: "SwiftGen Fonts" - regex: 'UIFont(\.init)?\(name: ?"?.+"?, ?size:.+?\)' - message: "Use FontFamily...size() instead" - severity: error - swiftgen_storyboards: - name: "SwiftGen Storyboard Scenes" - regex: '(UIStoryboard\(name: ?"?.+"?, ?bundle:.+\))|(instantiateViewController\(withIdentifier:.+?\))|(instantiateInitialViewController\(\))' - message: "Use StoryboardScene...instantiate() instead" - severity: error - swiftgen_strings: - name: "SwiftGen Strings" - regex: 'NSLocalizedString' - message: "Use L10n.key instead" - severity: error diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index 1cd99dd..8612d98 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -11,7 +11,6 @@ 4A4E592B2176AE7A002CF83D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4E592A2176AE7A002CF83D /* Assets.xcassets */; }; 4A4E592E2176AE7A002CF83D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4E592C2176AE7A002CF83D /* Main.storyboard */; }; 4A5E917A2179183E001C378F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E917C2179183E001C378F /* Localizable.strings */; }; - 4A5E9180217918A5001C378F /* Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5E917F217918A5001C378F /* Localizable.swift */; }; 4AA984F42178DF6500B64A3F /* PasteboardMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */; }; /* End PBXBuildFile section */ @@ -21,9 +20,7 @@ 4A4E592A2176AE7A002CF83D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4A4E592F2176AE7A002CF83D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 4A4E59302176AE7A002CF83D /* PlainPasta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PlainPasta.entitlements; sourceTree = ""; }; - 4A5E9178217917A5001C378F /* swiftgen.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = swiftgen.yml; sourceTree = ""; }; 4A5E917B2179183E001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; - 4A5E917F217918A5001C378F /* Localizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localizable.swift; sourceTree = ""; }; 4A8A68162176C5F500A4F1D8 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 4A8A68172176C5F500A4F1D8 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; 4A8A68182176C5F500A4F1D8 /* changelog.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = changelog.md; sourceTree = ""; }; @@ -58,7 +55,6 @@ 4A8A68182176C5F500A4F1D8 /* changelog.md */, 4A4E59252176AE7A002CF83D /* PlainPasta */, 4A8A68192176C5F500A4F1D8 /* LICENSE */, - 4A5E9178217917A5001C378F /* swiftgen.yml */, 4A8A68172176C5F500A4F1D8 /* .swiftlint.yml */, 4A8A68162176C5F500A4F1D8 /* .gitignore */, 4A4E59242176AE7A002CF83D /* Products */, @@ -80,7 +76,6 @@ children = ( 4A4E59262176AE7A002CF83D /* AppDelegate.swift */, 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */, - 4A5E917F217918A5001C378F /* Localizable.swift */, 4A4E592A2176AE7A002CF83D /* Assets.xcassets */, 4A4E592C2176AE7A002CF83D /* Main.storyboard */, 4A4E592F2176AE7A002CF83D /* Info.plist */, @@ -97,7 +92,6 @@ isa = PBXNativeTarget; buildConfigurationList = 4A4E59332176AE7A002CF83D /* Build configuration list for PBXNativeTarget "Plain Pasta" */; buildPhases = ( - 4A5E917621791728001C378F /* [Swiftgen] */, 4A5E917721791748001C378F /* [Swiftlint] */, 4A4E591F2176AE7A002CF83D /* Sources */, 4A4E59202176AE7A002CF83D /* Frameworks */, @@ -165,24 +159,6 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 4A5E917621791728001C378F /* [Swiftgen] */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - ); - name = "[Swiftgen]"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "if which swiftgen >/dev/null; then\n swiftgen\nelse\n echo \"warning: SwiftGen not installed, download it from https://github.com/SwiftGen/SwiftGen\"\nfi\n"; - }; 4A5E917721791748001C378F /* [Swiftlint] */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -209,7 +185,6 @@ buildActionMask = 2147483647; files = ( 4A4E59272176AE7A002CF83D /* AppDelegate.swift in Sources */, - 4A5E9180217918A5001C378F /* Localizable.swift in Sources */, 4AA984F42178DF6500B64A3F /* PasteboardMonitor.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/PlainPasta/AppDelegate.swift b/PlainPasta/AppDelegate.swift index eb72dad..4a83dc3 100644 --- a/PlainPasta/AppDelegate.swift +++ b/PlainPasta/AppDelegate.swift @@ -12,7 +12,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { let menuBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength) let enabledMenuItem = NSMenuItem( - title: L10n.enabled, + title: NSLocalizedString("Enabled", comment: "Title for Enabled menu item"), action: #selector(toggleTimer), keyEquivalent: "" ) @@ -36,27 +36,20 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { keyEquivalent: "" ) - let checkForUpdates = NSMenuItem( - title: L10n.checkForUpdates, - action: #selector(checkForAppUpdates), - keyEquivalent: "" - ) - let aboutPlainPasta = NSMenuItem( - title: L10n.aboutPlainPasta, + title: NSLocalizedString("About Plain Pasta…", comment: "Title for About menu item"), action: #selector(openAboutPage), keyEquivalent: "" ) let quit = NSMenuItem( - title: L10n.quit, + title: NSLocalizedString("Quit", comment: "Title for Quit menu item"), action: #selector(NSApplication.terminate), keyEquivalent: "q" ) let orderedMenuItems = [ versionInfo, - checkForUpdates, NSMenuItem.separator(), enabledMenuItem, NSMenuItem.separator(), @@ -92,9 +85,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { } var appVersionTitle: String { + let versionTitle = NSLocalizedString("Version", comment: "Version title for version information") let versionNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "" + + let buildTitle = NSLocalizedString("build", comment: "build title for version information") let buildNumber = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "" - return "\(L10n.version) \(versionNumber) (\(L10n.build) \(buildNumber))" + + return "\(versionTitle) \(versionNumber) (\(buildTitle) \(buildNumber))" } } diff --git a/PlainPasta/Info.plist b/PlainPasta/Info.plist index c89b046..372dba7 100644 --- a/PlainPasta/Info.plist +++ b/PlainPasta/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.1.0 CFBundleVersion - 10 + 1 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/PlainPasta/Localizable.swift b/PlainPasta/Localizable.swift deleted file mode 100644 index 98d3536..0000000 --- a/PlainPasta/Localizable.swift +++ /dev/null @@ -1,39 +0,0 @@ -// swiftlint:disable all -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen - -import Foundation - -// swiftlint:disable superfluous_disable_command -// swiftlint:disable file_length - -// MARK: - Strings - -// swiftlint:disable function_parameter_count identifier_name line_length type_body_length -internal enum L10n { - /// About Plain Pasta… - internal static let aboutPlainPasta = L10n.tr("Localizable", "About Plain Pasta…") - /// build - internal static let build = L10n.tr("Localizable", "build") - /// Check for Updates… - internal static let checkForUpdates = L10n.tr("Localizable", "Check for Updates…") - /// Enabled - internal static let enabled = L10n.tr("Localizable", "Enabled") - /// Plain Pasta - internal static let plainPasta = L10n.tr("Localizable", "Plain Pasta") - /// Quit - internal static let quit = L10n.tr("Localizable", "Quit") - /// Version - internal static let version = L10n.tr("Localizable", "Version") -} -// swiftlint:enable function_parameter_count identifier_name line_length type_body_length - -// MARK: - Implementation Details - -extension L10n { - private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { - let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") - return String(format: format, locale: Locale.current, arguments: args) - } -} - -private final class BundleToken {} diff --git a/PlainPasta/en.lproj/Localizable.strings b/PlainPasta/en.lproj/Localizable.strings index 395a409..eeb5c32 100644 --- a/PlainPasta/en.lproj/Localizable.strings +++ b/PlainPasta/en.lproj/Localizable.strings @@ -7,11 +7,10 @@ // Menu Items "Enabled" = "Enabled"; // Title for Enabled menu item -"Check for Updates…" = "Check for Updates…"; // Title for Check for Updates menu item "About Plain Pasta…" = "About Plain Pasta…"; // Title for About menu item "Quit" = "Quit"; // Title for Quit menu item // Version Number -"Version" = "Version"; // Version word for version information -"build" = "build"; // build word for version information +"Version" = "Version"; // Version title for version information +"build" = "build"; // build title for version information diff --git a/swiftgen.yml b/swiftgen.yml deleted file mode 100644 index 5706c8b..0000000 --- a/swiftgen.yml +++ /dev/null @@ -1,7 +0,0 @@ -input_dir: ./PlainPasta/ -output_dir: ./PlainPasta/ -strings: - inputs: en.lproj/Localizable.strings - outputs: - - templateName: flat-swift4 - output: Localizable.swift From b3f5c3c4b3b1c7906f131db731bbb5243072728f Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 13:57:20 -0500 Subject: [PATCH 07/17] Update entitlements file to prompt App ID creation --- PlainPasta.xcodeproj/project.pbxproj | 7 +++++-- .../{PlainPasta.entitlements => Plain Pasta.entitlements} | 0 2 files changed, 5 insertions(+), 2 deletions(-) rename PlainPasta/{PlainPasta.entitlements => Plain Pasta.entitlements} (100%) diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index 45d8c1a..ab29b7d 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -20,7 +20,6 @@ 4A4E59262176AE7A002CF83D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4A4E592A2176AE7A002CF83D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4A4E592F2176AE7A002CF83D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4A4E59302176AE7A002CF83D /* PlainPasta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PlainPasta.entitlements; sourceTree = ""; }; 4A5E9178217917A5001C378F /* swiftgen.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = swiftgen.yml; sourceTree = ""; }; 4A5E917B2179183E001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 4A5E917E2179186D001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Main.storyboard; sourceTree = ""; }; @@ -31,6 +30,7 @@ 4A8A68192176C5F500A4F1D8 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 4A8A681A2176C5F500A4F1D8 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardMonitor.swift; sourceTree = ""; }; + F2E4F2ED22AED9E0006313B9 /* Plain Pasta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Plain Pasta.entitlements"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -84,7 +84,7 @@ 4A4E592A2176AE7A002CF83D /* Assets.xcassets */, 4A4E592C2176AE7A002CF83D /* Main.storyboard */, 4A4E592F2176AE7A002CF83D /* Info.plist */, - 4A4E59302176AE7A002CF83D /* PlainPasta.entitlements */, + F2E4F2ED22AED9E0006313B9 /* Plain Pasta.entitlements */, 4A5E917C2179183E001C378F /* Localizable.strings */, ); path = PlainPasta; @@ -125,6 +125,9 @@ 4A4E59222176AE7A002CF83D = { CreatedOnToolsVersion = 10.0; SystemCapabilities = { + com.apple.Push = { + enabled = 0; + }; com.apple.Sandbox = { enabled = 0; }; diff --git a/PlainPasta/PlainPasta.entitlements b/PlainPasta/Plain Pasta.entitlements similarity index 100% rename from PlainPasta/PlainPasta.entitlements rename to PlainPasta/Plain Pasta.entitlements From 3dc42213025d13f560d57116bb606a8fc68c0fd1 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 14:05:26 -0500 Subject: [PATCH 08/17] =?UTF-8?q?Fix=20entitlements=20issue=20and=20remove?= =?UTF-8?q?=20'Check=20for=20Updates=E2=80=A6'=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PlainPasta/AppDelegate.swift | 7 ------- PlainPasta/Info.plist | 4 ++-- PlainPasta/Localizable.swift | 5 ++--- PlainPasta/en.lproj/Localizable.strings | 1 - changelog.md | 6 ++++++ 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/PlainPasta/AppDelegate.swift b/PlainPasta/AppDelegate.swift index eb72dad..8555fef 100644 --- a/PlainPasta/AppDelegate.swift +++ b/PlainPasta/AppDelegate.swift @@ -36,12 +36,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { keyEquivalent: "" ) - let checkForUpdates = NSMenuItem( - title: L10n.checkForUpdates, - action: #selector(checkForAppUpdates), - keyEquivalent: "" - ) - let aboutPlainPasta = NSMenuItem( title: L10n.aboutPlainPasta, action: #selector(openAboutPage), @@ -56,7 +50,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { let orderedMenuItems = [ versionInfo, - checkForUpdates, NSMenuItem.separator(), enabledMenuItem, NSMenuItem.separator(), diff --git a/PlainPasta/Info.plist b/PlainPasta/Info.plist index c89b046..eaa9dcf 100644 --- a/PlainPasta/Info.plist +++ b/PlainPasta/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.0 + 1.0.1 CFBundleVersion - 10 + 1 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/PlainPasta/Localizable.swift b/PlainPasta/Localizable.swift index 98d3536..17e3cc1 100644 --- a/PlainPasta/Localizable.swift +++ b/PlainPasta/Localizable.swift @@ -1,5 +1,5 @@ // swiftlint:disable all -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen +// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen import Foundation @@ -14,8 +14,6 @@ internal enum L10n { internal static let aboutPlainPasta = L10n.tr("Localizable", "About Plain Pasta…") /// build internal static let build = L10n.tr("Localizable", "build") - /// Check for Updates… - internal static let checkForUpdates = L10n.tr("Localizable", "Check for Updates…") /// Enabled internal static let enabled = L10n.tr("Localizable", "Enabled") /// Plain Pasta @@ -31,6 +29,7 @@ internal enum L10n { extension L10n { private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String { + // swiftlint:disable:next nslocalizedstring_key let format = NSLocalizedString(key, tableName: table, bundle: Bundle(for: BundleToken.self), comment: "") return String(format: format, locale: Locale.current, arguments: args) } diff --git a/PlainPasta/en.lproj/Localizable.strings b/PlainPasta/en.lproj/Localizable.strings index 395a409..504cf58 100644 --- a/PlainPasta/en.lproj/Localizable.strings +++ b/PlainPasta/en.lproj/Localizable.strings @@ -7,7 +7,6 @@ // Menu Items "Enabled" = "Enabled"; // Title for Enabled menu item -"Check for Updates…" = "Check for Updates…"; // Title for Check for Updates menu item "About Plain Pasta…" = "About Plain Pasta…"; // Title for About menu item "Quit" = "Quit"; // Title for Quit menu item diff --git a/changelog.md b/changelog.md index 0dd019f..b35e81d 100644 --- a/changelog.md +++ b/changelog.md @@ -4,8 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2019-06-10 + +- Update entitlements file to allow for automatic creation of App ID in App Store Connect +- Remove "Check for Updates…" menu item, as this will now be done through the App Store + ## [1.0.0] - 2018-11-04 Initial release! [1.0.0]: https://github.com/hisaac/PlainPasta/compare/3f3479bf1b417790735aa6cfb8850eb73fe74a07...1.0.0 +[1.0.1]: https://github.com/hisaac/PlainPasta/compare/1.0.0...1.0.1 From 7449a53a660935cfd5262b731ef20ac7baa5864d Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 14:19:07 -0500 Subject: [PATCH 09/17] Enable App Sandboxing --- PlainPasta.xcodeproj/project.pbxproj | 4 +++- PlainPasta/Plain Pasta.entitlements | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index ab29b7d..dba969a 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -129,7 +129,7 @@ enabled = 0; }; com.apple.Sandbox = { - enabled = 0; + enabled = 1; }; }; }; @@ -356,6 +356,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = "PlainPasta/Plain Pasta.entitlements"; CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; @@ -377,6 +378,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = "PlainPasta/Plain Pasta.entitlements"; CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; diff --git a/PlainPasta/Plain Pasta.entitlements b/PlainPasta/Plain Pasta.entitlements index 0c67376..852fa1a 100644 --- a/PlainPasta/Plain Pasta.entitlements +++ b/PlainPasta/Plain Pasta.entitlements @@ -1,5 +1,8 @@ - + + com.apple.security.app-sandbox + + From f5097d87270d3406519972bbab34873cbb627aa0 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 10 Jun 2019 14:19:53 -0500 Subject: [PATCH 10/17] Update build number and changelog --- PlainPasta/Info.plist | 2 +- changelog.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/PlainPasta/Info.plist b/PlainPasta/Info.plist index eaa9dcf..d05d10d 100644 --- a/PlainPasta/Info.plist +++ b/PlainPasta/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 1.0.1 CFBundleVersion - 1 + 2 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/changelog.md b/changelog.md index b35e81d..f08adde 100644 --- a/changelog.md +++ b/changelog.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Update entitlements file to allow for automatic creation of App ID in App Store Connect - Remove "Check for Updates…" menu item, as this will now be done through the App Store +- Enable App Sandboxing for Mac App Store ## [1.0.0] - 2018-11-04 From ee614724fca8f0b18061b0cc815025f5a397d6d2 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Thu, 3 Sep 2020 21:49:02 -0500 Subject: [PATCH 11/17] Refactor checkPasteboard method to more surgically modify styled text content --- PlainPasta/PasteboardMonitor.swift | 35 ++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index 8647629..e388ce2 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -46,29 +46,40 @@ class PasteboardMonitor { timer.cancel() } - /// Checks the pasteboard for textual contents, and strips the formatting if possible + /// Checks the pasteboard for styled text contents, and strips the formatting if possible private func checkPasteboard() { if internalChangeCount != pasteboard.changeCount { // Check to see if the item on the pasteboard is a file or directory, and exit if it is guard pasteboard.availableType(from: [.fileName]) == nil else { return } - // Convert the pasteboard content into a plaintext string if possible - guard let plaintextString = pasteboard.string(forType: .string) else { return } + // Check to see if there is styled text on the pasteboard, and exit if not + guard pasteboard.availableType(from: [.rtf, .rtfd]) != nil else { return } - if plaintextString != previousPasteboard { - previousPasteboard = plaintextString - pasteboard.clearContents() - pasteboard.setString(plaintextString, forType: .string) + guard let pasteboardItem = pasteboard.pasteboardItems?.first else { return } + guard let plaintextString = pasteboardItem.string(forType: .string) else { return } - internalChangeCount = pasteboard.changeCount - - if #available(OSX 10.14, *) { - os_log(.info, "plaintext pasteboard content: %@", plaintextString) + let newPasteboardItem = NSPasteboardItem() + for type in pasteboardItem.types { + if type == .rtf || type == .rtfd { + newPasteboardItem.setString(plaintextString, forType: type) } else { - os_log("plaintext pasteboard content: %@", log: .default, type: .info, plaintextString) + guard let data = pasteboardItem.data(forType: type) else { continue } + newPasteboardItem.setData(data, forType: type) } } + + pasteboard.clearContents() + let wroteToPasteboard = pasteboard.writeObjects([newPasteboardItem]) + if wroteToPasteboard { + internalChangeCount = pasteboard.changeCount + } + + if #available(OSX 10.14, *) { + os_log(.info, "plaintext pasteboard content: %@", plaintextString) + } else { + os_log("plaintext pasteboard content: %@", log: .default, type: .info, plaintextString) + } } } From 332b2043d4f5634ea9001e89fef9aeac04f20e34 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Thu, 3 Sep 2020 21:51:09 -0500 Subject: [PATCH 12/17] Rename variable and refactor didSet for better readability --- PlainPasta/AppDelegate.swift | 2 +- PlainPasta/PasteboardMonitor.swift | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/PlainPasta/AppDelegate.swift b/PlainPasta/AppDelegate.swift index 4a83dc3..9827c82 100644 --- a/PlainPasta/AppDelegate.swift +++ b/PlainPasta/AppDelegate.swift @@ -73,7 +73,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, PasteboardMonitorDelegate { // MARK: - Menu Item Actions @objc func toggleTimer() { - pasteboardMonitor.enabledState.toggle() + pasteboardMonitor.isEnabled.toggle() } @objc func checkForAppUpdates() { diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index e388ce2..0f5ade8 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -30,8 +30,14 @@ class PasteboardMonitor { } /// The current state of the pasteboard monitor - var enabledState: Bool = true { - didSet { enabledState ? startTimer() : stopTimer() } + var isEnabled: Bool = true { + didSet { + if isEnabled { + startTimer() + } else { + stopTimer() + } + } } /// Starts monitoring the pasteboard, and sets the menu item's state to enabled From 5d0dedc5b22119cc3478505f5bc0bc8e706a338b Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Thu, 3 Sep 2020 22:06:20 -0500 Subject: [PATCH 13/17] Update changelog --- changelog.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index ccc326e..07429f8 100644 --- a/changelog.md +++ b/changelog.md @@ -6,18 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] -- Move to using GCD instead of `Timer` for repeat polling of the pasteboard. This provides a small increase in performance. - -## [1.0.1] - 2019-06-10 +### Changed +- Move to using GCD instead of `Timer` for repeat polling of the pasteboard. This provides a small increase in performance. - Update entitlements file to allow for automatic creation of App ID in App Store Connect - Remove "Check for Updates…" menu item, as this will now be done through the App Store - Enable App Sandboxing for Mac App Store +### Fixed + +- Fixed a bug that would cause images on the pasteboard to be removed ([reported](https://github.com/hisaac/PlainPasta/issues/3) by [@foigus](https://github.com/foigus). Thanks!) + ## [1.0.0] - 2018-11-04 Initial release! 🎉 -[Unreleased]: https://github.com/hisaac/PlainPasta/compare/master...development +[Unreleased]: https://github.com/hisaac/PlainPasta/compare/master...development [1.0.0]: https://github.com/hisaac/PlainPasta/compare/3f3479bf1b417790735aa6cfb8850eb73fe74a07...1.0.0 -[1.0.1]: https://github.com/hisaac/PlainPasta/compare/1.0.0...1.0.1 From fc845eccb27ee2291cc89496ae5580f6371b86b1 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Sat, 5 Sep 2020 13:17:13 -0500 Subject: [PATCH 14/17] Cleanup readme --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9546010..9e874ab 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- + Plain Pasta's app icon

# Plain Pasta @@ -12,22 +12,22 @@ I made this app because I rarely want styling to be copied to my clipboard. When Download the most recent version of Plain Pasta from the [Releases page](https://github.com/hisaac/PlainPasta/releases). -### Demonstration +## Demonstration -#### Without Plain Pasta +### Without Plain Pasta
- A screen recording of text and style being copy/pasted + A screen recording of text and style being copy/pasted

Copy/Pasting styled text takes both the text and the styling with it

-#### With Plain Pasta +### With Plain Pasta
- A screen recording of text being copy/pasted without its styling + A screen recording of text being copy/pasted without its styling

Copy/Pasting styled text with Plain Pasta enabled only pastes the text itself, no styling

@@ -36,11 +36,12 @@ Download the most recent version of Plain Pasta from the [Releases page](https:/ Plain Pasta was inspired by another app called [FormatMatch](https://itunes.apple.com/us/app/formatmatch/id445211988?mt=12) by [Robert Wessels](http://www.robertwessels.com). -I've used FormatMatch for many years, and I would've happily used it for many more years to come, but the app hasn't been updated for over 6 years, and Robert Wessel's website hasn't been updated since 2016. I've been concerned for the continued life of the app, so I finally decided to take the time to write a new version using modern technologies. +I've used FormatMatch for many years. I would've happily used it for many more years to come, but the app hasn't been updated for over 6 years, and Robert Wessel's website is no longer live. I've been concerned for the continued life of the app, so I finally decided to take the time to write a new version using modern technologies. - Icon image is [Noodles by Paolo Valzania from the Noun Project](https://thenounproject.com/search/?q=noodle&i=1681744) - Clipboard monitoring code based on [klipsustreamer](https://github.com/lahdekorpi/klipsustreamer) by [Toni Lähdekorpi](https://github.com/lahdekorpi) From 378938328f98e2dddf2d0ba36a6c218d5f6798c7 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Sat, 5 Sep 2020 13:18:21 -0500 Subject: [PATCH 15/17] Update xcodeproj format, and move localizable.strings into a swift file --- .swiftlint.yml | 1 + PlainPasta.xcodeproj/project.pbxproj | 40 ++++++------- .../contents.xcworkspacedata | 2 +- .../xcschemes/Plain Pasta.xcscheme | 15 +---- PlainPasta/AppDelegate.swift | 40 +++---------- PlainPasta/Localizable.swift | 57 +++++++++++++++++++ PlainPasta/PasteboardMonitor.swift | 2 - PlainPasta/en.lproj/Localizable.strings | 16 ------ .../{Base.lproj => en.lproj}/Main.storyboard | 4 +- changelog.md | 2 + 10 files changed, 89 insertions(+), 90 deletions(-) create mode 100644 PlainPasta/Localizable.swift delete mode 100644 PlainPasta/en.lproj/Localizable.strings rename PlainPasta/{Base.lproj => en.lproj}/Main.storyboard (99%) diff --git a/.swiftlint.yml b/.swiftlint.yml index 1a2de91..aad0b13 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -11,6 +11,7 @@ opt_in_rules: - number_separator - operator_usage_whitespace - redundant_nil_coalescing +- trailing_whitespace - unneeded_parentheses_in_closure_argument disabled_rules: diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index 36bb59d..f6717e5 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -3,15 +3,15 @@ archiveVersion = 1; classes = { }; - objectVersion = 51; + objectVersion = 53; objects = { /* Begin PBXBuildFile section */ 4A4E59272176AE7A002CF83D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A4E59262176AE7A002CF83D /* AppDelegate.swift */; }; 4A4E592B2176AE7A002CF83D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A4E592A2176AE7A002CF83D /* Assets.xcassets */; }; 4A4E592E2176AE7A002CF83D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A4E592C2176AE7A002CF83D /* Main.storyboard */; }; - 4A5E917A2179183E001C378F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E917C2179183E001C378F /* Localizable.strings */; }; 4AA984F42178DF6500B64A3F /* PasteboardMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */; }; + 4ADE040D24ECC23F0045181C /* Localizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ADE040C24ECC23F0045181C /* Localizable.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -19,15 +19,14 @@ 4A4E59262176AE7A002CF83D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 4A4E592A2176AE7A002CF83D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 4A4E592F2176AE7A002CF83D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4A5E9178217917A5001C378F /* swiftgen.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = swiftgen.yml; sourceTree = ""; }; - 4A5E917B2179183E001C378F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 4A8A68162176C5F500A4F1D8 /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; }; 4A8A68172176C5F500A4F1D8 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; 4A8A68182176C5F500A4F1D8 /* changelog.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = changelog.md; sourceTree = ""; }; 4A8A68192176C5F500A4F1D8 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 4A8A681A2176C5F500A4F1D8 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 4A9998E325040BE700141546 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/Main.storyboard; sourceTree = ""; }; 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardMonitor.swift; sourceTree = ""; }; - F2E4F2EC22AED734006313B9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 4ADE040C24ECC23F0045181C /* Localizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Localizable.swift; sourceTree = ""; }; F2E4F2ED22AED9E0006313B9 /* Plain Pasta.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Plain Pasta.entitlements"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -77,11 +76,11 @@ children = ( 4A4E59262176AE7A002CF83D /* AppDelegate.swift */, 4AA984F32178DF6500B64A3F /* PasteboardMonitor.swift */, + 4ADE040C24ECC23F0045181C /* Localizable.swift */, 4A4E592A2176AE7A002CF83D /* Assets.xcassets */, 4A4E592C2176AE7A002CF83D /* Main.storyboard */, 4A4E592F2176AE7A002CF83D /* Info.plist */, F2E4F2ED22AED9E0006313B9 /* Plain Pasta.entitlements */, - 4A5E917C2179183E001C378F /* Localizable.strings */, ); path = PlainPasta; sourceTree = ""; @@ -93,10 +92,10 @@ isa = PBXNativeTarget; buildConfigurationList = 4A4E59332176AE7A002CF83D /* Build configuration list for PBXNativeTarget "Plain Pasta" */; buildPhases = ( - 4A5E917721791748001C378F /* [Swiftlint] */, 4A4E591F2176AE7A002CF83D /* Sources */, 4A4E59202176AE7A002CF83D /* Frameworks */, 4A4E59212176AE7A002CF83D /* Resources */, + 4A5E917721791748001C378F /* Run Swiftlint */, ); buildRules = ( ); @@ -114,12 +113,12 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1000; - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = Levelsoft; TargetAttributes = { 4A4E59222176AE7A002CF83D = { CreatedOnToolsVersion = 10.0; - LastSwiftMigration = 1020; + LastSwiftMigration = 1200; SystemCapabilities = { com.apple.Push = { enabled = 0; @@ -132,12 +131,11 @@ }; }; buildConfigurationList = 4A4E591E2176AE7A002CF83D /* Build configuration list for PBXProject "PlainPasta" */; - compatibilityVersion = "Xcode 10.0"; + compatibilityVersion = "Xcode 11.4"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, - Base, ); mainGroup = 4A4E591A2176AE7A002CF83D; productRefGroup = 4A4E59242176AE7A002CF83D /* Products */; @@ -155,7 +153,6 @@ buildActionMask = 2147483647; files = ( 4A4E592B2176AE7A002CF83D /* Assets.xcassets in Resources */, - 4A5E917A2179183E001C378F /* Localizable.strings in Resources */, 4A4E592E2176AE7A002CF83D /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -163,7 +160,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 4A5E917721791748001C378F /* [Swiftlint] */ = { + 4A5E917721791748001C378F /* Run Swiftlint */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -172,7 +169,7 @@ ); inputPaths = ( ); - name = "[Swiftlint]"; + name = "Run Swiftlint"; outputFileListPaths = ( ); outputPaths = ( @@ -189,6 +186,7 @@ buildActionMask = 2147483647; files = ( 4A4E59272176AE7A002CF83D /* AppDelegate.swift in Sources */, + 4ADE040D24ECC23F0045181C /* Localizable.swift in Sources */, 4AA984F42178DF6500B64A3F /* PasteboardMonitor.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -199,19 +197,11 @@ 4A4E592C2176AE7A002CF83D /* Main.storyboard */ = { isa = PBXVariantGroup; children = ( - F2E4F2EC22AED734006313B9 /* Base */, + 4A9998E325040BE700141546 /* en */, ); name = Main.storyboard; sourceTree = ""; }; - 4A5E917C2179183E001C378F /* Localizable.strings */ = { - isa = PBXVariantGroup; - children = ( - 4A5E917B2179183E001C378F /* en */, - ); - name = Localizable.strings; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -241,6 +231,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -302,6 +293,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -339,6 +331,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = F2J52QJQ9Y; + ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/PlainPasta/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -361,6 +354,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = F2J52QJQ9Y; + ENABLE_HARDENED_RUNTIME = YES; FRAMEWORK_SEARCH_PATHS = "$(inherited)"; INFOPLIST_FILE = "$(SRCROOT)/PlainPasta/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/PlainPasta.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/PlainPasta.xcodeproj/project.xcworkspace/contents.xcworkspacedata index b2a34b2..919434a 100644 --- a/PlainPasta.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/PlainPasta.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/PlainPasta.xcodeproj/xcshareddata/xcschemes/Plain Pasta.xcscheme b/PlainPasta.xcodeproj/xcshareddata/xcschemes/Plain Pasta.xcscheme index 52cbf04..dfdde5e 100644 --- a/PlainPasta.xcodeproj/xcshareddata/xcschemes/Plain Pasta.xcscheme +++ b/PlainPasta.xcodeproj/xcshareddata/xcschemes/Plain Pasta.xcscheme @@ -1,6 +1,6 @@ - - - - - - - - - + - + diff --git a/changelog.md b/changelog.md index 07429f8..d60aa7a 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Update entitlements file to allow for automatic creation of App ID in App Store Connect - Remove "Check for Updates…" menu item, as this will now be done through the App Store - Enable App Sandboxing for Mac App Store +- Enable hardened runtime +- Move Localizable.strings into Swift file ### Fixed From e3d6c90e5a6f8bfcffd64896ea35beecc87b2bf8 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Sat, 5 Sep 2020 13:35:32 -0500 Subject: [PATCH 16/17] Set deployment target to 10.10 and improve some logging --- PlainPasta.xcodeproj/project.pbxproj | 4 ++-- PlainPasta/PasteboardMonitor.swift | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/PlainPasta.xcodeproj/project.pbxproj b/PlainPasta.xcodeproj/project.pbxproj index f6717e5..28bc9fc 100644 --- a/PlainPasta.xcodeproj/project.pbxproj +++ b/PlainPasta.xcodeproj/project.pbxproj @@ -257,7 +257,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -313,7 +313,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; diff --git a/PlainPasta/PasteboardMonitor.swift b/PlainPasta/PasteboardMonitor.swift index 7b4d925..07c97c0 100644 --- a/PlainPasta/PasteboardMonitor.swift +++ b/PlainPasta/PasteboardMonitor.swift @@ -77,13 +77,20 @@ class PasteboardMonitor { let wroteToPasteboard = pasteboard.writeObjects([newPasteboardItem]) if wroteToPasteboard { internalChangeCount = pasteboard.changeCount + logPlaintextStringToConsole(plaintextString) } + } + } - if #available(OSX 10.14, *) { - os_log(.info, "plaintext pasteboard content: %@", plaintextString) - } else { - os_log("plaintext pasteboard content: %@", log: .default, type: .info, plaintextString) - } + private func logPlaintextStringToConsole(_ plaintextString: String) { + let debugFormatString: String = "plaintext pasteboard content: %@" + let debugFormatStaticString: StaticString = "plaintext pasteboard content: %@" + if #available(OSX 10.14, *) { + os_log(.info, debugFormatStaticString, plaintextString) + } else if #available(OSX 10.12, *) { + os_log(debugFormatStaticString, log: .default, type: .info, plaintextString) + } else { + NSLog(debugFormatString, plaintextString) } } From 2c3e649d0f6409b80834021fd4a713e0216a17a8 Mon Sep 17 00:00:00 2001 From: Isaac Halvorson Date: Mon, 7 Sep 2020 09:49:07 -0500 Subject: [PATCH 17/17] Update changelog and readme for release --- README.md | 5 ----- changelog.md | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9e874ab..b3266f5 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,3 @@ I've used FormatMatch for many years. I would've happily used it for many more y - Icon image is [Noodles by Paolo Valzania from the Noun Project](https://thenounproject.com/search/?q=noodle&i=1681744) - Clipboard monitoring code based on [klipsustreamer](https://github.com/lahdekorpi/klipsustreamer) by [Toni Lähdekorpi](https://github.com/lahdekorpi) - - diff --git a/changelog.md b/changelog.md index d60aa7a..225078e 100644 --- a/changelog.md +++ b/changelog.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [1.1.0] - 2020-09-07 ### Changed @@ -25,3 +25,4 @@ Initial release! 🎉 [Unreleased]: https://github.com/hisaac/PlainPasta/compare/master...development [1.0.0]: https://github.com/hisaac/PlainPasta/compare/3f3479bf1b417790735aa6cfb8850eb73fe74a07...1.0.0 +[1.1.0]: https://github.com/hisaac/PlainPasta/compare/1.0.0...1.1.0