Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ This can be used to feed a SwiftUI List or UITableView dataSource in your app.
2. Add the following as a Run Script for your target in Xcode

```sh
DIR=$PROJECT_TEMP_DIR/../../../SourcePackages/checkouts/AckGen
# Calculate the package path dynamically (handles "Build" in usernames/project paths)
BASE_DIR="${PROJECT_TEMP_DIR%/Build/*}"
DIR="$BASE_DIR/SourcePackages/checkouts/AckGen"

if [ -d "$DIR" ]; then
cd $DIR
SDKROOT=(xcrun --sdk macosx --show-sdk-path)
cd "$DIR"
SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
swift run ackgen
Comment on lines +34 to 35

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this shell snippet SDKROOT=$(...) only sets a shell variable; it is not exported, so swift run ackgen will not see SDKROOT in its environment. If the intent is to force the macOS SDK for the child process, export it (or set it inline on the swift run invocation); otherwise consider removing the line to avoid implying it has an effect.

Suggested change
SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
swift run ackgen
SDKROOT=$(xcrun --sdk macosx --show-sdk-path) swift run ackgen

Copilot uses AI. Check for mistakes.
else
echo "warning: AckGen not found. Please install the package via SPM (https://github.com/MartinP7r/AckGen#installation)"
Expand Down
8 changes: 7 additions & 1 deletion Sources/AckGenCLI/AckGen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ struct AckGen: ParsableCommand {

let plistPath: String = output ?? "\(srcRoot)/Acknowledgements.plist"

let packageCachePath = tempDirPath.components(separatedBy: "/Build/")[0] + "/SourcePackages/checkouts"
// Find the last occurrence of "/Build/" to handle edge cases like "Build" in username
let packageCachePath: String
if let range = tempDirPath.range(of: "/Build/", options: .backwards) {
packageCachePath = String(tempDirPath[..<range.lowerBound]) + "/SourcePackages/checkouts"
} else {
packageCachePath = tempDirPath.components(separatedBy: "/Build/")[0] + "/SourcePackages/checkouts"
}
Comment on lines +43 to +48

Copilot AI Mar 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else branch is redundant and keeps the old components(separatedBy: "/Build/")[0] logic around (which is the behavior this PR is trying to move away from). If "/Build/" isn't present, components(...)[0] is just tempDirPath anyway, so this can be simplified to make the intent clearer (e.g., use tempDirPath directly or compute a basePath once and append /SourcePackages/checkouts).

Suggested change
let packageCachePath: String
if let range = tempDirPath.range(of: "/Build/", options: .backwards) {
packageCachePath = String(tempDirPath[..<range.lowerBound]) + "/SourcePackages/checkouts"
} else {
packageCachePath = tempDirPath.components(separatedBy: "/Build/")[0] + "/SourcePackages/checkouts"
}
let basePath: String
if let range = tempDirPath.range(of: "/Build/", options: .backwards) {
basePath = String(tempDirPath[..<range.lowerBound])
} else {
basePath = tempDirPath
}
let packageCachePath = basePath + "/SourcePackages/checkouts"

Copilot uses AI. Check for mistakes.
let fman = FileManager.default

let packageDirectories = try fman.contentsOfDirectory(atPath: packageCachePath)
Expand Down