@@ -23,28 +23,29 @@ def install
2323 }
2424 SWIFT
2525
26- # Swift 6 / new build system only outputs the product you ask for.
27- # Build each executable product explicitly so all three land in the
28- # bin-path directory.
26+ # Swift 6 / new build system replaces the output binary on each
27+ # --product build. Build each product and immediately stage it
28+ # before the next build overwrites the output directory.
2929 swift_flags = %w[
3030 --configuration release
3131 --disable-sandbox
3232 -Xswiftc -cross-module-optimization
3333 ]
34- system "swift" , "build" , *swift_flags , "--product" , "wwk"
35- system "swift" , "build" , *swift_flags , "--product" , "wwkd"
36- system "swift" , "build" , *swift_flags , "--product" , "WellWhaddyaKnow"
3734
38- # Resolve the actual bin path — SPM may use a triple-specific directory
39- # (e.g. .build/arm64-apple-macosx/release) and the .build/release symlink
40- # does not always resolve correctly inside Homebrew's build sandbox.
41- bin_path = Utils . safe_popen_read (
42- "swift" , "build" , "--show-bin-path" , "--configuration" , "release"
43- ) . chomp
35+ staging = buildpath /"staged_binaries"
36+ staging . mkpath
37+
38+ %w[ wwk wwkd WellWhaddyaKnow ] . each do |product |
39+ system "swift" , "build" , *swift_flags , "--product" , product
40+ bp = Utils . safe_popen_read (
41+ "swift" , "build" , "--show-bin-path" , "--configuration" , "release"
42+ ) . chomp
43+ cp "#{ bp } /#{ product } " , staging /product
44+ end
4445
4546 # Install CLI and agent binaries
46- bin . install " #{ bin_path } / wwk"
47- bin . install " #{ bin_path } / wwkd"
47+ bin . install staging / " wwk"
48+ bin . install staging / " wwkd"
4849
4950 # Construct WellWhaddyaKnow.app bundle
5051 app_bundle = prefix /"WellWhaddyaKnow.app"
@@ -57,8 +58,8 @@ def install
5758 resources . mkpath
5859 la_dir . mkpath
5960
60- cp " #{ bin_path } / WellWhaddyaKnow", macos_dir /"WellWhaddyaKnow"
61- cp " #{ bin_path } / wwkd", macos_dir /"wwkd"
61+ cp staging / " WellWhaddyaKnow", macos_dir /"WellWhaddyaKnow"
62+ cp staging / " wwkd", macos_dir /"wwkd"
6263
6364 # Embed launchd plist (required for SMAppService)
6465 cp "Sources/WellWhaddyaKnowApp/LaunchAgents/com.daylily.wellwhaddyaknow.agent.plist" ,
0 commit comments