This is the platform-specific project for the platform macOS.
Make sure to check the shared crate as we depend on it.
Rust is a cross-platform language that supports many different architectures and platforms.
Building for Desktop Platforms (like Windows, Linux, macOS) is natively supported as long as the required tools are installed.
For Android, iOS and WebAssembly (WASM) we "require" some additional tools to build.
In essence, we could do it without those tools but it would be much harder to do so.
Said tools commonly package our apps into .APK, .APP and .JS/WASM, link them against our library and make sure the entrypoint is called.
Inside src/lib.rs
we have a public entrypoint defined:
pub fn entrypoint() {
// Our cross-platform code here
}
Each platform calls this, while each platform itself has an entrypoint.
Ideally, we only have our shared code.
However, sometimes we need some very platform specific things that can only be done on said platform.
In this case we have some non-shared/platform-specific code but overall this should only be true for very special cases as the Rust standard library works mostly the same on each platform/target.
We implement the standard Rust Binary-Entrypoint:
fn main() {
// OUR CODE HERE
}
And simply call the entrypoint defined by our shared library.
Check out the shared crate for more on how this is working and what it is doing.
This is the most basic of examples: A simple "Hello World"
or better yet: "Hello from Rust!"
to the standard output.
On Desktop platforms this will open a Terminal/Console printing out the text and exiting.
For Android, iOS and WebAssembly this will be logged to LogCat, Device Logs and the Browser Console respectively.
Independent of the platform the app will exit right after being done. Depending on the platform the window (console or app) may close before you even see it.
On Desktop you can call the executable from a terminal either by using the executable in target/(debug|release|<arch>)/platform_*(.exe)
or using the cargo run --package platform_<platform>
command.
For Android, iOS and WebAssembly enable persistent logging and reopen the app/website.
Host: Windows | Host: Linux | Host: macOS | |
---|---|---|---|
Target: Windows | ✅: Visual Studio | 🔀: MinGW | 🔀: MinGW |
Target: Linux | ✅: GCC or Clang | 🔀: Docker or VM | |
Target: macOS | ✅: XCode | ||
Target: Android | 🔀: Android Studio or Android CommandLine-Tools | 🔀: Android Studio or Android CommandLine-Tools | 🔀: Android Studio or Android CommandLine-Tools |
Target: iOS | ✅: XCode | ||
Target: WebAssembly | ✅: Wasm-Pack | ✅: Wasm-Pack | ✅: Wasm-Pack |
✅ = Natively supported.
🔀 = Cross-Compilation & Toolchain needed.
Requirements:
- Rust and Cargo is installed, preferably via Rustup. Use the stable channel ideally.
- Rust on macOS requires Clang to be installed, ideally install XCode from the AppStore (or archive for older macOS versions) or use Brew to install
xcode-buildtools
andclang
.
Debug/Development Build:
cargo build --package platform_macos
Release/Production Build:
cargo build --package platform_macos --release
Optionally add
--verbose
to see what is happening.
Floods your console with message though possibly, use when there are build errors.
Requirements:
- Rust and Cargo is installed, preferably via Rustup. Use the stable channel ideally.
- Rust on macOS requires Clang to be installed, ideally install XCode from the AppStore (or archive for older macOS versions) or use Brew to install
xcode-buildtools
andclang
.
Debug/Development Testing:
cargo test --package platform_macos
Release/Production Testing:
cargo test --package platform_macos --release
Optionally add
--verbose
to see what is happening.
Floods your console with message though possibly, use when there are build errors.
Requirements:
- Rust and Cargo is installed, preferably via Rustup. Use the stable channel ideally.
- Rust on macOS requires Clang to be installed, ideally install XCode from the AppStore (or archive for older macOS versions) or use Brew to install
xcode-buildtools
andclang
.
Debug/Development Running:
cargo run --package platform_macos
Release/Production Running:
cargo run --package platform_macos --release
Optionally add
--verbose
to see what is happening.
Floods your console with message though possibly, use when there are build errors.