Copilot for Xcode is the host app containing both the XPCService and the editor extension. It provides the settings UI.
As its name suggests, the Xcode source 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 (CommunicationBridge and ExtensionService) to bypass the limitations. The XPCService service name must be included in the com.apple.security.temporary-exception.mach-lookup.global-name entitlements.
The ExtensionService is a program that operates in the background. All features are implemented in this target.
It's responsible for maintaining the communication between the Copilot for Xcode/EditorExtension and ExtensionService.
Most of the logics are implemented inside the package Core and Tool.
- The
Servicecontains the implementations of the ExtensionService target. - The
HostAppcontains the implementations of the Copilot for Xcode target.
- Update the xcconfig files, bridgeLaunchAgent.plist, and Tool/Configs/Configurations.swift.
- Build or archive the Copilot for Xcode target.
Just run both the ExtensionService, CommunicationBridge and the EditorExtension Target. Read Testing Your Source Editor Extension for more details.
If you are not testing the source editor extension, it's recommended to archive and install a debug version of the Copilot for Xcode and test with the bundled source editor extension.
Looks like SwiftUI Previews are not very happy with Objective-C packages when running with app targets. To use previews, please switch schemes to the package product targets.
To run unit tests, just run test from the Copilot for Xcode target.
For new tests, they should be added to the TestPlan.xctestplan.
To create a chat plugin, please use the TerminalChatPlugin as an example. You should add your plugin to the target ChatPlugin and register it in ChatService.
We use SwiftFormat to format the code.
The source code mostly follows the Ray Wenderlich Style Guide very closely with the following exception:
- Use the Xcode default of 4 spaces for indentation.
The app version and all targets' version in controlled by Version.xcconfig.