Answer#
Finder treats a folder named Something.app as a program. The standard structure is:
Notes.app/
Contents/
Info.plist the bundle's description (name, identifier, version, executable name, icon)
MacOS/ the executable
Resources/ icon (.icns), data files, translationscargo build gives you only the executable. A bundle needs the folders and an Info.plist. The program below creates this layout, so you can see exactly what goes where. It writes placeholder files for the executable and icon, so it checks the structure, not that macOS accepts the bundle.
use std::fs;
use std::path::Path;
/// Lays out the folders and files of a macOS .app bundle. Only the layout is checked here (on Windows);
/// the bundle was not opened on a Mac.
fn main() -> std::io::Result<()> {
let root = std::env::temp_dir().join("rs-forum-bundle-demo").join("Notes.app");
let contents = root.join("Contents");
fs::create_dir_all(contents.join("MacOS"))?;
fs::create_dir_all(contents.join("Resources"))?;
fs::write(contents.join("MacOS").join("notes"), b"(the compiled executable goes here)")?;
fs::write(contents.join("Resources").join("AppIcon.icns"), b"(icon)")?;
fs::write(
contents.join("Info.plist"),
r#"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key><string>Notes</string>
<key>CFBundleIdentifier</key><string>org.example.notes</string>
<key>CFBundleExecutable</key><string>notes</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.0.0</string>
<key>CFBundleVersion</key><string>1</string>
</dict>
</plist>
"#,
)?;
print_tree(root.parent().unwrap(), root.parent().unwrap(), 0)?;
fs::remove_dir_all(root.parent().unwrap())
}
fn print_tree(base: &Path, dir: &Path, depth: usize) -> std::io::Result<()> {
let mut entries: Vec<_> = fs::read_dir(dir)?.flatten().collect();
entries.sort_by_key(|e| e.file_name());
for e in entries {
println!("{}{}", " ".repeat(depth), e.file_name().to_string_lossy());
if e.path().is_dir() {
print_tree(base, &e.path(), depth + 1)?;
}
}
Ok(())
}Notes.app
Contents
Info.plist
MacOS
notes
Resources
AppIcon.icnsThings to know:
CFBundleExecutablemust match the file name inContents/MacOS(notesabove).CFBundleIdentifieris a reverse-domain name that identifies the app to the system; choose one you control.org.example.notesis a placeholder.- The icon is an
.icnsfile;CFBundleIconFilenames it without the extension. - Build the bundle on a Mac. Windows file systems have no Unix permission bits, and the executable needs its execute permission, so assemble the real bundle on a Mac or a macOS CI runner.
- Bundling tools exist so you do not write this by hand.
cargo-bundledescribes itself as generating "installers or app bundles for GUI executables built with cargo" and reads its settings from[package.metadata.bundle]inCargo.toml;cargo-packagerlists.appand.dmgamong its macOS formats. Neither was run for this thread.
Common mistakes#
- Putting writable data inside the bundle. Changing the bundle after signing breaks the signature; use the user's folders (see the settings thread).
- Assembling the
.appon Windows and expecting it to run on a Mac: see the note above.
Related questions#
Do I need a universal binary?#
That depends on whether you support both Intel and Apple silicon Macs; it is a build question, not a layout one.
Sources#
- Apple, Bundle Programming Guide, bundle structures: https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html (listed by Apple; not readable as text by the tool used here)
- cargo-bundle: https://github.com/burtonageo/cargo-bundle (read 2026-12-05)
- cargo-packager: https://github.com/crabnebula-dev/cargo-packager (read 2026-12-05)