Repository navigation
chore: make MeshCore portable for non-Apple builds - #498
Merged
Merged
Conversation
Gate Apple-only frameworks (os, CryptoKit, CommonCrypto, Network, Synchronization) behind canImport checks, add cross-platform fallbacks, port sendVerifiedChannelMessage with tests, and add the Linux MeshCore build check and optional multiplatform Makefile include.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
MeshCoreondevimports Apple-only system frameworks (os,CryptoKit,CommonCrypto,Network, and unguardedSynchronization) directly, so cross-compilingMeshCorefor Android or Linux fails immediately and forces themultiplatformbranch to carry recurring merge-conflicting shims across 30+MeshCore/files and root build files. Moving these behavior-neutral#if canImport(...)shims,sendVerifiedChannelMessage, and zero-conflict branch hooks ontodevkeeps Apple behavior identical while allowingmultiplatformto mergedevwithout conflicts.Overview of Changes
MeshCore/):os,CryptoKit,CommonCrypto,Network, andSynchronizationimports behind#if canImport(...)acrossMeshCore/Sources/andMeshCore/Tests/(includingSubmittedCommandWindowandWiFiTransportErrorhandling inMeshCoreSession+TransportWrites.swift).Compat/OSLogCompat.swift(Logger/OSSignpostersink with<private>redaction parity off Apple),Compat/OSAllocatedUnfairLock.swift, andProtocol/AES128ECBFallback.swift(per-block AES-CBC with zero IV viaswift-crypto5.0.0, linked only on.android,.linux, and.windows).AES128ECBPortabilityTestsandLogPrivacyTestspinning off-Apple behavior against the Apple CommonCrypto andos.Loggersemantics.MeshCoreSession+ChannelSending.swift):sendVerifiedChannelMessage(channel:text:timestamp:floodScope:expectedSecret:), which verifies channel occupancy withgetChanneland sends within a single serialized command slot.VerifiedChannelSendTests.swiftcovering unscoped send, flood-scoped send + baseline reset, secret mismatch rejection,notFoundrejection, and cancellation before write.-include multiplatform/Makefile(and-honhelpgrep) inMakefile,MeshCoreBridge/.buildexcludes in.swiftlint.ymland.swiftformat, andradio-dev.envin.gitignore..github/workflows/meshcore-portability.ymlto build--target MeshCoreinsideswift:6.2-noblewhenMeshCore/**changes on PRs todevormain.Details & Trade-offs
iOS/macOS) continue linking only Apple's systemos,CryptoKit,CommonCrypto,Network, andSynchronizationframeworks;swift-crypto5.0.0is gated by.when(platforms: [.android, .linux, .windows]).WiFiTransport.swiftandWiFiTransportTests.swiftremain fenced with#if canImport(Network)and formatted normally under.swiftformat.swiftformatis0.64.7(CI pins0.64.5), soMeshCore/was formatted and verified against.swiftformatwithout touching unrelatedMC1/MC1Servicesfiles..github/workflows/meshcore-portability.yml) has not run in GitHub Actions yet; it will execute on PR open.make test-appandmake test-storewere not run locally (simulator build + both SPM package suites ran instead).ELI5
The shared radio protocol package previously failed to compile off Apple devices because it imported macOS/iOS logging, networking, and cryptography modules directly. This change wraps those imports in platform checks with non-Apple fallbacks and adds a small Linux build check on PRs, so the Android branch can share
MeshCoredirectly fromdevwithout carrying merge-conflicting patches.Testing
Before (
devat059bc163a)Exit code
1:After (
chore/meshcore-android-portabilityat5e838da56)Android
aarch64cross-compile (EXIT_ARM64=0):Android
x86_64cross-compile (EXIT_X64=0):Package & iOS checks:
make help— exit0, lists root targets cleanly without error whenmultiplatform/Makefileis absent.make test-meshcore— exit0,Test run with 596 tests in 74 suites passed after 11.585 seconds.(includesVerifiedChannelSendTests,AES128ECBPortabilityTests,LogPrivacyTests,WiFiTransportTests).make test-services— exit0,Test run with 2882 tests in 332 suites passed after 506.334 seconds.make generate && xcodebuild build -project MC1.xcodeproj -scheme MC1 -destination "platform=iOS Simulator,name=iPhone 17e,OS=27.2" 2>&1 | xcsift -f toon— exit0,status: success,errors: 0,warnings: 9,linker_errors: 0.swiftformat --config .swiftformat --lint --strict MeshCore/— exit0,0/166 files require formatting, 15 files skipped.swiftlint lint --strict --config .swiftlint.yml MeshCore/ MC1Services/ MC1/ MC1Tests/— exit0,Done linting! Found 0 violations, 0 serious in 2188 files.Tested on