Quick answers
- Fastest path: install Xcode, open the project, pick the scheme, press Run. The terminal route below is the same four steps with the IDE removed.
- Where the built app lands: with
xcodebuildplus an explicit-derivedDataPath, atbuild/Build/Products/Release/YourApp.app. Without that flag, somewhere under~/Library/Developer/Xcode/DerivedData. - Is a paid Apple Developer account required? No. A free Apple ID is enough to build and run a copy on your own Mac. Money only becomes relevant when you distribute.
- Why does macOS call the app "damaged"? That message almost always means a quarantine flag or a mismatched signature on a downloaded copy. A local build rarely hits it.
- Can the build run without the Xcode app? No for
.xcodeprojand.xcworkspaceprojects, becausexcodebuildships inside Xcode. A pure Swift package can be built with the Command Line Tools alone. - How long does a first build take? Two to five minutes for a small project, and considerably longer when Swift packages or C dependencies compile from scratch.
What the build needs before anything else
The build needs the complete Xcode toolchain rather than the standalone Command Line Tools, because the macOS SDKs and xcodebuild are shipped inside Xcode.
Install Xcode from the App Store or from the Apple developer downloads page, launch it once so the additional components finish installing, accept the licence, then point the toolchain at that copy:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
xcode-select -p
xcodebuild -versionThree artefacts are worth gathering from the repository before the first command: the README's build section, the deployment target, and the dependency manager in use. A project with a Podfile needs pod install before the workspace is used, a project with Package.swift resolves its packages on first build, and a project whose README lists Homebrew formulae expects those formulae installed first. Budget roughly 40 GB of free disk space for Xcode plus build products, and confirm the machine architecture so you know what binary to expect:
uname -m
df -h /Identify the project type before typing a command
The marker file at the repository root tells you which build command to use, so read the file listing before guessing.
Marker at the repo root | What it means | Build command |
|---|---|---|
| A single Xcode project |
|
| A workspace, usually CocoaPods or local packages |
|
| A Swift Package Manager package |
|
| Plain make or CMake |
|
| A Node-wrapped desktop app |
|
| XcodeGen generates the project first |
|
A Swift package is the one case that needs a warning attached: swift build produces an executable, not an application bundle. Unless the package also ships an Info.plist and a bundling script, there is no .app to double-click at the end, and the honest result of that build is a binary you run from a terminal.
Build from the command line
A command-line build needs the scheme name, and asking for the scheme list first prevents the most common early failure.
xcodebuild -list -project MyApp.xcodeprojWith the scheme confirmed, a release build into a predictable folder looks like this:
xcodebuild \
-project MyApp.xcodeproj \
-scheme MyApp \
-configuration Release \
-derivedDataPath build \
buildThe output path is then build/Build/Products/Release/MyApp.app. For a workspace, swap -project MyApp.xcodeproj for -workspace MyApp.xcworkspace. When dependency resolution fails behind a proxy or from a cold cache, xcodebuild -resolvePackageDependencies runs that step on its own and reports the real error instead of burying it. To produce one binary that runs on both Apple Silicon and Intel Macs, override the architecture settings:
xcodebuild -project MyApp.xcodeproj -scheme MyApp -configuration Release \
-derivedDataPath build ONLY_ACTIVE_ARCH=NO ARCHS="arm64 x86_64" buildIf the build state looks poisoned by an earlier failed attempt, remove the derived data folder rather than editing the project. Nothing in build/ or ~/Library/Developer/Xcode/DerivedData is source code.
Sign the finished bundle
macOS will run a locally built app without a developer certificate, but the bundle still needs a valid signature, and an ad-hoc signature satisfies that requirement on the machine that built it.
codesign --force --sign - build/Build/Products/Release/MyApp.app
codesign --verify --strict --verbose=2 build/Build/Products/Release/MyApp.appThe - after --sign means ad-hoc. Adding --deep makes signing a bundle with nested frameworks easier for a quick local test, though for anything you hand to another person each nested framework should be signed individually, deepest first. Source, build, sign, and notarize are the four stages every Mac build passes through, and the last two only become mandatory once the app travels beyond your own machine.

