Skip to content

Commit a41051b

Browse files
committed
Require macOS 11 and rewrite the app
1 parent 89d6f1b commit a41051b

30 files changed

+616
-882
lines changed

Diff for: .github/funding.yml

-2
This file was deleted.

Diff for: .swiftlint.yml

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
whitelist_rules:
1+
only_rules:
22
- anyobject_protocol
33
- array_init
44
- block_based_kvo
@@ -35,7 +35,7 @@ whitelist_rules:
3535
- empty_parentheses_with_trailing_closure
3636
- empty_string
3737
- empty_xctest_method
38-
- enum_case_associated_value_count
38+
- enum_case_associated_values_count
3939
- explicit_init
4040
- fallthrough
4141
- fatal_error_message
@@ -48,6 +48,7 @@ whitelist_rules:
4848
- identifier_name
4949
- implicit_getter
5050
- implicit_return
51+
- inclusive_language
5152
- inert_defer
5253
- is_disjoint
5354
- joined_default_parameter
@@ -86,7 +87,6 @@ whitelist_rules:
8687
- private_action
8788
- private_outlet
8889
- private_unit_test
89-
- prohibited_nan_comparison
9090
- prohibited_super_call
9191
- protocol_property_accessors_order
9292
- reduce_boolean
@@ -100,7 +100,6 @@ whitelist_rules:
100100
- redundant_type_annotation
101101
- redundant_void_return
102102
- required_enum_case
103-
- return_value_from_void_function
104103
- return_arrow_whitespace
105104
- shorthand_operator
106105
- sorted_first_last
@@ -111,19 +110,19 @@ whitelist_rules:
111110
- switch_case_alignment
112111
- switch_case_on_newline
113112
- syntactic_sugar
113+
- test_case_accessibility
114114
- toggle_bool
115115
- trailing_closure
116116
- trailing_comma
117117
- trailing_newline
118118
- trailing_semicolon
119119
- trailing_whitespace
120-
- tuple_pattern
121120
- unavailable_function
122121
- unneeded_break_in_switch
123-
- unneeded_notification_center_removal
124122
- unneeded_parentheses_in_closure_argument
125123
- unowned_variable_capture
126124
- untyped_error_in_catch
125+
- unused_capture_list
127126
- unused_closure_parameter
128127
- unused_control_flow_label
129128
- unused_enumerated
@@ -135,16 +134,12 @@ whitelist_rules:
135134
- vertical_whitespace_closing_braces
136135
- vertical_whitespace_opening_braces
137136
- void_return
138-
- weak_delegate
139137
- xct_specific_matcher
140138
- xctfail_message
141139
- yoda_condition
142140
analyzer_rules:
143141
- unused_declaration
144142
- unused_import
145-
force_cast: warning
146-
force_try: warning
147-
force_unwrapping: warning
148143
number_separator:
149144
minimum_length: 5
150145
identifier_name:
@@ -167,7 +162,7 @@ identifier_name:
167162
- 'y1'
168163
- 'y2'
169164
deployment_target:
170-
macOS_deployment_target: '10.15.5'
165+
macOS_deployment_target: '11'
171166
custom_rules:
172167
no_nsrect:
173168
regex: '\bNSRect\b'

Diff for: Pasteboard Viewer.xcodeproj/project.pbxproj

