Skip to content

Commit cf553c1

Browse files
committed
Minor tweaks
1 parent 2410aba commit cf553c1

File tree

12 files changed

+224
-241
lines changed

12 files changed

+224
-241
lines changed

.swiftlint.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
only_rules:
2-
- anyobject_protocol
2+
- accessibility_trait_for_button
33
- array_init
44
- block_based_kvo
55
- class_delegate_protocol
@@ -10,6 +10,7 @@ only_rules:
1010
- collection_alignment
1111
- colon
1212
- comma
13+
- comma_inheritance
1314
- compiler_protocol_init
1415
- computed_accessors_order
1516
- conditional_returns_on_newline
@@ -77,12 +78,11 @@ only_rules:
7778
- no_fallthrough_only
7879
- no_space_in_method_call
7980
- notification_center_detachment
81+
- ns_number_init_as_function_reference
8082
- nsobject_prefer_isequal
81-
- number_separator
8283
- opening_brace
8384
- operator_usage_whitespace
8485
- operator_whitespace
85-
- orphaned_doc_comment
8686
- overridden_super_call
8787
- prefer_self_in_static_references
8888
- prefer_self_type_over_type_of_self
@@ -106,8 +106,10 @@ only_rules:
106106
- required_enum_case
107107
- return_arrow_whitespace
108108
- return_value_from_void_function
109+
- self_binding
109110
- self_in_property_initialization
110111
- shorthand_operator
112+
- shorthand_optional_binding
111113
- sorted_first_last
112114
- statement_position
113115
- static_operator
@@ -137,9 +139,9 @@ only_rules:
137139
- unused_setter_value
138140
- valid_ibinspectable
139141
- vertical_parameter_alignment
140-
- vertical_parameter_alignment_on_call
141142
- vertical_whitespace_closing_braces
142143
- vertical_whitespace_opening_braces
144+
- void_function_in_ternary
143145
- void_return
144146
- xct_specific_matcher
145147
- xctfail_message
@@ -149,8 +151,8 @@ analyzer_rules:
149151
- unused_declaration
150152
- unused_import
151153
- typesafe_array_init
152-
number_separator:
153-
minimum_length: 5
154+
for_where:
155+
allow_for_as_filter: true
154156
identifier_name:
155157
max_length:
156158
warning: 100
@@ -203,3 +205,6 @@ custom_rules:
203205
final_class:
204206
regex: '^class [a-zA-Z\d]+[^{]+\{'
205207
message: 'Classes should be marked as final whenever possible. If you actually need it to be subclassable, just add `// swiftlint:disable:next final_class`.'
208+
no_alignment_center:
209+
regex: '\b\(alignment: .center\b'
210+
message: 'This alignment is the default.'

Color Picker.xcodeproj/project.pbxproj

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 55;
6+
objectVersion = 56;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -24,7 +24,7 @@
2424
E3DFA8C92662514800D2623E /* Events.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3DFA8C82662514800D2623E /* Events.swift */; };
2525
E3E7D79B27218903009D71F4 /* Intents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E3E7D79A27218903009D71F4 /* Intents.framework */; platformFilter = maccatalyst; };
2626
E3E7D79E27218903009D71F4 /* IntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D79D27218903009D71F4 /* IntentHandler.swift */; };
27-
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = E3E7D79927218903009D71F4 /* IntentsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
27+
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = E3E7D79927218903009D71F4 /* IntentsExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
2828
E3E7D7A927218959009D71F4 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D7A827218959009D71F4 /* Intents.intentdefinition */; };
2929
E3E7D7AA27218959009D71F4 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = E3E7D7A827218959009D71F4 /* Intents.intentdefinition */; };
3030
E3E7D7AC27218C03009D71F4 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = E38D4332263AB24E00701B82 /* Utilities.swift */; };
@@ -44,15 +44,15 @@
4444
/* End PBXContainerItemProxy section */
4545

