Skip to content

Commit f27c3a1

Browse files
committed
Fix that launch agent manager was not installed on launch
1 parent 5497253 commit f27c3a1

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
C87B03AC293B2CF300C77EAE /* XcodeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C81458902939EFDC00135263 /* XcodeKit.framework */; };
4040
C87B03AD293B2CF300C77EAE /* XcodeKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C81458902939EFDC00135263 /* XcodeKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
4141
C882175C294187EF00A22FD3 /* Client in Frameworks */ = {isa = PBXBuildFile; productRef = C882175B294187EF00A22FD3 /* Client */; };
42+
C89A37162A12728200BE3C16 /* LaunchAgentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89A37152A12728200BE3C16 /* LaunchAgentManager.swift */; };
4243
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4344
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */; };
4445
/* End PBXBuildFile section */
@@ -176,6 +177,7 @@
176177
C87B03A8293B262600C77EAE /* NextSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NextSuggestionCommand.swift; sourceTree = "<group>"; };
177178
C87B03AA293B262E00C77EAE /* PreviousSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviousSuggestionCommand.swift; sourceTree = "<group>"; };
178179
C887BC832965D96000931567 /* DEVELOPMENT.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = DEVELOPMENT.md; sourceTree = "<group>"; };
180+
C89A37152A12728200BE3C16 /* LaunchAgentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAgentManager.swift; sourceTree = "<group>"; };
179181
C8CD828229B88006008D044D /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
180182
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatWithSelection.swift; sourceTree = "<group>"; };
181183
/* End PBXFileReference section */
@@ -286,6 +288,7 @@
286288
children = (
287289
C87B03A3293B24AB00C77EAE /* Copilot-for-Xcode-Info.plist */,
288290
C8189B192938972F00C9DCDA /* App.swift */,
291+
C89A37152A12728200BE3C16 /* LaunchAgentManager.swift */,
289292
C8189B1D2938973000C9DCDA /* Assets.xcassets */,
290293
C8189B222938973000C9DCDA /* Copilot_for_Xcode.entitlements */,
291294
C8189B1F2938973000C9DCDA /* Preview Content */,
@@ -516,6 +519,7 @@
516519
isa = PBXSourcesBuildPhase;
517520
buildActionMask = 2147483647;
518521
files = (
522+
C89A37162A12728200BE3C16 /* LaunchAgentManager.swift in Sources */,
519523
C8189B1A2938972F00C9DCDA /* App.swift in Sources */,
520524
);
521525
runOnlyForDeploymentPostprocessing = 0;

Copilot for Xcode/App.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Client
2+
import HostApp
3+
import LaunchAgentManager
24
import SwiftUI
35
import UpdateChecker
46
import XPCShared
5-
import HostApp
67

78
@main
89
struct CopilotForXcodeApp: App {
@@ -14,8 +15,23 @@ struct CopilotForXcodeApp: App {
1415
UserDefaults.setupDefaultSettings()
1516
}
1617
.environment(\.updateChecker, UpdateChecker(hostBundle: Bundle.main))
18+
.onAppear {
19+
#if DEBUG
20+
// do not auto install on debug build
21+
#else
22+
Task {
23+
do {
24+
try await LaunchAgentManager()
25+
.setupLaunchAgentForTheFirstTimeIfNeeded()
26+
} catch {
27+
errorMessage = error.localizedDescription
28+
}
29+
}
30+
#endif
31+
}
1732
}
1833
}
1934
}
2035

2136
var isPreview: Bool { ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" }
37+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Foundation
2+
import LaunchAgentManager
3+
4+
extension LaunchAgentManager {
5+
init() {
6+
self.init(
7+
serviceIdentifier: Bundle.main
8+
.object(forInfoDictionaryKey: "BUNDLE_IDENTIFIER_BASE") as! String +
9+
".ExtensionService",
10+
executablePath: Bundle.main.bundleURL
11+
.appendingPathComponent("Contents")
12+
.appendingPathComponent("Applications")
13+
.appendingPathComponent(
14+
"CopilotForXcodeExtensionService.app/Contents/MacOS/CopilotForXcodeExtensionService"
15+
)
16+
.path
17+
)
18+
}
19+
}

0 commit comments

Comments
 (0)