- https://swift.org/package-manager/
- https://swift.org/documentation/cxx-interop/project-build-setup/
- https://developer.apple.com/documentation/swift_packages
- https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc
- https://learn.microsoft.com/en-us/vcpkg/consume/manifest-mode
- https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
- https://github.com/realm/SwiftLint
scripts/setup-metal-cpp.ps1 -Folder "externals" -FileName "metal-cpp_macOS15_iOS18.zip"swift build --build-tests swift build --configuration debug --target Baguettexcodebuild -showsdksxcodebuild -list -workspace .xcodebuild -workspace . -scheme "Baguette-Package" -showdestinationsxcodebuild -workspace . -scheme "Baguette-Package" \ -destination "generic/platform=macOS" \ -derivedDataPath DerivedData \ -configuration Debug \ buildexport VCPKG_FEATURE_FLAGS="manifests" export VCPKG_ROOT="$HOME/../vcpkg"cmake --preset x64-osx cmake --build --preset x64-osx-debugswift test --list-tests swift test --enable-code-coveragexcodebuild -workspace . -scheme "Baguette-Package" \ -destination "platform=macOS" \ -derivedDataPath DerivedData \ -enableCodeCoverage YES \ testcmake --build --preset x64-osx-debug --target baguette_test ctest --preset x64-osx-debug- https://docs.sonarqube.org/latest/analyzing-source-code/analysis-parameters/
- https://docs.sonarcloud.io/enriching/test-coverage/test-coverage-parameters/
- https://medium.com/xcblog/xccov-xcode-code-coverage-report-for-humans-466a4865aa18
If you used Swift Package Manager to build/test, the path can be used with configuration name.
llvm-cov export --format lcov -instr-profile .build/debug/codecov/default.profdata .build/debug/BaguettePackageTests.xctest/Contents/MacOS/BaguettePackageTests > lcov.infoXcodebuild will generate more complicated output path.
profdata_path=$(find "DerivedData/Build/ProfileData" -name "Coverage.profdata" | head -n 1) xctest_path="DerivedData/Build/Products/Debug/BaguetteBridgeTests.xctest/Contents/MacOS/BaguetteBridgeTests" llvm-cov export -format lcov -instr-profile "$profdata_path" "$xctest_path" > lcov.info$profdata_path = Get-ChildItem -File -Path "DerivedData/Build/ProfileData" -Recurse -Filter "Coverage.profdata" $xctest_path = "./DerivedData/Build/Products/Debug/BaguetteBridgeTests.xctest/Contents/MacOS/BaguetteBridgeTests" llvm-cov export -format lcov -instr-profile "$profdata_path" "$xctest_path" > lcov.infoFrom the generated lcov.info, you can remove unnecessary files.
lcov --remove lcov.info "test/" \ --output-file lcov-changed.info lcov --remove lcov-changed.info "externals/" \ --output-file lcov-changed.info --ignore-errors unusedlcov --list lcov-changed.infoFrom the file, you can generate HTML report.
genhtml lcov.info --output-directory docs open docs/index.htmlUse xcrun to generate coverage report.
xcrun --run llvm-cov show -instr-profile=$profdata_path $xctest_path > docs/coverage.reportxcresult_path=$(find DerivedData/Logs/Test/ -maxdepth 1 -name "Test*.xcresult" | head -n 1)$xcresult_path = Get-ChildItem -Directory -Filter "DerivedData/Logs/Test/Test*.xcresult" | Select-Object -First 1xcrun xccov view --report "$xcresult_path"xcrun xccov view --report --json $xcresult_path | jqNew-Item -Type Directory -Name "scripts" -Force Invoke-WebRequest -Uri "https://raw.githubusercontent.com/SonarSource/sonar-scanning-examples/master/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh" -OutFile "scripts/xccov-to-sonarqube-generic.sh"bash ./scripts/xccov-to-sonarqube-generic.sh $xcresult_path > docs/coverage.xml(TBA)
Check https://github.com/realm/SwiftLint
swiftlint lint --autocorrect swiftlint lint --output docs/lint.md --reporter markdownxcodebuild docbuild -workspace . -derivedDataPath DerivedData -scheme Baguette-Package -destination "platform=macOS" find "$(pwd)/.build" -type d -name "*.doccarchive"