You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DEVELOPMENT.md
+19-12Lines changed: 19 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,37 +4,44 @@
4
4
5
5
### Copilot for Xcode
6
6
7
-
Copilot for Xcode is the app containing both the XPCService and the editor extension.
7
+
Copilot for Xcode is the host app containing both the XPCService and the editor extension.
8
8
9
9
### EditorExtension
10
10
11
-
As its name suggests, the editor extension. Since an editor extension must be sandboxed, it will need to talk to a trusted non-sandboxed XPCService to break out the limitations. The identifier of the XPCService must be listed under `com.apple.security.temporary-exception.mach-lookup.global-name` in entitlements.
11
+
As its name suggests, the editor extension. Its sole purpose is to forward editor content to the XPCService for processing, and update the editor with the returned content. Due to the sandboxing requirements for editor extensions, it has to communicate with a trusted, non-sandboxed XPCService to bypass the limitations. The XPCService identifier must be included in the `com.apple.security.temporary-exception.mach-lookup.global-name` entitlements.
12
12
13
13
### ExtensionService
14
14
15
-
The ExtensionService is a program that runs in the background and does basically everything. It redirects the requests from EditorExtension to `CopilotService` and returns the updated code back to the extension.
15
+
The `ExtensionService` is a program that operates in the background and performs a wide range of tasks. It redirects requests from the `EditorExtension` to the `CopilotService` and returns the updated code back to the extension, or presents it in a GUI outside of Xcode.
16
16
17
-
Since the Xcode source editor extension only allows its commands to be triggered manually, the ExtensionService has to use Apple Scripts to trigger the menu items to generate real-time suggestions.
17
+
### Core
18
18
19
-
The ExtensionService is also using a lot of Apple Script tricks to get the file paths and project/workspace paths of the active Xcode window because Xcode is not providing this information.
19
+
Most of the logics are implemented inside the package `Core`.
20
+
21
+
- The `CopilotService` is responsible for communicating with the GitHub Copilot LSP.
22
+
- The `Service` is responsible for handling the requests from the `EditorExtension`, communicating with the `CopilotService`, update the code blocks and present the GUI.
23
+
- The `Client` is basically just a wrapper around the XPCService
24
+
- The `SuggestionInjector` is responsible for injecting the suggestions into the code. Used in comment mode to present the suggestions, and all modes to accept suggestions.
25
+
- The `Environment` contains some swappable global functions. It is used to make testing easier.
26
+
- The `SuggestionWidget` is responsible for presenting the suggestions in floating widget mode.
20
27
21
28
## Building and Archiving the App
22
29
23
-
Firstly, create a `Secrets.xcconfig`next to the others. You can provide a `GITHUB_TOKEN` here if you want to check for updates.
30
+
To get started, create a `Secrets.xcconfig`file at the root directory. You can use the `Secrets.sample.xcconfig` as a reference.
24
31
25
-
This project contains a Git submodule `copilot.vim`, so you will have to initialize the submodule or download it from [copilot.vim](https://github.com/github/copilot.vim).
32
+
This project includes a Git submodule,`copilot.vim`, so you will need to either initialize the submodule or download it from the [copilot.vim](https://github.com/github/copilot.vim) repository.
26
33
27
-
Then archive the target Copilot for Xcode.
34
+
Finally, archive the Copilot for Xcode target.
28
35
29
36
## Testing Extension
30
37
31
-
### Testing Real-time Suggestions Commands
38
+
Just run both the `ExtensionService` and the `EditorExtension` Target.
32
39
33
-
Testing Real-time Suggestions is a little bit different because the Apple Script can't find the commands when debugging the extension in Xcode. Instead, you will have to archive the debug version of the app, run the XPCService target simultaneously and use them against each other.
40
+
## Unit Tests
34
41
35
-
### Testing Other Commands
42
+
To run unit tests, just run test from the `Copilot for Xcode` target.
36
43
37
-
Just run both the XPCService and the EditorExtension Target.
44
+
For new tests, they should be added to the `TestPlan.xctestplan`.
Copy file name to clipboardExpand all lines: README.md
+6-13Lines changed: 6 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,9 @@ Thanks to [LSP-copilot](https://github.com/TerminalFi/LSP-copilot) for showing t
22
22
-[Limitations](#limitations)
23
23
-[FAQ](#faq)
24
24
-[License](#license)
25
-
-[Development](DEVELOPMENT.md)
25
+
26
+
27
+
For development instruction, check [Development.md](DEVELOPMENT.md).
26
28
27
29
## Prerequisites
28
30
@@ -32,15 +34,10 @@ Thanks to [LSP-copilot](https://github.com/TerminalFi/LSP-copilot) for showing t
32
34
33
35
## Permissions Required
34
36
35
-
- Accessibility API
36
37
- Folder Access
37
-
-Input Monitoring (for real-time suggestions cancellation by pressing esc, arrow keys or clicking the mouse)
38
+
-Accessibility API
38
39
39
-
> You no longer require Input Monitoring to utilize real-time suggestions with version 0.8.1+. If you do not need the cancellation feature, you can simply ignore this permission.
40
-
>
41
-
> However, to be frank, the Accessibility API is more dangerous than Input Monitoring. To remove the need for Input Monitoring, we can simply change the `CGEventTapOptions` from `listenOnly` to `defaultTap`, which allows for input manipulation.
42
-
>
43
-
> If you are concerned about key logging and cannot trust the binary, we recommend examining the code and building it yourself. To address any concerns, you can specifically search for `CGEvent.tapCreate`, `AXObserver`, `AX___` within the code.
40
+
> If you are concerned about key logging and cannot trust the binary, we recommend examining the code and [building it yourself](DEVELOPMENT.md). To address any concerns, you can specifically search for `CGEvent.tapCreate`, `AXObserver`, `AX___` within the code.
44
41
45
42
## Installation and Setup
46
43
@@ -72,18 +69,14 @@ Then set it up with the following steps:
72
69
73
70
### Granting Permissions to the App
74
71
75
-
The first time the app is open and command run, the extension will ask for the necessary permissions. (except Input Monitoring, you have to enable it manually)
72
+
The first time the app is open and command run, the extension will ask for the necessary permissions.
76
73
77
74
Alternatively, you may manually grant the required permissions by navigating to the `Privacy & Security` tab in the `System Settings.app`.
78
75
79
76
- To grant permissions for the Accessibility API, click `Accessibility`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
- To enable Input Monitoring (for real-time suggestions cancellation by pressing esc, arrow keys or clicking the mouse), click `Input Monitoring`, and drag `CopilotForXcodeExtensionService.app` to the list. You can locate the extension app by clicking `Reveal Extension App in Finder` in the host app.
If you encounter an alert requesting permission that you have previously granted, please remove the permission from the list and add it again to re-grant the necessary permissions.
0 commit comments