Repository Public
1# Code signing23ORIX Sheet is distributed outside the Mac App Store, signed with a Developer ID Application4certificate and the hardened runtime. Signing is implemented by one script, `Scripts/sign.sh`5(65 lines), also reachable as `Scripts/build.sh release`. This document describes that script and6the build settings it relies on, and records what was observed on the signed bundle present in7`dist/` on 2026-11-21.89Next steps in the chain: [notarization](notarization.md), [distribution](distribution.md),10[release checklist](checklist.md). Threat model: [security.md](../security.md).1112## Inputs1314| Input | Value | Where it is set |15|---|---|---|16| Bundle identifier | `ai.spboucher.orix.sheet` | `project.yml` (`PRODUCT_BUNDLE_IDENTIFIER`) |17| Team | `3YM54G49SN` | `project.yml` (`DEVELOPMENT_TEAM`); also hard-coded in the verification loop of `sign.sh` |18| Version / build | `1.0.0` / `1` | `project.yml` (`MARKETING_VERSION`, `CURRENT_PROJECT_VERSION`) |19| Signing style | Manual | `project.yml` (`CODE_SIGN_STYLE`) |20| Identity, Debug | `Apple Development` | `project.yml` (target base settings) |21| Identity, Release | `Developer ID Application`, with `OTHER_CODE_SIGN_FLAGS: --timestamp` | `project.yml` (Release config) |22| Architectures, Release | `arm64 x86_64`, `ONLY_ACTIVE_ARCH: NO` | `project.yml` |23| Hardened runtime | `ENABLE_HARDENED_RUNTIME: YES` | `project.yml` |24| App Sandbox | `ENABLE_APP_SANDBOX: NO` | `project.yml` |25| Entitlements file | `App/Resources/ORIXSheet.entitlements` (empty dictionary) | `project.yml` (`CODE_SIGN_ENTITLEMENTS`) |26| Injected base entitlements | `CODE_SIGN_INJECT_BASE_ENTITLEMENTS: NO` | `project.yml` |27| Runpath | `@executable_path/../Frameworks` | `project.yml` (`LD_RUNPATH_SEARCH_PATHS`) |2829Source: `project.yml`, `Scripts/sign.sh`.3031The certificate and its private key are expected in the login keychain. The script never creates,32exports or prints key material; no certificate, `.p8`, `.p12` or provisioning profile is stored in33the repository (`.gitignore` excludes them and `Scripts/secret-scan.sh` fails on such files).3435## What `Scripts/sign.sh` does3637<!-- diagram: signing-pipeline -->38```mermaid39flowchart TD40 A["Find Developer ID identity<br/>in the keychain"] --> B["fetch-duckdb.sh<br/>xcodegen generate"]41 B --> C["xcodebuild Release<br/>(universal, signed by Xcode)"]42 C --> D["ditto to<br/>dist/ORIX Sheet.app"]43 D --> CLI["swift build orix-sheet<br/>(universal), copy to<br/>Contents/MacOS, fix runpaths"]44 CLI --> E["Sign Mach-O files:<br/>dylibs, Helpers, Resources"]45 E --> F["Sign frameworks and<br/>bundles, deepest first"]46 F --> T["Sign the orix-sheet tool"]47 T --> G["Sign the app with<br/>the entitlements file"]48 G --> H["Verify: strict deep check,<br/>no get-task-allow,<br/>team and runtime on every Mach-O"]49```5051SVG fallback: 5253Step by step, with the exact behaviour of the script:54551. **Identity.** `security find-identity -v -p codesigning` is filtered for the first line containing56 `Developer ID Application: …`. If none is found the script stops with an error. If several57 Developer ID identities are installed, the first one listed is used; there is no option to choose.582. **Project.** `Scripts/fetch-duckdb.sh` makes sure `Vendor/duckdb/CDuckDB.xcframework` exists59 (pinned DuckDB `v2.0.1`, SHA-256 checked on download), then `xcodegen generate` rebuilds60 `ORIXSheet.xcodeproj` from `project.yml`.613. **Build.** `xcodebuild -configuration Release -derivedDataPath build/DerivedData-release build`.62 Output is filtered to error lines and the `** BUILD … **` line. The previous Release product is63 deleted first. A failing `xcodebuild` stops the script at this line (`set -euo pipefail`); a64 second guard stops it if the app is missing afterwards.654. **Copy.** `dist/ORIX Sheet.app` is replaced by a `ditto` copy of the built product. Signing is66 done on the copy.675. **Command-line tool.** `swift build -c release --arch arm64 --arch x86_64 --product orix-sheet`68 in `Packages/SheetAutomation` builds a universal `orix-sheet`, which is copied to69 `dist/ORIX Sheet.app/Contents/MacOS/orix-sheet`. Every runpath of the copy other than70 `/usr/lib/swift` is deleted with `install_name_tool -delete_rpath` (they point into the build71 machine), and `@executable_path/../Frameworks` is added, so that the tool loads72 `libduckdb.dylib` from the app's `Contents/Frameworks`. `FeatureAutomation` looks for the tool73 at that location when the user installs a schedule (`WorkflowSchedule.bundledTool`).746. **Nested code, inside-out.**75 - every regular file under `Contents/` that is a `*.dylib`, or lies under a `Helpers/` or76 `Resources/` directory, **and** that `file` identifies as Mach-O, is signed with77 `codesign --force --timestamp --options runtime --sign "$IDENTITY"`;78 - every `*.framework` and `*.bundle` directory is signed with the same options, deepest first79 (`find -depth`);80 - `Contents/MacOS/orix-sheet` is signed with the same options (no entitlements);81 - the application itself is signed last, the only step that passes82 `--entitlements App/Resources/ORIXSheet.entitlements`.837. **Verification** (the script fails if any check fails):84 - `codesign --verify --deep --strict --verbose=2`;85 - prints architectures (`lipo -archs`), identifier, authorities, team, timestamp, runtime version86 and the code-directory flags;87 - **refuses a build that carries `get-task-allow`** in its entitlements;88 - walks every file of the bundle and requires each Mach-O to show `TeamIdentifier=3YM54G49SN`89 and `flags=…runtime`;90 - runs the embedded tool (`orix-sheet version`) and prints its first line, which shows that it91 starts and finds DuckDB from inside the bundle;92 - prints the version from `Info.plist` and ends with93 `RESULT: … is built and signed. It is NOT notarized yet (run Scripts/notarize.sh).`9495Nothing is uploaded by this script.9697### Why every nested binary is re-signed9899Xcode already signs the product during the Release build. The script signs again, explicitly, for100three reasons that can be read from its code:101102- **a secure timestamp on every signature** (`--timestamp`), which notarization requires;103- **the hardened runtime on every Mach-O**, including libraries that Xcode copies as they are;104- **one team for everything**, checked afterwards file by file, so that library validation cannot105 reject a nested library at launch.106107`--deep` is used only for verification, never for signing: nested code is signed explicitly,108inside-out, and the outer signature then seals the already-signed contents.109110## Entitlements: an empty dictionary111112`App/Resources/ORIXSheet.entitlements` is:113114```xml115<plist version="1.0">116<dict/>117</plist>118```119120The file carries no comment. The reasons below are derived from the build settings and from the121package documents; they describe why no key is needed, not a recorded decision.122123| Entitlement that is absent | Why the app works without it |124|---|---|125| `com.apple.security.app-sandbox` | The app is not sandboxed (`ENABLE_APP_SANDBOX: NO`). Consequently no file-access or network sandbox entitlement applies either. |126| `com.apple.security.cs.disable-library-validation` | The only third-party library, DuckDB, is re-signed with the app's own identity (next section), so library validation stays on, for the app and for the embedded `orix-sheet` tool. |127| `com.apple.security.cs.allow-jit`, `allow-unsigned-executable-memory` | No JIT and no in-process interpreter: Python runs as a separate process of an interpreter found on the Mac (`docs/research/technology-evaluation.md`; see [python-runtime](../architecture/python-runtime.md)). |128| `com.apple.security.cs.allow-dyld-environment-variables` | Not used by the app. |129| `com.apple.security.get-task-allow` | A debugging entitlement; `CODE_SIGN_INJECT_BASE_ENTITLEMENTS: NO` stops Xcode from injecting it and `sign.sh` fails if it is present. Notarization rejects it. |130| `com.apple.security.automation.apple-events`, camera, microphone, etc. | No such capability is requested by the entitlements file. |131132Source: `App/Resources/ORIXSheet.entitlements`, `project.yml`, `Scripts/sign.sh`.133134An empty entitlements file means the hardened runtime applies with **no exception**. That is the135strictest configuration available to a non-sandboxed Developer ID app. It does not make the app136sandboxed: the process has the user's file-system and network rights. What the app actually does137with them is covered in [security.md](../security.md).138139## DuckDB re-signing140141The data engine links the official DuckDB shared library, fetched by `Scripts/fetch-duckdb.sh`142(not kept in git) and wrapped in `Vendor/duckdb/CDuckDB.xcframework`.143144| Fact | Value | Observed with |145|---|---|---|146| Vendored file | `Vendor/duckdb/dl/libduckdb.dylib`, 133,735,472 bytes, `x86_64 arm64` | `ls -l`, `lipo -archs` |147| Upstream signature | `Developer ID Application: Stichting DuckDB Foundation (7NCTQWA3HA)`, hardened runtime | `codesign -dvv` on the vendored file |148| Location in a built app | `Contents/Frameworks/libduckdb.dylib` | Debug product in `build/DerivedData`, Release bundle in `dist/` |149| Signature in the Debug product | `Apple Development: Simon-Pierre Boucher (NYGTAPU4ZN)` (re-signed by Xcode's embed step) | `codesign -dvv` on the embedded copy |150| Signature in the Release bundle | `Developer ID Application: Simon-Pierre Boucher (3YM54G49SN)`, `flags=0x10000(runtime)`, timestamp Nov 21, 2026 at 3:50:29 AM, 133,735,472 bytes, `x86_64 arm64` | `codesign -dvv`, `ls -l`, `lipo -archs` on `dist/ORIX Sheet.app/Contents/Frameworks/libduckdb.dylib` |151152Source: commands run on 2026-11-21 against the working tree; `Packages/SheetData/README.md`153("Embedding DuckDB in the app") for the requirement.154155Because the upstream library is signed by another team, a hardened-runtime app with library156validation would refuse to load it unchanged. `sign.sh` handles it with its first loop: the file157matches `*.dylib`, is Mach-O, and is therefore signed with the Developer ID identity, a timestamp158and the hardened runtime, replacing the upstream signature; the final loop then requires159`TeamIdentifier=3YM54G49SN` on it.160161Not done: the library is not thinned. `Packages/SheetData/README.md` notes that162`lipo -thin arm64` would save about 68 MB; the Release configuration is universal, so both slices163ship.164165## State of `dist/ORIX Sheet.app` observed on 2026-11-21166167A signed Release bundle was produced by `Scripts/sign.sh` on 2026-11-21. The table is a read-only168inspection of that bundle (`codesign -dvv`, `codesign --verify`, `lipo`, `otool -l`, `find`, `du`).169170| Property | Observed |171|---|---|172| Identifier | `ai.spboucher.orix.sheet` |173| Format | app bundle with Mach-O universal (`x86_64 arm64`) |174| Flags | `0x10000(runtime)` (hardened runtime) |175| Authority | `Developer ID Application: Simon-Pierre Boucher (3YM54G49SN)` → Developer ID Certification Authority → Apple Root CA |176| Timestamp | Nov 21, 2026 at 3:50:32 AM |177| Runtime version | 27.2.0 |178| Entitlements in the signature | empty dictionary; no `get-task-allow` |179| `codesign --verify --deep --strict` | passes |180| Version | 1.0.0 |181| Bundle size | 259 MB (`du -sh`) |182| Mach-O files in the bundle | 3, all universal (`x86_64 arm64`), all signed by team `3YM54G49SN` with the hardened runtime and a secure timestamp |183| `Contents/MacOS/ORIX Sheet` | main executable, 99,143,360 bytes |184| `Contents/MacOS/orix-sheet` | embedded command-line tool, 36,545,024 bytes; runpaths `/usr/lib/swift` and `@executable_path/../Frameworks`; `orix-sheet version` prints `orix-sheet 1.0.0 (473 worksheet functions, DuckDB v2.0.1, workflow schema 1)` |185| `Contents/Frameworks/libduckdb.dylib` | 133,735,472 bytes, re-signed (previous section) |186| `Contents/Resources` | 14 resource bundles of the packages, `Assets.car`, `AppIcon.icns`, `fr-CA.lproj`, `Metadata.appintents` |187188Source: `codesign -dvv`, `codesign -d --entitlements - --xml`, `codesign --verify --deep --strict`,189`lipo -archs`, `otool -l`, `ls -l`, `du -sh` on `dist/ORIX Sheet.app` and its three Mach-O files,190run on 2026-11-21.191192The DuckDB re-signing path and the tool-embedding step of `sign.sh` are therefore observed on a193Release bundle. Notarization, stapling, checksums and the Gatekeeper assessment of this bundle are194not recorded here: see `RELEASE-REPORT.md`.195196## Known limits of the script197198- The team identifier in the verification loop is a literal; signing with another team's Developer199 ID would build correctly and then fail verification.200- Build warnings are filtered out of the console output; only errors and the build result are shown.201- The script signs `dist/ORIX Sheet.app` in place. There is no dry-run mode and no option to sign202 an existing bundle without rebuilding.203- No `xcodebuild archive`/`exportArchive` is used; the Release product of a plain `build` is taken.204 dSYM handling is not part of the script.205