4646
/* Begin PBXCopyFilesBuildPhase section */
47-
E3E7D7A327218903009D71F4 /* Embed App Extensions */ = {
47+
E3E7D7A327218903009D71F4 /* Embed Foundation Extensions */ = {
4848
isa = PBXCopyFilesBuildPhase;
4949
buildActionMask = 2147483647;
5050
dstPath = "";
5151
dstSubfolderSpec = 13;
5252
files = (
53-
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed App Extensions */,
53+
E3E7D7A227218903009D71F4 /* IntentsExtension.appex in Embed Foundation Extensions */,
5454
);
55-
name = "Embed App Extensions";
55+
name = "Embed Foundation Extensions";
5656
runOnlyForDeploymentPostprocessing = 0;
5757
};
5858
/* End PBXCopyFilesBuildPhase section */
@@ -186,7 +186,7 @@
186186
E3A3B11625904E7B001B4D0C /* Frameworks */,
187187
E3A3B11725904E7B001B4D0C /* Resources */,
188188
E394DAAF263E95E200F5B042 /* Copy “Launch at Login Helper” */,
189-
E3E7D7A327218903009D71F4 /* Embed App Extensions */,
189+
E3E7D7A327218903009D71F4 /* Embed Foundation Extensions */,
190190
);
191191
buildRules = (
192192
);
@@ -233,7 +233,7 @@
233233
isa = PBXProject;
234234
attributes = {
235235
LastSwiftUpdateCheck = 1310;
236-
LastUpgradeCheck = 1250;
236+
LastUpgradeCheck = 1400;
237237
TargetAttributes = {
238238
E3A3B11825904E7B001B4D0C = {
239239
CreatedOnToolsVersion = 12.3;
@@ -244,7 +244,7 @@
244244
};
245245
};
246246
buildConfigurationList = E3A3B11425904E7B001B4D0C /* Build configuration list for PBXProject "Color Picker" */;
247-
compatibilityVersion = "Xcode 13.0";
247+
compatibilityVersion = "Xcode 14.0";
248248
developmentRegion = en;
249249
hasScannedForEncodings = 0;
250250
knownRegions = (
@@ -291,6 +291,7 @@
291291
/* Begin PBXShellScriptBuildPhase section */
292292
E394DAAF263E95E200F5B042 /* Copy “Launch at Login Helper” */ = {
293293
isa = PBXShellScriptBuildPhase;
294+
alwaysOutOfDate = 1;
294295
buildActionMask = 2147483647;
295296
files = (
296297
);
@@ -310,6 +311,7 @@
310311
};
311312
E3E9F9AE2642B8F800AE6450 /* SwiftLint */ = {
312313
isa = PBXShellScriptBuildPhase;
314+
alwaysOutOfDate = 1;
313315
buildActionMask = 2147483647;
314316
files = (
315317
);
@@ -403,6 +405,7 @@
403405
CLANG_WARN_UNREACHABLE_CODE = YES;
404406
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
405407
COPY_PHASE_STRIP = NO;
408+
DEAD_CODE_STRIPPING = YES;
406409
DEBUG_INFORMATION_FORMAT = dwarf;
407410
ENABLE_STRICT_OBJC_MSGSEND = YES;
408411
ENABLE_TESTABILITY = YES;
@@ -420,7 +423,7 @@
420423
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
421424
GCC_WARN_UNUSED_FUNCTION = YES;
422425
GCC_WARN_UNUSED_VARIABLE = YES;
423-
MACOSX_DEPLOYMENT_TARGET = 12.3;
426+
MACOSX_DEPLOYMENT_TARGET = 12.4;
424427
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
425428
MTL_FAST_MATH = YES;
426429
ONLY_ACTIVE_ARCH = YES;
@@ -466,6 +469,7 @@
466469
CLANG_WARN_UNREACHABLE_CODE = YES;
467470
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
468471
COPY_PHASE_STRIP = NO;
472+
DEAD_CODE_STRIPPING = YES;
469473
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
470474
ENABLE_NS_ASSERTIONS = NO;
471475
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -477,7 +481,7 @@
477481
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
478482
GCC_WARN_UNUSED_FUNCTION = YES;
479483
GCC_WARN_UNUSED_VARIABLE = YES;
480-
MACOSX_DEPLOYMENT_TARGET = 12.3;
484+
MACOSX_DEPLOYMENT_TARGET = 12.4;
481485
MTL_ENABLE_DEBUG_INFO = NO;
482486
MTL_FAST_MATH = YES;
483487
SDKROOT = macosx;
@@ -497,11 +501,13 @@
497501
CODE_SIGN_IDENTITY = "Apple Development";
498502
CODE_SIGN_STYLE = Automatic;
499503
COMBINE_HIDPI_IMAGES = YES;
504+
DEAD_CODE_STRIPPING = YES;
500505
DEVELOPMENT_ASSET_PATHS = "";
501506
DEVELOPMENT_TEAM = YG56YK5RN5;
502507
ENABLE_HARDENED_RUNTIME = YES;
503508
ENABLE_PREVIEWS = YES;
504509
INFOPLIST_FILE = "Color Picker/Info.plist";
510+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
505511
LD_RUNPATH_SEARCH_PATHS = (
506512
"$(inherited)",
507513
"@executable_path/../Frameworks",
@@ -522,11 +528,13 @@
522528
CODE_SIGN_IDENTITY = "Apple Development";
523529
CODE_SIGN_STYLE = Automatic;
524530
COMBINE_HIDPI_IMAGES = YES;
531+
DEAD_CODE_STRIPPING = YES;
525532
DEVELOPMENT_ASSET_PATHS = "";
526533
DEVELOPMENT_TEAM = YG56YK5RN5;
527534
ENABLE_HARDENED_RUNTIME = YES;
528535
ENABLE_PREVIEWS = YES;
529536
INFOPLIST_FILE = "Color Picker/Info.plist";
537+
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.developer-tools";
530538
LD_RUNPATH_SEARCH_PATHS = (
531539
"$(inherited)",
532540
"@executable_path/../Frameworks",
@@ -544,6 +552,7 @@
544552
CODE_SIGN_ENTITLEMENTS = IntentsExtension/IntentsExtension.entitlements;
545553
CODE_SIGN_IDENTITY = "Apple Development";
546554
CODE_SIGN_STYLE = Automatic;
555+
DEAD_CODE_STRIPPING = YES;
547556
DEVELOPMENT_TEAM = YG56YK5RN5;
548557
ENABLE_HARDENED_RUNTIME = YES;
549558
GENERATE_INFOPLIST_FILE = YES;
@@ -555,7 +564,6 @@
555564
"@executable_path/../Frameworks",
556565
"@executable_path/../../../../Frameworks",
557566
);
558-
MACOSX_DEPLOYMENT_TARGET = 12.0;
559567
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Color-Picker.IntentsExtension";
560568
PRODUCT_NAME = "$(TARGET_NAME)";
561569
SKIP_INSTALL = YES;
@@ -571,6 +579,7 @@
571579
CODE_SIGN_ENTITLEMENTS = IntentsExtension/IntentsExtension.entitlements;
572580
CODE_SIGN_IDENTITY = "Apple Development";
573581
CODE_SIGN_STYLE = Automatic;
582+
DEAD_CODE_STRIPPING = YES;
574583
DEVELOPMENT_TEAM = YG56YK5RN5;
575584
ENABLE_HARDENED_RUNTIME = YES;
576585
GENERATE_INFOPLIST_FILE = YES;
@@ -582,7 +591,6 @@
582591
"@executable_path/../Frameworks",
583592
"@executable_path/../../../../Frameworks",
584593
);
585-
MACOSX_DEPLOYMENT_TARGET = 12.0;
586594
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Color-Picker.IntentsExtension";
587595
PRODUCT_NAME = "$(TARGET_NAME)";
588596
SKIP_INSTALL = YES;
@@ -637,31 +645,31 @@
637645
repositoryURL = "https://github.com/sindresorhus/LaunchAtLogin";
638646
requirement = {
639647
kind = upToNextMajorVersion;
640-
minimumVersion = 4.2.0;
648+
minimumVersion = 5.0.0;
641649
};
642650
};
643651
E394DAB0263E965500F5B042 /* XCRemoteSwiftPackageReference "KeyboardShortcuts" */ = {
644652
isa = XCRemoteSwiftPackageReference;
645653
repositoryURL = "https://github.com/sindresorhus/KeyboardShortcuts";
646654
requirement = {
647655
kind = upToNextMajorVersion;
648-
minimumVersion = 1.6.0;
656+
minimumVersion = 1.9.0;
649657
};
650658
};
651659
E3E14060259A0D97004FC89F /* XCRemoteSwiftPackageReference "Defaults" */ = {
652660
isa = XCRemoteSwiftPackageReference;
653661
repositoryURL = "https://github.com/sindresorhus/Defaults";
654662
requirement = {
655663
kind = upToNextMajorVersion;
656-
minimumVersion = 6.2.1;
664+
minimumVersion = 6.3.0;
657665
};
658666
};
659667
E3F4BC852788A5780075DC52 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
660668
isa = XCRemoteSwiftPackageReference;
661669
repositoryURL = "https://github.com/getsentry/sentry-cocoa";
662670
requirement = {
663671
kind = upToNextMajorVersion;
664-
minimumVersion = 7.17.0;
672+
minimumVersion = 7.31.3;
665673
};
666674
};
667675
/* End XCRemoteSwiftPackageReference section */

Color Picker.xcodeproj/xcshareddata/xcschemes/Color Picker.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1250"
3+
LastUpgradeVersion = "1400"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Color Picker/App.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import SwiftUI
22
import Defaults
3+
import LaunchAtLogin
34

45
/**
56
NOTES:
67
- The "com.apple.security.files.user-selected.read-only" entitlement is required by the "Open" menu in the "Color Palettes" pane.
8+
9+
TODO when targeting macOS 13:
10+
- Upload non-App Store version.
11+
12+
TODO shortcut action ideas;
13+
- Convert color
14+
- Toggle color panel
15+
- Toggle color sampler in app
716
*/
817

918
@main
@@ -56,8 +65,8 @@ struct AppMain: App {
5665
CommandGroup(replacing: .help) {
5766
Link("What is LCH color?", destination: "https://lea.verou.me/2020/04/lch-colors-in-css-what-why-and-how/")
5867
Link("FAQ", destination: "https://github.com/sindresorhus/System-Color-Picker#faq")
59-
Divider()
6068
Link("Website", destination: "https://sindresorhus.com/system-color-picker")
69+
Divider()
6170
Link("Rate on the App Store", destination: "macappstore://apps.apple.com/app/id1545870783?action=write-review")
6271
Link("More Apps by Me", destination: "macappstore://apps.apple.com/developer/id328077650")
6372
Divider()
@@ -72,6 +81,8 @@ struct AppMain: App {
7281
}
7382

7483
private func migrate() {
84+
LaunchAtLogin.migrateIfNeeded()
85+
7586
// TODO: Remove in 2023.
7687
SSApp.runOnce(identifier: "migrateShownColorFormats") {
7788
guard !SSApp.isFirstLaunch else {
@@ -119,7 +130,11 @@ struct AppMain: App {
119130

120131
@MainActor
121132
private final class AppDelegate: NSObject, NSApplicationDelegate {
122-
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
133+
func applicationDidFinishLaunching(_ notification: Notification) {
134+
if #available(macOS 13, *) {
135+
SSApp.swiftUIMainWindow?.close()
136+
}
137+
}
123138

124139
// Does not work on macOS 12.0.1 because of `WindowGroup`: https://github.com/feedback-assistant/reports/issues/246
125140
// This is only run when the app is started when it's already running.

Color Picker/AppState.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ final class AppState: ObservableObject {
1313
let colorPanel = ColorPanel()
1414
colorPanel.titleVisibility = .hidden
1515
colorPanel.hidesOnDeactivate = false
16+
colorPanel.becomesKeyOnlyIfNeeded = false
1617
colorPanel.isFloatingPanel = false
1718
colorPanel.isRestorable = false
1819
colorPanel.styleMask.remove(.utilityWindow)
1920
colorPanel.standardWindowButton(.miniaturizeButton)?.isHidden = true
2021
colorPanel.standardWindowButton(.zoomButton)?.isHidden = true
2122
colorPanel.tabbingMode = .disallowed
2223
colorPanel.collectionBehavior = [
23-
.moveToActiveSpace,
24+
.canJoinAllSpaces,
2425
.fullScreenAuxiliary
26+
// We cannot enable tiling as then it doesn't show up in fullscreen spaces. (macOS 12.5)
27+
// .fullScreenAllowsTiling
2528
]
2629
colorPanel.makeMain()
2730

@@ -145,6 +148,8 @@ final class AppState: ObservableObject {
145148

146149
if Defaults[.showInMenuBar] {
147150
colorPanel.close()
151+
} else {
152+
colorPanel.makeKeyAndOrderFront(nil)
148153
}
149154

150155
#if DEBUG
@@ -162,12 +167,16 @@ final class AppState: ObservableObject {
162167
}
163168

164169
private func fixStuff() {
165-
// Make the invisible native SwitUI window not block access to the desktop. (macOS 12.0)
166-
// https://github.com/feedback-assistant/reports/issues/253
167-
SSApp.swiftUIMainWindow?.ignoresMouseEvents = true
168-
169-
// Make the invisible native SwiftUI window not show up in mission control when in menu bar mode. (macOS 11.6)
170-
SSApp.swiftUIMainWindow?.collectionBehavior = .stationary
170+
if #available(macOS 13, *) {
171+
SSApp.swiftUIMainWindow?.close()
172+
} else {
173+
// Make the invisible native SwitUI window not block access to the desktop. (macOS 12.0)
174+
// https://github.com/feedback-assistant/reports/issues/253
175+
SSApp.swiftUIMainWindow?.ignoresMouseEvents = true
176+
177+
// Make the invisible native SwiftUI window not show up in mission control when in menu bar mode. (macOS 11.6)
178+
SSApp.swiftUIMainWindow?.collectionBehavior = .stationary
179+
}
171180
}
172181

173182
private func requestReview() {

0 commit comments

Comments
 (0)