{"id":19457712,"url":"https://github.com/luncliff/cpp-swift-experiment","last_synced_at":"2026-05-12T23:07:26.535Z","repository":{"id":46797433,"uuid":"370793001","full_name":"luncliff/cpp-swift-experiment","owner":"luncliff","description":"Experiment of Interoperability between C++ \u0026 Swift","archived":false,"fork":false,"pushed_at":"2025-04-08T15:12:58.000Z","size":40,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-30T12:23:15.001Z","etag":null,"topics":["cmake-examples","cpp","cpp-library","experiment","objective-c-runtime","swift","swift-package-manager"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luncliff.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-25T18:34:14.000Z","updated_at":"2025-04-08T15:12:59.000Z","dependencies_parsed_at":"2024-11-10T17:25:14.654Z","dependency_job_id":"64b74927-5743-4667-b64a-faabdba1a124","html_url":"https://github.com/luncliff/cpp-swift-experiment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/luncliff/cpp-swift-experiment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luncliff%2Fcpp-swift-experiment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luncliff%2Fcpp-swift-experiment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luncliff%2Fcpp-swift-experiment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luncliff%2Fcpp-swift-experiment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luncliff","download_url":"https://codeload.github.com/luncliff/cpp-swift-experiment/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luncliff%2Fcpp-swift-experiment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32960368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T09:19:52.626Z","status":"ssl_error","status_checked_at":"2026-05-12T09:17:33.438Z","response_time":102,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake-examples","cpp","cpp-library","experiment","objective-c-runtime","swift","swift-package-manager"],"created_at":"2024-11-10T17:23:35.123Z","updated_at":"2026-05-12T23:07:26.529Z","avatar_url":"https://github.com/luncliff.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Build](https://github.com/luncliff/cpp-swift-experiment/actions/workflows/build.yml/badge.svg)](https://github.com/luncliff/cpp-swift-experiment/actions/workflows/build.yml)\n\n### References\n\n* https://swift.org/package-manager/\n* https://swift.org/documentation/cxx-interop/project-build-setup/\n* https://developer.apple.com/documentation/swift_packages\n* https://developer.apple.com/documentation/objectivec/objective-c_runtime?language=objc\n* https://learn.microsoft.com/en-us/vcpkg/consume/manifest-mode\n* https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage\n* https://github.com/realm/SwiftLint\n\n## How To\n\n### Setup\n\n```powershell\nscripts/setup-metal-cpp.ps1 -Folder \"externals\" -FileName \"metal-cpp_macOS15_iOS18.zip\"\n```\n\n### Build\n\n#### With Swift Package Manager(SwiftPM)\n\n```bash\nswift build --build-tests\nswift build --configuration debug --target Baguette\n```\n\n#### With Xcodebuild\n\n```bash\nxcodebuild -showsdks\n```\n\n```bash\nxcodebuild -list -workspace .\n```\n\n```bash\nxcodebuild -workspace . -scheme \"Baguette-Package\" -showdestinations\n```\n\n```bash\nxcodebuild -workspace . -scheme \"Baguette-Package\" \\\n    -destination \"generic/platform=macOS\" \\\n    -derivedDataPath DerivedData \\\n    -configuration Debug \\\n    build\n```\n\n#### With CMake, Vcpkg Toolchain\n\n```bash\nexport VCPKG_FEATURE_FLAGS=\"manifests\"\nexport VCPKG_ROOT=\"$HOME/../vcpkg\"\n```\n\n```bash\ncmake --preset x64-osx\ncmake --build --preset x64-osx-debug\n```\n\n### Test\n\n#### With SwiftPM\n\n```bash\nswift test --list-tests\nswift test --enable-code-coverage\n```\n\n#### With Xcodebuild\n\n```bash\nxcodebuild -workspace . -scheme \"Baguette-Package\" \\\n    -destination \"platform=macOS\" \\\n    -derivedDataPath DerivedData \\\n    -enableCodeCoverage YES \\\n    test\n```\n\n#### With CMake, Vcpkg Toolchain\n\n```bash\ncmake --build --preset x64-osx-debug --target baguette_test\nctest --preset x64-osx-debug\n```\n\n### Analysis\n\n* https://docs.sonarqube.org/latest/analyzing-source-code/analysis-parameters/\n* https://docs.sonarcloud.io/enriching/test-coverage/test-coverage-parameters/\n* https://medium.com/xcblog/xccov-xcode-code-coverage-report-for-humans-466a4865aa18\n\n#### Coverage With llvm-cov \u0026 lcov\n\nIf you used Swift Package Manager to build/test, the path can be used with configuration name.\n\n```bash\nllvm-cov export --format lcov -instr-profile .build/debug/codecov/default.profdata .build/debug/BaguettePackageTests.xctest/Contents/MacOS/BaguettePackageTests \u003e lcov.info\n```\n\nXcodebuild will generate more complicated output path.\n\n```bash\nprofdata_path=$(find \"DerivedData/Build/ProfileData\" -name \"Coverage.profdata\" | head -n 1)\nxctest_path=\"DerivedData/Build/Products/Debug/BaguetteBridgeTests.xctest/Contents/MacOS/BaguetteBridgeTests\"\nllvm-cov export -format lcov -instr-profile \"$profdata_path\" \"$xctest_path\" \u003e lcov.info\n```\n\n```ps1\n$profdata_path = Get-ChildItem -File -Path \"DerivedData/Build/ProfileData\" -Recurse -Filter \"Coverage.profdata\" \n$xctest_path = \"./DerivedData/Build/Products/Debug/BaguetteBridgeTests.xctest/Contents/MacOS/BaguetteBridgeTests\"\nllvm-cov export -format lcov -instr-profile \"$profdata_path\" \"$xctest_path\" \u003e lcov.info\n```\n\nFrom the generated `lcov.info`, you can remove unnecessary files. \n\n```bash\nlcov --remove lcov.info \"test/\" \\\n     --output-file lcov-changed.info\nlcov --remove lcov-changed.info \"externals/\" \\\n     --output-file lcov-changed.info --ignore-errors unused\n```\n\n```bash\nlcov --list lcov-changed.info\n```\n\nFrom the file, you can generate HTML report.\n\n```bash\ngenhtml lcov.info --output-directory docs\nopen docs/index.html\n```\n\nUse xcrun to generate coverage report.\n\n```bash\nxcrun --run llvm-cov show -instr-profile=$profdata_path $xctest_path \u003e docs/coverage.report\n```\n\n#### Coverage With xccov\n\n```bash\nxcresult_path=$(find DerivedData/Logs/Test/ -maxdepth 1 -name \"Test*.xcresult\" | head -n 1)\n```\n\n```ps1\n$xcresult_path = Get-ChildItem -Directory  -Filter \"DerivedData/Logs/Test/Test*.xcresult\" | Select-Object -First 1\n```\n\n```bash\nxcrun xccov view --report \"$xcresult_path\"\n```\n\n```bash\nxcrun xccov view --report --json $xcresult_path | jq\n```\n\n```ps1\nNew-Item -Type Directory -Name \"scripts\" -Force\nInvoke-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\"\n```\n\n```bash\nbash ./scripts/xccov-to-sonarqube-generic.sh $xcresult_path \u003e docs/coverage.xml\n```\n\n#### Reporting\n\n(TBA)\n\n### Lint\n\nCheck https://github.com/realm/SwiftLint\n\n```bash\nswiftlint lint --autocorrect\nswiftlint lint --output docs/lint.md --reporter markdown\n```\n\n### Document\n\n```bash\nxcodebuild docbuild -workspace . -derivedDataPath DerivedData -scheme Baguette-Package -destination \"platform=macOS\"\nfind \"$(pwd)/.build\" -type d -name \"*.doccarchive\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluncliff%2Fcpp-swift-experiment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluncliff%2Fcpp-swift-experiment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluncliff%2Fcpp-swift-experiment/lists"}