mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 10:18:51 +00:00
This PR improves the build process for the macOS / iOS apps by building connlib as part of the macOS / iOS app build. Fixes firezone/product#625. This is how the build would work after this PR: - `build-rust.sh` creates `libconnlib.a` for the appropriate target triples only. lipo is not used. When creating macOS debug builds, it’s built only for the native architecture. - The network extension targets in the Xcode project set a library search path as the cargo target dir, so that the Xcode build for a target triple can pickup the appropriate `libconnlib.a` at link time. Swift code reorganizations: - connlib’s Adapter has moved to the main app - connlib’s CallbackHandler’s logic has moved to Adapter, which is set as CallbackHandler’s delegate. The CallbackHandler serves as an interface to receive callbacks from the FFI. In case we need to change the FFI, CallbackHandler should change as well, so it remains in the connlib directory. In case of changes to the Rust FFI, as part of the Rust FFI change PR, we can modify the CallbackHandler class and leave the delegate unchanged, so that the app can continue to be built without errors. - `Connlib.xcodeproject` and build scripts for building `Connlib.xcframework` are removed - Connlib headers and Swift files are copied to `FirezoneNetworkExtension/Connlib` as part of the build process, and used from there. Rust build changes: - The rust target dir remains the same, but it’s ~~passed explicitly as `--target-dir`~~ used to set `CARGO_TARGET_DIR`, so that the same target dir can be used to populate Xcode’s library search paths - The `build.rs` for connlib-apple had lots of code to build Swift code as part of the Rust build. This PR reverts it to the previous simple version. With this PR, building connlib-apple (i.e. running `build-rust.sh`) only builds the Rust code. - ~~We set `cargo:rerun-if-env-changed=CONNLIB_MOCK`.~~ We don't set this because it's not required. - The Rust CI job for building connlib-apple is removed. It's built when the macOS / iOS apps are built in swift.yml. This means that with this PR, connlib-apple is tested only when `rust/connlib/**` changes, not when `rust/**` changes. Is that ok? Other changes not directly related to the build process change but part of this PR: - There’s a cleanup script: `./cleanup.sh` - Fixed a typo in `swift-pass-checks.yml`: “paths-ginore”
Connlib
Firezone's connectivity library shared by all clients.
🚧 Disclaimer 🚧
NOTE: This repository is undergoing heavy construction. You could say we're Building In The Open™ in true open source spirit. Do not attempt to use anything released here until this notice is removed. You have been warned.
Building Connlib
Setting the CONNLIB_MOCK environment variable when packaging for Apple or Android will activate the mock feature flag, replacing connlib's normal connection logic with a mock for testing purposes.
- You'll need a Rust toolchain installed if you don't have one already. We recommend following the instructions at https://rustup.rs.
rustup showwill install all needed targets since they are added torust-toolchain.toml.- Follow the relevant instructions for your platform:
- Apple
- Android
- Linux
- Windows
Apple
Connlib should build successfully with recent macOS and Xcode versions assuming you have Rust installed. If not, open a PR with the notes you found.