+14-25
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,31 @@
1212
E337758A2486CB9200DBE2A0 /* AppCenterCrashes in Frameworks */ = {isa = PBXBuildFile; productRef = E33775892486CB9200DBE2A0 /* AppCenterCrashes */; };
1313
E338690024AC782D0074DFF8 /* InternetAccessPolicy.json in Resources */ = {isa = PBXBuildFile; fileRef = E33868FF24AC782D0074DFF8 /* InternetAccessPolicy.json */; };
1414
E353C8B4256BE26800D08A09 /* WelcomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E353C8B3256BE26800D08A09 /* WelcomeView.swift */; };
15-
E3A7F1DD23F7DAD400CDF428 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A7F1DC23F7DAD400CDF428 /* AppDelegate.swift */; };
15+
E3A7F1DD23F7DAD400CDF428 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A7F1DC23F7DAD400CDF428 /* App.swift */; };
1616
E3A7F1DF23F7DAD400CDF428 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A7F1DE23F7DAD400CDF428 /* ContentView.swift */; };
1717
E3A7F1E123F7DAD700CDF428 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E3A7F1E023F7DAD700CDF428 /* Assets.xcassets */; };
1818
E3A7F1E423F7DAD700CDF428 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E3A7F1E323F7DAD700CDF428 /* Preview Assets.xcassets */; };
19-
E3A7F1E723F7DAD700CDF428 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E3A7F1E523F7DAD700CDF428 /* Main.storyboard */; };
2019
E3A7F20F23F7E36000CDF428 /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A7F20E23F7E36000CDF428 /* Utilities.swift */; };
2120
E3A7F21223F8498F00CDF428 /* PasteboardContentsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3A7F21123F8498F00CDF428 /* PasteboardContentsView.swift */; };
2221
E3BB8DC623FBDBCE007A3849 /* Pasteboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3BB8DC523FBDBCE007A3849 /* Pasteboard.swift */; };
22+
E3E4394225FDF97A000DE4B8 /* AppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3E4394125FDF97A000DE4B8 /* AppState.swift */; };
2323
/* End PBXBuildFile section */
2424

2525
/* Begin PBXFileReference section */
2626
E31C294323FBE32200DF3442 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
2727
E33868FF24AC782D0074DFF8 /* InternetAccessPolicy.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = InternetAccessPolicy.json; sourceTree = "<group>"; };
2828
E353C8B3256BE26800D08A09 /* WelcomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeView.swift; sourceTree = "<group>"; };
2929
E3A7F1D923F7DAD400CDF428 /* Pasteboard Viewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Pasteboard Viewer.app"; sourceTree = BUILT_PRODUCTS_DIR; };
30-
E3A7F1DC23F7DAD400CDF428 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
30+
E3A7F1DC23F7DAD400CDF428 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; };
3131
E3A7F1DE23F7DAD400CDF428 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
3232
E3A7F1E023F7DAD700CDF428 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
3333
E3A7F1E323F7DAD700CDF428 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
34-
E3A7F1E623F7DAD700CDF428 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
3534
E3A7F1E823F7DAD700CDF428 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3635
E3A7F1E923F7DAD700CDF428 /* Pasteboard_Viewer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Pasteboard_Viewer.entitlements; sourceTree = "<group>"; };
3736
E3A7F20E23F7E36000CDF428 /* Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Utilities.swift; sourceTree = "<group>"; };
3837
E3A7F21123F8498F00CDF428 /* PasteboardContentsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardContentsView.swift; sourceTree = "<group>"; };
3938
E3BB8DC523FBDBCE007A3849 /* Pasteboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Pasteboard.swift; sourceTree = "<group>"; };
39+
E3E4394125FDF97A000DE4B8 /* AppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppState.swift; sourceTree = "<group>"; };
4040
/* End PBXFileReference section */
4141

