Skip to content

Commit 09824c1

Browse files
committed
Make XPC service start on demand
1 parent ac89238 commit 09824c1

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

EditorExtension/SourceEditorExtension.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Client
12
import Foundation
23
import XcodeKit
34

@@ -14,6 +15,20 @@ class SourceEditorExtension: NSObject, XCSourceEditorExtension {
1415
PrefetchSuggestionsCommand(),
1516
].map(makeCommandDefinition)
1617
}
18+
19+
func extensionDidFinishLaunching() {
20+
#if DEBUG
21+
// In a debug build, we usually want to use the XPC service run from Xcode.
22+
#else
23+
// When the source extension is initialized
24+
// we can call a random command to wake up the XPC service.
25+
Task.detached {
26+
try await Task.sleep(nanoseconds: 1_000_000_000)
27+
let service = try getService()
28+
_ = try await service.checkStatus()
29+
}
30+
#endif
31+
}
1732
}
1833

1934
private let identifierPrefix: String = Bundle.main.bundleIdentifier ?? ""

0 commit comments

Comments
 (0)