Distribution is where certificates enter the picture. A Developer ID Application certificate, the hardened runtime flag, and a notarization submission are all required before Gatekeeper will accept a build on someone else's Mac:
codesign --force --options runtime --sign "Developer ID Application: Name (TEAMID)" MyApp.app
ditto -c -k --keepParent MyApp.app MyApp.zip
xcrun notarytool submit MyApp.zip --keychain-profile notary-profile --wait
xcrun stapler staple MyApp.appConfirm the build is actually finished
A build is finished when the bundle exists, verifies, launches, reports the version you intended, and stays open.
- The bundle exists at the expected path and reports the right architectures:
lipo -info MyApp.app/Contents/MacOS/MyApp. codesign --verify --strictexits without complaint.open build/Build/Products/Release/MyApp.appbrings up a window rather than bouncing once and dying.- The version shown in the app's About panel matches the tag you checked out.
- A short log query shows no crash loop:
log show --predicate 'process == "MyApp"' --last 2m.
If all five pass, the build is reproducible from a clean checkout and the remaining work is about trust and distribution, not compilation.
Follow-up questions, grouped by intent
Getting set up
Do you still need the Command Line Tools when Xcode is installed? Mostly no, because Xcode bundles them. Installing them separately is only useful for a machine that builds Swift packages without the IDE.
What macOS version do you need? The version required to run Xcode is the ceiling, and the project's deployment target is the floor. A project with a deployment target newer than your macOS cannot be built or run locally.
Is administrator access required? Yes for xcode-select --switch and for installing Homebrew dependencies, since both write outside the user's home directory.
Build failures
The build says "no such module" for a dependency. Package resolution did not run. Open the project in Xcode once, or run xcodebuild -resolvePackageDependencies and read the reported network or version error.
It fails with "no signing certificate found". Signing is being attempted before you have a certificate. For a local build, disable signing at compile time with CODE_SIGNING_ALLOWED=NO and ad-hoc sign the finished bundle afterwards.
The project is an iOS app and there is no macOS target. Then it cannot be built as a Mac app. Only a project with a macOS target, a Mac Catalyst target, or a Mac app destination for an iPad app can produce a .app — the source layout alone does not decide this.
The build succeeds but the app crashes on launch. Check whether an embedded framework or a Homebrew library is missing from the bundle, and read the crash report's termination reason before changing build settings.
Signing and trust
Is an ad-hoc signature enough for personal use? Yes. It is enough to launch on the Mac that produced it, and it is not enough for notarization or the App Store.
Why does spctl reject the build? Gatekeeper assessment is stricter than code validation, and an ad-hoc signed app fails it by design. Locally built apps launch anyway because they carry no quarantine attribute.
Is removing the quarantine flag a real fix? It is a diagnosis, not a repair. xattr -dr com.apple.quarantine MyApp.app explains the "damaged" message, and it should never be applied to software from a source you do not trust.
Sharing and distribution
What changes when someone else runs the build? Signing with a Developer ID certificate and notarizing, because a copy that arrives over the internet is quarantined and then assessed.
Can a build go to the App Store? Only with a paid developer account, an app sandbox, and a bundle identifier and entitlements that match the provisioning profile.
How do updates work for a source build? Pull the new tag, rebuild, and replace the old bundle. Sharing a build with someone else is a different job from running it yourself, so most projects automate the signing and notarizing steps in a script rather than repeating them by hand.

FAQ
Do you have to compile an app to use it? No. For daily use, prefer a signed release from the project's own release page; compiling is for verifying behaviour, patching, or running a version that has no build available.
Can an Intel Mac build an app for Apple Silicon? Yes, through a universal build with both architectures requested, and an app without an arm64 slice can still run under Rosetta on Apple Silicon.
Where does the source come from? A source archive or a clone of the project's repository. Read the build instructions in that repository before installing anything, because they take precedence over any general guide.
Is a build reproducible later? Only if the toolchain, dependencies, and commit stay the same. Record the Xcode version and the commit hash next to the build so a later failure is diagnosable rather than mysterious.


