Skip to content

Commit 13cec0a

Browse files
committed
1. Makefile: Added codesign --force --sign - to ad-hoc sign the app bundle —
SMAppService.mainApp.register() requires a signed app to work 2. SettingsView: Added error message display so if registration still fails (e.g., app not in /Applications), the user sees why instead of the toggle silently reverting
1 parent 9a8460e commit 13cec0a

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ app: build
2626
/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$(APP_BUNDLE)/Contents/Info.plist" 2>/dev/null || true
2727
/usr/libexec/PlistBuddy -c "Add :CFBundleIconFile string '$(APP_NAME)'" "$(APP_BUNDLE)/Contents/Info.plist" 2>/dev/null || true
2828
/usr/libexec/PlistBuddy -c "Set :CFBundleIconFile '$(APP_NAME)'" "$(APP_BUNDLE)/Contents/Info.plist"
29+
codesign --force --sign - "$(APP_BUNDLE)"
2930

3031
dmg: app
3132
rm -f $(DMG_NAME)

Sources/DNSSwitcher/UI/SettingsView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ struct SettingsView: View {
77
@State private var editingProfile: DnsProfile?
88
@State private var showingEditor = false
99
@State private var launchAtLogin = SMAppService.mainApp.status == .enabled
10+
@State private var loginItemError: String?
1011

1112
var body: some View {
1213
VStack(spacing: 0) {
@@ -70,10 +71,18 @@ struct SettingsView: View {
7071
} else {
7172
try SMAppService.mainApp.unregister()
7273
}
74+
loginItemError = nil
7375
} catch {
7476
launchAtLogin = !newValue
77+
loginItemError = error.localizedDescription
7578
}
7679
}
80+
81+
if let loginItemError {
82+
Text(loginItemError)
83+
.font(.caption)
84+
.foregroundColor(.red)
85+
}
7786
}
7887
.padding()
7988
}

0 commit comments

Comments
 (0)