Skip to content

Commit

Permalink
Merge branch 'feature/launch-agent-template' into hotfix/0.18.3
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Jun 23, 2023
2 parents 1bbf33f + 8245c31 commit 684cffe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Core/Sources/HostApp/LaunchAgentManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ extension LaunchAgentManager {
.appendingPathComponent(
"CopilotForXcodeExtensionService.app/Contents/MacOS/CopilotForXcodeExtensionService"
)
.path
.path,
bundleIdentifier: Bundle.main
.object(forInfoDictionaryKey: "BUNDLE_IDENTIFIER_BASE") as! String
)
}
}
10 changes: 9 additions & 1 deletion Core/Sources/LaunchAgentManager/LaunchAgentManager.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Foundation

#warning("TODO: Migrate to SMAppService")
public struct LaunchAgentManager {
let lastLaunchAgentVersionKey = "LastLaunchAgentVersion"
let serviceIdentifier: String
let executablePath: String
let bundleIdentifier: String

var launchAgentDirURL: URL {
FileManager.default.homeDirectoryForCurrentUser
Expand All @@ -14,9 +16,10 @@ public struct LaunchAgentManager {
launchAgentDirURL.appendingPathComponent("\(serviceIdentifier).plist").path
}

public init(serviceIdentifier: String, executablePath: String) {
public init(serviceIdentifier: String, executablePath: String, bundleIdentifier: String) {
self.serviceIdentifier = serviceIdentifier
self.executablePath = executablePath
self.bundleIdentifier = bundleIdentifier
}

public func setupLaunchAgentForTheFirstTimeIfNeeded() async throws {
Expand Down Expand Up @@ -44,6 +47,11 @@ public struct LaunchAgentManager {
<key>\(serviceIdentifier)</key>
<true/>
</dict>
<key>AssociatedBundleIdentifiers</key>
<array>
<string>\(bundleIdentifier)</string>
<string>\(serviceIdentifier)</string>
</array>
</dict>
</plist>
"""
Expand Down

0 comments on commit 684cffe

Please sign in to comment.