File tree Expand file tree Collapse file tree 11 files changed +492
-0
lines changed
Copilot for Xcode.xcodeproj
Preview Content/Preview Assets.xcassets Expand file tree Collapse file tree 11 files changed +492
-0
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
2+ import Logger
3+ import XPCShared
4+
5+ class ServiceDelegate : NSObject , NSXPCListenerDelegate {
6+ func listener(
7+ _: NSXPCListener ,
8+ shouldAcceptNewConnection newConnection: NSXPCConnection
9+ ) -> Bool {
10+ newConnection. exportedInterface = NSXPCInterface (
11+ with: CommunicationBridgeXPCServiceProtocol . self
12+ )
13+
14+ let exportedObject = XPCService ( )
15+ newConnection. exportedObject = exportedObject
16+ newConnection. resume ( )
17+
18+ Logger . temp. debug ( " Accepted new connection. " )
19+
20+ return true
21+ }
22+ }
23+
24+ class XPCService : CommunicationBridgeXPCServiceProtocol {
25+ static var endpoint : NSXPCListenerEndpoint ?
26+
27+ func launchExtensionServiceIfNeeded(
28+ withReply reply: @escaping ( NSXPCListenerEndpoint ? ) -> Void
29+ ) {
30+ #if DEBUG
31+ reply ( Self . endpoint)
32+ #else
33+ // launch the app
34+ reply ( endpoint)
35+ #endif
36+ }
37+
38+ func quit( withReply reply: ( ) -> Void ) {
39+ listener. invalidate ( )
40+ exit ( 0 )
41+ }
42+
43+ func updateServiceEndpoint( endpoint: NSXPCListenerEndpoint , withReply reply: ( ) -> Void ) {
44+ Self . endpoint = endpoint
45+ reply ( )
46+ }
47+ }
48+
Original file line number Diff line number Diff line change 1+ import Foundation
2+
3+ let bundleIdentifierBase = Bundle ( url: Bundle . main. bundleURL. appendingPathComponent (
4+ " CopilotForXcodeExtensionService.app "
5+ ) ) ? . object ( forInfoDictionaryKey: " BUNDLE_IDENTIFIER_BASE " ) as? String ?? " com.intii.CopilotForXcode "
6+
7+ let serviceIdentifier = bundleIdentifierBase + " .CommunicationBridge "
8+
9+ let delegate = ServiceDelegate ( )
10+ let listener = NSXPCListener ( machServiceName: serviceIdentifier)
11+ listener. delegate = delegate
12+ listener. resume ( )
13+ RunLoop . main. run ( )
14+
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ {
2+ "colors" : [
3+ {
4+ "idiom" : " universal"
5+ }
6+ ],
7+ "info" : {
8+ "author" : " xcode" ,
9+ "version" : 1
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ {
2+ "images" : [
3+ {
4+ "idiom" : " mac" ,
5+ "scale" : " 1x" ,
6+ "size" : " 16x16"
7+ },
8+ {
9+ "idiom" : " mac" ,
10+ "scale" : " 2x" ,
11+ "size" : " 16x16"
12+ },
13+ {
14+ "idiom" : " mac" ,
15+ "scale" : " 1x" ,
16+ "size" : " 32x32"
17+ },
18+ {
19+ "idiom" : " mac" ,
20+ "scale" : " 2x" ,
21+ "size" : " 32x32"
22+ },
23+ {
24+ "idiom" : " mac" ,
25+ "scale" : " 1x" ,
26+ "size" : " 128x128"
27+ },
28+ {
29+ "idiom" : " mac" ,
30+ "scale" : " 2x" ,
31+ "size" : " 128x128"
32+ },
33+ {
34+ "idiom" : " mac" ,
35+ "scale" : " 1x" ,
36+ "size" : " 256x256"
37+ },
38+ {
39+ "idiom" : " mac" ,
40+ "scale" : " 2x" ,
41+ "size" : " 256x256"
42+ },
43+ {
44+ "idiom" : " mac" ,
45+ "scale" : " 1x" ,
46+ "size" : " 512x512"
47+ },
48+ {
49+ "idiom" : " mac" ,
50+ "scale" : " 2x" ,
51+ "size" : " 512x512"
52+ }
53+ ],
54+ "info" : {
55+ "author" : " xcode" ,
56+ "version" : 1
57+ }
58+ }
Original file line number Diff line number Diff line change 1+ {
2+ "info" : {
3+ "author" : " xcode" ,
4+ "version" : 1
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ import SwiftUI
2+ import Client
3+
4+ struct ContentView : View {
5+ @State var text : String = " Hello, world! "
6+ var body : some View {
7+ VStack {
8+ Button ( action: {
9+ Task {
10+ do {
11+ let service = try getService ( )
12+ let version = try await service. getXPCServiceVersion ( )
13+ text = " Version: \( version. version) Build: \( version. build) "
14+ } catch {
15+ text = error. localizedDescription
16+ }
17+ }
18+ } ) {
19+ Text ( " Test " )
20+ }
21+ Text ( text)
22+ }
23+ . padding ( )
24+ }
25+ }
26+
27+ #Preview {
28+ ContentView ( )
29+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+ <plist version =" 1.0" >
4+ <dict >
5+ <key >BUNDLE_IDENTIFIER_BASE </key >
6+ <string >$(BUNDLE_IDENTIFIER_BASE) </string >
7+ </dict >
8+ </plist >
Original file line number Diff line number Diff line change 1+ {
2+ "info" : {
3+ "author" : " xcode" ,
4+ "version" : 1
5+ }
6+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+ <plist version =" 1.0" >
4+ <dict >
5+ <key >com.apple.security.app-sandbox</key >
6+ <true />
7+ <key >com.apple.security.files.user-selected.read-only</key >
8+ <true />
9+ <key >com.apple.security.temporary-exception.mach-lookup.global-name</key >
10+ <array >
11+ <string >$(BUNDLE_IDENTIFIER_BASE).CommunicationBridge</string >
12+ </array >
13+ </dict >
14+ </plist >
You can’t perform that action at this time.
0 commit comments