Skip to content

Commit eec1adf

Browse files
committed
Add restart XPC service button
1 parent 1db021a commit eec1adf

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

Copilot for Xcode/LaunchAgentManager.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ struct LaunchAgentManager {
5858
launchctl("unload", launchAgentPath)
5959
try FileManager.default.removeItem(atPath: launchAgentPath)
6060
}
61+
62+
func restartLaunchAgent() {
63+
launchctl("unload", launchAgentPath)
64+
launchctl("load", launchAgentPath)
65+
}
6166
}
6267

6368
private func launchctl(_ args: String...) {

Copilot for Xcode/LaunchAgentView.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ struct LaunchAgentView: View {
44
@State var errorMessage: String?
55
@State var isDidRemoveLaunchAgentAlertPresented = false
66
@State var isDidSetupLaunchAgentAlertPresented = false
7-
7+
@State var isDidRestartLaunchAgentAlertPresented = false
8+
89
var body: some View {
910
Section {
1011
HStack {
@@ -45,6 +46,18 @@ struct LaunchAgentView: View {
4546
)
4647
}
4748

49+
Button(action: {
50+
LaunchAgentManager().restartLaunchAgent()
51+
isDidRestartLaunchAgentAlertPresented = true
52+
}) {
53+
Text("Restart XPC Service")
54+
}.alert(isPresented: $isDidRestartLaunchAgentAlertPresented) {
55+
.init(
56+
title: Text("Launch Agent Restarted"),
57+
dismissButton: .default(Text("OK"))
58+
)
59+
}
60+
4861
EmptyView()
4962
.alert(isPresented: .init(
5063
get: { errorMessage != nil },

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ fi
8484

8585
> A: Check the list in `Settings.app > Privacy & Security > Accessibility`. Turn the toggle on for `Copilot for Xcode`. If it's not on the list, add it manually.
8686
>
87-
> If you have just **updated the app**, consider reloading XPCService in app or trying removing the Launch Agents and set it up again!
87+
> If you have just **updated the app**, consider restarting XPCService in app or trying removing the Launch Agents and set it up again!
8888
8989
**Q: I turned on realtime suggestions, but nothing happens**
9090

91-
> A: Check the list in `Settings.app > Privacy & Security > Input Monitoring`. Turn the toggle on for `Copilot for Xcode`. If it's not on the list, add it manually. After that, you may have to reload the XPC Service.
91+
> A: Check the list in `Settings.app > Privacy & Security > Input Monitoring`. Turn the toggle on for `Copilot for Xcode`. If it's not on the list, add it manually. After that, you may have to restart the XPC Service.
9292
9393
**Q: Will it work in future Xcode updates?**
9494

0 commit comments

Comments
 (0)