Skip to content

Commit df963bc

Browse files
committed
Fix: Use dynamic bin path resolution for SPM binaries
The formula was using hardcoded .build/release/ paths which don't resolve correctly in Homebrew's build sandbox. SPM places binaries in triple-specific directories (e.g. .build/arm64-apple-macosx/release/) and the symlink doesn't always work with Ruby's file operations. Now using 'swift build --show-bin-path' to dynamically resolve the correct binary location.
1 parent 41308ec commit df963bc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

Formula/wwk.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ def install
2929
"--disable-sandbox",
3030
"-Xswiftc", "-cross-module-optimization"
3131

32+
# Resolve the actual bin path — SPM may use a triple-specific directory
33+
# (e.g. .build/arm64-apple-macosx/release) and the .build/release symlink
34+
# does not always resolve correctly inside Homebrew's build sandbox.
35+
bin_path = Utils.safe_popen_read(
36+
"swift", "build", "--show-bin-path", "--configuration", "release"
37+
).chomp
38+
3239
# Install CLI and agent binaries
33-
bin.install ".build/release/wwk"
34-
bin.install ".build/release/wwkd"
40+
bin.install "#{bin_path}/wwk"
41+
bin.install "#{bin_path}/wwkd"
3542

3643
# Construct WellWhaddyaKnow.app bundle
3744
app_bundle = prefix/"WellWhaddyaKnow.app"
@@ -44,8 +51,8 @@ def install
4451
resources.mkpath
4552
la_dir.mkpath
4653

47-
cp ".build/release/WellWhaddyaKnow", macos_dir/"WellWhaddyaKnow"
48-
cp ".build/release/wwkd", macos_dir/"wwkd"
54+
cp "#{bin_path}/WellWhaddyaKnow", macos_dir/"WellWhaddyaKnow"
55+
cp "#{bin_path}/wwkd", macos_dir/"wwkd"
4956

5057
# Embed launchd plist (required for SMAppService)
5158
cp "Sources/WellWhaddyaKnowApp/LaunchAgents/com.daylily.wellwhaddyaknow.agent.plist",
@@ -60,7 +67,7 @@ def install
6067
cp "Sources/WellWhaddyaKnowApp/PrivacyInfo.xcprivacy", resources/"PrivacyInfo.xcprivacy"
6168
(contents/"PkgInfo").write("APPL????")
6269

63-
# Ad-hoc codesign (inner outer)
70+
# Ad-hoc codesign (inner then outer)
6471
system "codesign", "--force", "--sign", "-",
6572
"-i", "com.daylily.wellwhaddyaknow.agent",
6673
macos_dir/"wwkd"
@@ -100,4 +107,3 @@ def caveats
100107
assert_match "gui", shell_output("#{bin}/wwk --help")
101108
end
102109
end
103-

0 commit comments

Comments
 (0)