4242
/* Begin PBXFrameworksBuildPhase section */
@@ -72,7 +72,8 @@
7272
E3A7F1DB23F7DAD400CDF428 /* Pasteboard Viewer */ = {
7373
isa = PBXGroup;
7474
children = (
75-
E3A7F1DC23F7DAD400CDF428 /* AppDelegate.swift */,
75+
E3A7F1DC23F7DAD400CDF428 /* App.swift */,
76+
E3E4394125FDF97A000DE4B8 /* AppState.swift */,
7677
E31C294323FBE32200DF3442 /* Constants.swift */,
7778
E3A7F1DE23F7DAD400CDF428 /* ContentView.swift */,
7879
E3A7F21123F8498F00CDF428 /* PasteboardContentsView.swift */,
@@ -97,7 +98,6 @@
9798
E3D883B124C898890001C032 /* Other */ = {
9899
isa = PBXGroup;
99100
children = (
100-
E3A7F1E523F7DAD700CDF428 /* Main.storyboard */,
101101
E3A7F1E823F7DAD700CDF428 /* Info.plist */,
102102
E3A7F1E923F7DAD700CDF428 /* Pasteboard_Viewer.entitlements */,
103103
E33868FF24AC782D0074DFF8 /* InternetAccessPolicy.json */,
@@ -173,7 +173,6 @@
173173
buildActionMask = 2147483647;
174174
files = (
175175
E338690024AC782D0074DFF8 /* InternetAccessPolicy.json in Resources */,
176-
E3A7F1E723F7DAD700CDF428 /* Main.storyboard in Resources */,
177176
E3A7F1E423F7DAD700CDF428 /* Preview Assets.xcassets in Resources */,
178177
E3A7F1E123F7DAD700CDF428 /* Assets.xcassets in Resources */,
179178
);
@@ -211,26 +210,16 @@
211210
E3A7F20F23F7E36000CDF428 /* Utilities.swift in Sources */,
212211
E3A7F21223F8498F00CDF428 /* PasteboardContentsView.swift in Sources */,
213212
E3BB8DC623FBDBCE007A3849 /* Pasteboard.swift in Sources */,
213+
E3E4394225FDF97A000DE4B8 /* AppState.swift in Sources */,
214214
E3A7F1DF23F7DAD400CDF428 /* ContentView.swift in Sources */,
215-
E3A7F1DD23F7DAD400CDF428 /* AppDelegate.swift in Sources */,
215+
E3A7F1DD23F7DAD400CDF428 /* App.swift in Sources */,
216216
E31C294423FBE32200DF3442 /* Constants.swift in Sources */,
217217
E353C8B4256BE26800D08A09 /* WelcomeView.swift in Sources */,
218218
);
219219
runOnlyForDeploymentPostprocessing = 0;
220220
};
221221
/* End PBXSourcesBuildPhase section */
222222

223-
/* Begin PBXVariantGroup section */
224-
E3A7F1E523F7DAD700CDF428 /* Main.storyboard */ = {
225-
isa = PBXVariantGroup;
226-
children = (
227-
E3A7F1E623F7DAD700CDF428 /* Base */,
228-
);
229-
name = Main.storyboard;
230-
sourceTree = "<group>";
231-
};
232-
/* End PBXVariantGroup section */
233-
234223
/* Begin XCBuildConfiguration section */
235224
E3A7F1EA23F7DAD700CDF428 /* Debug */ = {
236225
isa = XCBuildConfiguration;
@@ -283,7 +272,7 @@
283272
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
284273
GCC_WARN_UNUSED_FUNCTION = YES;
285274
GCC_WARN_UNUSED_VARIABLE = YES;
286-
MACOSX_DEPLOYMENT_TARGET = 10.15.5;
275+
MACOSX_DEPLOYMENT_TARGET = 11.3;
287276
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
288277
MTL_FAST_MATH = YES;
289278
ONLY_ACTIVE_ARCH = YES;
@@ -338,7 +327,7 @@
338327
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
339328
GCC_WARN_UNUSED_FUNCTION = YES;
340329
GCC_WARN_UNUSED_VARIABLE = YES;
341-
MACOSX_DEPLOYMENT_TARGET = 10.15.5;
330+
MACOSX_DEPLOYMENT_TARGET = 11.3;
342331
MTL_ENABLE_DEBUG_INFO = NO;
343332
MTL_FAST_MATH = YES;
344333
SDKROOT = macosx;
@@ -355,7 +344,7 @@
355344
CODE_SIGN_IDENTITY = "Apple Development";
356345
CODE_SIGN_STYLE = Automatic;
357346
COMBINE_HIDPI_IMAGES = YES;
358-
CURRENT_PROJECT_VERSION = 9;
347+
CURRENT_PROJECT_VERSION = 10;
359348
DEVELOPMENT_ASSET_PATHS = "\"Pasteboard Viewer/Preview Content\"";
360349
DEVELOPMENT_TEAM = YG56YK5RN5;
361350
ENABLE_HARDENED_RUNTIME = YES;
@@ -365,7 +354,7 @@
365354
"$(inherited)",
366355
"@executable_path/../Frameworks",
367356
);
368-
MARKETING_VERSION = 1.5.1;
357+
MARKETING_VERSION = 1.5.2;
369358
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Pasteboard-Viewer";
370359
PRODUCT_NAME = "$(TARGET_NAME)";
371360
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -381,7 +370,7 @@
381370
CODE_SIGN_IDENTITY = "Apple Development";
382371
CODE_SIGN_STYLE = Automatic;
383372
COMBINE_HIDPI_IMAGES = YES;
384-
CURRENT_PROJECT_VERSION = 9;
373+
CURRENT_PROJECT_VERSION = 10;
385374
DEVELOPMENT_ASSET_PATHS = "\"Pasteboard Viewer/Preview Content\"";
386375
DEVELOPMENT_TEAM = YG56YK5RN5;
387376
ENABLE_HARDENED_RUNTIME = YES;
@@ -391,7 +380,7 @@
391380
"$(inherited)",
392381
"@executable_path/../Frameworks",
393382
);
394-
MARKETING_VERSION = 1.5.1;
383+
MARKETING_VERSION = 1.5.2;
395384
PRODUCT_BUNDLE_IDENTIFIER = "com.sindresorhus.Pasteboard-Viewer";
396385
PRODUCT_NAME = "$(TARGET_NAME)";
397386
PROVISIONING_PROFILE_SPECIFIER = "";

Diff for: Pasteboard Viewer/App.swift

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import SwiftUI
2+
import Defaults
3+
4+
@main
5+
struct AppMain: App {
6+
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
7+
@StateObject private var appState = AppState()
8+
// TODO: `@Default` doesn't update the state in the menu. Probably a macOS 11 bug. (macOS 11.3)
9+
// @Default(.stayOnTop) private var stayOnTop
10+
@AppStorage(.stayOnTop) private var stayOnTop
11+
@State var window: NSWindow? // swiftlint:disable:this swiftui_state_private
12+
13+
var body: some Scene {
14+
WindowGroup {
15+
ContentView()
16+
.environmentObject(appState)
17+
.onAppear(perform: onAppear)
18+
.bindNativeWindow($window)
19+
.windowTabbingMode(.disallowed)
20+
.windowLevel(stayOnTop ? .floating : .normal)
21+
.eraseToAnyView() // This fixes an issue where the window size is not persisted. (macOS 11.3)
22+
}
23+
.commands {
24+
CommandGroup(replacing: .newItem) {}
25+
CommandGroup(after: .windowSize) {
26+
Toggle("Stay On Top", isOn: $stayOnTop)
27+
}
28+
CommandGroup(replacing: .help) {
29+
// TODO: `Link` doesn't yet work here. (macOS 11.3)
30+
// Link("Website", destination: "https://sindresorhus.com/pasteboard-viewer")
31+
Button("Website") {
32+
"https://sindresorhus.com/pasteboard-viewer".openUrl()
33+
}
34+
Button("Rate on the App Store") {
35+
"macappstore://apps.apple.com/app/id1499215709?action=write-review".openUrl()
36+
}
37+
Button("More Apps by Me") {
38+
"macappstore://apps.apple.com/developer/id328077650".openUrl()
39+
}
40+
Divider()
41+
Button("Send Feedback…") {
42+
SSApp.openSendFeedbackPage()
43+
}
44+
}
45+
}
46+
}
47+
48+
private func onAppear() {
49+
DispatchQueue.main.async {
50+
showWelcomeScreenIfNeeded()
51+
}
52+
}
53+
}
54+
55+
private final class AppDelegate: NSObject, NSApplicationDelegate {
56+
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
57+
}

Diff for: Pasteboard Viewer/AppDelegate.swift

-63
This file was deleted.

Diff for: Pasteboard Viewer/AppState.swift

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Combine
2+
import AppCenter
3+
import AppCenterCrashes
4+
5+
final class AppState: ObservableObject {
6+
init() {
7+
setUpConfig()
8+
}
9+
10+
private func setUpConfig() {
11+
UserDefaults.standard.register(
12+
defaults: [
13+
"NSApplicationCrashOnExceptions": true
14+
]
15+
)
16+
17+
AppCenter.start(
18+
withAppSecret: "3da13331-e82c-4245-b7fa-023424c17f16",
19+
services: [
20+
Crashes.self
21+
]
22+
)
23+
}
24+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

Diff for: Pasteboard Viewer/Assets.xcassets/Contents.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"info" : {
3-
"version" : 1,
4-
"author" : "xcode"
3+
"author" : "xcode",
4+
"version" : 1
55
}
6-
}
6+
}

0 commit comments

Comments
 (0)