feat(cli): Add SE-0162 support for custom SPM target layouts#8191
feat(cli): Add SE-0162 support for custom SPM target layouts#8191fortmarek merged 12 commits intotuist:mainfrom
Conversation
- Add test for Test targets with custom layout - Add test for alternative source directories (Source/, src/) - Add test for empty Sources directory fallback to standard layout
- Add reference to SPM's SupportedLanguageExtension.swift - Add TODO for potential assembly extensions support
042385a to
a6ca7e0
Compare
a6ca7e0 to
3d83784
Compare
fortmarek
left a comment
There was a problem hiding this comment.
Thanks! A couple of minor comments 🙂
- Support packages with sources directly in Sources/ without subdirectories. - Refactor basePath to use single-loop verification with early return.
- Extract hasSourceFiles as private method - Consolidate layout detection into single loop with early returns - Simplify directory selection with ternary operator
- Consolidate SE-0162 tests into PackageInfoMapperTests - Remove redundant PackageInfoMapperCustomLayoutTests file - Eliminate duplicate test coverage already handled by existing tests
|
Thank you for the review @fortmarek 👍 I refactored the layout validation logic that previously checked standard layout and SE-0162 separately (traversing directories twice) into a single loop that validates all layouts. Additionally, I replaced the unnecessary Task creation overhead from |
fortmarek
left a comment
There was a problem hiding this comment.
We can make the globbing slightly more performant. Also, don't forget to run mise run lint --fix when you push, so the lint check can pass 😌
- Rename 'dir' to 'directory' for better readability - Use backticks for 'extension' to avoid Swift keyword conflict
1b34d35 to
a1b87f3
Compare
- Replace 7 individual glob operations with one using brace expansion - Follows existing pattern used in line 901 for consistency - Improves performance for SE-0162 source file detection https://github.com/tuist/tuist/blob/main/cli/Sources/TuistLoader/SwiftPackageManager/PackageInfoMapper.swift#L901
a1b87f3 to
a1a2ef9
Compare
|
Thank you for your time @fortmarek 😄
Regarding the lint error I ran mise run lint.sh --fix
[lint.sh] $ ~/Desktop/tuist/mise/tasks/lint.sh --fix
[cli:lint] $ ~/Desktop/tuist/mise/tasks/cli/lint.sh --fix
Running SwiftFormat...
Reading config file at /Users/devyhan93/Desktop/tuist/.swiftformat
SwiftFormat completed in 0.76s.
0/2239 files formatted, 30 files skipped.CI-Lint Job Error: About Test Failures I noticed that the CI tests are failing specifically for registry-based packages while Git-based SPM packages pass
Could this be related to registry package handling or CI environment configuration? I'd appreciate your insights on whether these test failures are expected or if there's something I should address. |
|
The lint job error was failing on |
|
Thanks again for your contribution! |
Co-authored-by: Marek Fořt <[email protected]>
Resolves #8185, xcodebuild-nvim-preview/#3
Fixes the "Default source path not found" error when using SPM packages that have source files directly in the
Sources/directory instead ofSources/TargetName/.This implements support for SPM's flexible source discovery mechanism which allows packages like
xcodebuild-nvim-previewto place source files directly inSources/.The fix modifies
PackageInfoMapper.basePath(packageFolder:)to first check for the standardSources/TargetName/layout, then fall back to checking for source files directly inSources/as per SPM's auto-discovery rules.How to test locally
tuist installtuist generate