fix(agent): correct LaunchAgent ProgramArguments path for SMAppService

SMAppService resolves ProgramArguments relative to the app bundle's
Contents/ directory, not the bundle root. The plist used
Contents/MacOS/ShadowsocksX-NG2Agent which resolved to a nonexistent
Contents/Contents/MacOS/... path, causing launchd to report
EX_CONFIG / spawn failed and the wrapper never started.

Change to MacOS/ShadowsocksX-NG2Agent so launchd finds the binary.
This commit is contained in:
Qiu Yuzhou
2026-09-26 23:04:26 +08:00
parent 973e8dd3b0
commit 354b0fb59e
3 changed files with 6 additions and 5 deletions
@@ -10,7 +10,8 @@ protocol LaunchAgentControlling {
}
/// 生产实现:plist 必须位于 app bundle `Contents/Library/LaunchAgents/`,
/// ProgramArguments 为 bundle 相对路径(launchd 按注册 app 的 bundle 解析)。
/// ProgramArguments 为 Contents/ 相对路径(launchd 按注册 app 的 Contents/
/// 解析)。
struct SMAppLaunchAgentService: LaunchAgentControlling {
static let plistName = "com.qiuyuzhou.ShadowsocksX-NG2.agent.plist"
@@ -11,7 +11,7 @@
<string>com.qiuyuzhou.ShadowsocksX-NG2.agent</string>
<key>ProgramArguments</key>
<array>
<string>Contents/MacOS/ShadowsocksX-NG2Agent</string>
<string>MacOS/ShadowsocksX-NG2Agent</string>
</array>
<key>ThrottleInterval</key>
<integer>2</integer>
+3 -3
View File
@@ -24,8 +24,8 @@ targets:
# 领域核心:配置目录树、凭据引用与持久化(spec #21 D3/D5)
- path: Domain
# LaunchAgent 注册清单:SMAppService.agent(plistName:) 从 bundle 内
# Contents/Library/LaunchAgents/ 读取;ProgramArguments 用 bundle 相对路径
# (spec #21 D2,issue #27)。
# Contents/Library/LaunchAgents/ 读取;ProgramArguments 用 Contents/
# 相对路径(launchd 按注册 app 的 Contents/ 解析,spec #21 D2,issue #27)。
- path: LaunchAgent/com.qiuyuzhou.ShadowsocksX-NG2.agent.plist
buildPhase:
copyFiles:
@@ -97,7 +97,7 @@ targets:
- ShadowsocksX-NG2Tests
dependencies:
# 代理运行时 wrapper(BundleProgram,spec #21 D2):以独立可执行文件装入
# Contents/MacOS,由 LaunchAgent plist 以 bundle 相对路径引用。
# Contents/MacOS,由 LaunchAgent plist 以 Contents/ 相对路径引用。
- target: ShadowsocksX-NG2Agent
copy:
destination: wrapper