Debian Codegraph @

docs/en/reference/platforms/macOS/index.md

raw
1 # macOS
2
3 <table class="host-platform-support-table">
4 <colgroup>
5 <col style="width: 11%" />
6 <col style="width: 10%" />
7 <col style="width: 7%" />
8 <col style="width: 5%" />
9 <col style="width: 6%" />
10 <col style="width: 5%" />
11 <col style="width: 5%" />
12 <col style="width: 7%" />
13 <col style="width: 11%" />
14 <col style="width: 7%" />
15 <col style="width: 10%" />
16 </colgroup>
17 <thead>
18 <tr>
19 <th colspan="11"><a href="../../../reference/platforms">Host Platform Support</a></th>
20 </tr>
21 <tr>
22 <th colspan="2">macOS</th>
23 <th colspan="5">Windows</th>
24 <th colspan="4">Linux</th>
25 </tr>
26 <tr>
27 <th>x86‑64</th>
28 <th>arm64</th>
29 <th>x86</th>
30 <th colspan="2">x86‑64</th>
31 <th colspan="2">arm64</th>
32 <th>x86</th>
33 <th>x86‑64</th>
34 <th>arm</th>
35 <th>arm64</th>
36 </tr>
37 </thead>
38 <tbody>
39 <tr>
40 <td>{{ ci_tested }}</td>
41 <td>{{ ci_tested }}</td>
42 <td></td>
43 <td colspan="2"></td>
44 <td colspan="2"></td>
45 <td></td>
46 <td></td>
47 <td></td>
48 <td></td>
49 </tr>
50 </tbody>
51 </table>
52
53 Briefcase supports two output formats for macOS apps:
54
55 - An [.app bundle][app-bundle] with a pre-compiled binary; and
56 - An [macOS Xcode project][macos-xcode-project] which can be used to build an app with a customized binary.
57
58 The default output format for macOS is an [.app bundle][app-bundle].
59
60 Both output formats support packaging as a macOS DMG, PKG or as a standalone signed app bundle. By default, apps will be both signed and notarized when they are packaged.
61
62 Configuration options between the [.app bundle][app-bundle] and [macOS Xcode project][macos-xcode-project] formats are identical.
63
64 ## Prerequisites { #macos-prerequisites }
65
66 Briefcase requires installing Python 3.10+. You will also need a method for managing virtual environments (such as `venv`).
67
68 ## Packaging format
69
70 Briefcase supports three packaging formats for a macOS app:
71
72 1. A DMG that contains the `.app` bundle (using `briefcase package macOS -p dmg`).
73 2. A zipped `.app` bundle (using `briefcase package macOS -p zip`).
74 3. A `.pkg` installer (using `briefcase package macOS -p pkg`).
75
76 `.pkg` is the *required* format for console apps. `.dmg` is the default format for GUI apps.
77
78 ## Icon format
79
80 macOS apps use `.icns` format icons.
81
82 macOS apps do not support splash screens or installer images.
83
84 ## Additional options
85
86 The following options can be provided at the command line when packaging macOS apps.
87
88 ### `--installer-identity <identity>`
89
90 This option is only used when creating a `.pkg` installer.
91
92 The [code signing identity][code-signing-macos] to use when signing the installer package. This is a *different* signing identity to the one used to sign the app, but it must be from the same team as the app signing identity.
93
94 ### `--no-sign-installer`
95
96 This option is only used when creating a `.pkg` installer.
97
98 Do not sign the installer. This option can be useful during development and testing. However, care should be taken using this option for release artefacts, as it may not be possible to distribute an unsigned installer to others.
99
100 ### `--no-notarize`
101
102 Do not submit the application for notarization. By default, apps will be submitted for notarization unless they have been signed with an ad-hoc signing identity.
103
104 ### `--resume <submission ID>`
105
106 Apple's notarization server can take a long time to respond - in some cases, hours. When you submit an app for notarization, the console output of the `package` command will provide you with a submission ID. If the notarization process is interrupted for any reason (including user intervention), you can use this submission ID with the `--resume` option to resume the notarization process for an app.
107
108 ## Application configuration
109
110 The following options can be added to the `tool.briefcase.app.<appname>.macOS` section of your `pyproject.toml` file.
111
112 ### `entitlement`
113
114 A property whose sub-attributes define keys that will be added to the app's `Entitlements.plist` file. Each entry will be converted into a key in the entitlements file. For example, specifying:
115
116 ```python
117 entitlement."com.apple.vm.networking" = true
118 ```
119
120 will result in an `Entitlements.plist` declaration of:
121
122 ```python
123 <key>com.apple.vm.networking</key><true/>
124 ```
125
126 Any Boolean, string, list, or dictionary value can be used as an entitlement value.
127
128 All macOS apps are automatically granted the following entitlements by default:
129
130 - `com.apple.security.cs.allow-unsigned-executable-memory`
131 - `com.apple.security.cs.disable-library-validation`
132
133 You can disable these default entitlements by defining them manually. For example, to enable library validation, you could add the following to your `pyproject.toml`:
134
135 ```python
136 entitlement."com.apple.security.cs.disable-library-validation" = false
137 ```
138
139 ### `info`
140
141 A property whose sub-attributes define keys that will be added to the app's `Info.plist` file. Each entry will be converted into a key in the entitlements file. For example, specifying:
142
143 ```python
144 info."NSAppleScriptEnabled" = true
145 ```
146
147 will result in an `Info.plist` declaration of:
148
149 ```python
150 <key>NSAppleScriptEnabled</key><true/>
151 ```
152
153 Any Boolean or string value can be used for an `Info.plist` value.
154
155 ### `min_os_version`
156
157 The minimum macOS version that the app will support. This controls the value of `MACOSX_DEPLOYMENT_TARGET` used when building the app.
158
159 ### `universal_build`
160
161 A Boolean, indicating whether Briefcase should build a universal app (i.e, an app that can target both x86_64 and ARM64). Defaults to `true`; if `false`, the binary will only be executable on the host platform on which it was built - i.e., if you build on an x86_64 machine, you will produce an x86_65 binary; if you build on an ARM64 machine, you will produce an ARM64 binary.
162
163 ## Document types { #macOS-document-types }
164
165 Internally, macOS uses Uniform Type Identifiers (UTIs) to track document types. UTIs are strings that uniquely identify a type of data. They are similar to MIME types, but they form a type hierarchy that allows for more complex relationships between types. For example, PDF files have the UTI `com.adobe.pdf`, which conforms to the UTI `public.data`, indicating that PDF files are a specific type of data, and also conforms to `public.content`, indicating that they are a type of document that can be shared via e.g. Airdrop. There is a long list of [standard UTIs defined by macOS](https://developer.apple.com/documentation/uniformtypeidentifiers/system-declared-uniform-type-identifiers).
166
167 These UTIs are then used to declare document types in an application's `Info.plist`. Briefcase will determine an appropriate declarations based on the MIME type that has been provided (or generated) for a document type. However, there are also some macOS-specific configuration items that can be used to override this default behavior to control how document types are presented on macOS.
168
169 ### Configuration options
170
171 The following macOS-specific configuration keys can be used in a document type declaration:
172
173 ### `macOS.CFBundleTypeRole`
174
175 [CFBundleTypeRole](https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundledocumenttypes/cfbundletyperole) declares the role the application plays with respect to the document type. Valid values are `Editor`, `Viewer`, `Shell`, `QLGenerator`, and `None`.
176
177 Briefcase will default to a role of `Viewer` for all document types.
178
179 ### `macOS.LSHandlerRank`
180
181 [LSHandlerRank](https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundledocumenttypes/lshandlerrank) defines the relative priority of this application when it comes to determining which application should open an application. Valid values are `Owner`, `Alternate`, `Default` and `None`.
182
183 Briefcase will default to a role of `Alternate` for any known MIME type, and `Owner` for any custom MIME type.
184
185 ### `macOS.LSItemContentTypes`
186
187 [LSItemContentTypes](https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundledocumenttypes/lsitemcontenttypes) define the UTI content types that the app can handle.
188
189 Briefcase defaults to the the registered UTI type for known MIME types. It will construct a UTI of the form `<bundle id>.<app name>.<document type id>` (e.g., `org.beeware.helloworld.document`) for unknown MIME types.
190
191 Although macOS technically allows an application to support multiple UTIs per document types, Briefcase can only assign a single content type. The value of [`macOS.LSItemContentTypes`][macoslsitemcontenttypes] must be a string, or a list containing a single value.
192
193 ### `macOS.UTTypeConformsTo`
194
195 [UTTypeConformsTo](https://developer.apple.com/documentation/BundleResources/Information-Property-List/UTExportedTypeDeclarations/UTTypeConformsTo) defines the list of UTIs that the document type conforms to. Each entry is a string.
196
197 Briefcase will assume a default of `["public.data", "public.content"]` for unknown MIME types. The value is not used for known mime types (as the operating system knows the conforming types).
198
199 ### `macOS.is_core_type`
200
201 A Boolean, used to explicitly declare a content type as a core type. This flag is used to determine whether a `UTImportedTypeDeclarations` entry is required in macOS app metadata.
202
203 You shouldn't need to set this value. Briefcase is able to determine whether a type is core or not based using data provided by the operating system.
204
205 ### Packages
206
207 macOS provides for document types that are *packages*. A package document is structured as a directory on disk, but presents to the user as a single icon. An `.app` bundle is an example of a package document type.
208
209 To define a package type, set [`macOS.UTTypeConformsTo`][macosuttypeconformsto] to `["com.apple.package", "public.content"]`. If other UTI types apply, they can also be added to this list.
210
211 ### Further customization
212
213 For more details on macOS document type declarations, see the following web pages from Apple provide more background information. They may be helpful in determining how to expose content types for your application:
214
215 - [Defining file and data types for your app](https://developer.apple.com/documentation/uniformtypeidentifiers/defining-file-and-data-types-for-your-app)
216 - [Uniform Type Identifiers — a reintroduction](https://developer.apple.com/videos/play/tech-talks/10696/?time=549)
217 - [Core Foundation Keys (archived)](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html)
218
219 ## Permissions
220
221 Briefcase cross platform permissions map to a combination of [`info`][] and [`entitlement`][] keys:
222
223 - [`permission.bluetooth`][permissionbluetooth]: an [`info`][] entry for `NSBluetoothAlwaysUsageDescription`; and an [`entitlement`][] of `com.apple.security.device.bluetooth`
224 - [`permission.camera`][permissioncamera]: an [`info`][] entry for `NSCameraUsageDescription`; and an [`entitlement`][] of `com.apple.security.device.camera`
225 - [`permission.microphone`][permissionmicrophone]: an [`info`][] entry for `NSMicrophoneUsageDescription`; and an [`entitlement`][] of `com.apple.security.device.audio-input`
226 - [`permission.coarse_location`][permissioncoarse_location]: an [`info`][] entry for `NSLocationUsageDescription` (ignored if [`permission.background_location`][permissionbackground_location] or [`permission.fine_location`][permissionfine_location] is defined); plus an entitlement of `com.apple.security.personal-information.location`
227 - [`permission.fine_location`][permissionfine_location]: an [`info`][] entry for `NSLocationUsageDescription`(ignored if [`permission.background_location`][permissionbackground_location] is defined); plus an [`entitlement`][] of `com.apple.security.personal-information.location`
228 - [`permission.background_location`][permissionbackground_location]: an [`info`][] entry for `NSLocationUsageDescription`; plus an [`entitlement`][] of `com.apple.security.personal-information.location`
229 - [`permission.photo_library`][permissionphoto_library]: an [`info`][] entry for `NSPhotoLibraryUsageDescription`; plus an [`entitlement`][] of `com.apple.security.personal-information.photos-library`
230
231 ## Platform quirks
232
233 ### Use of iCloud-synchronized folders
234
235 iCloud stores and maintains metadata on some content stored in iCloud-synchronized folders. Unfortunately, this metadata prevents apps from being signed and notarized, and app signing is a requirement for all apps on macOS. As a result, Briefcase cannot be used to generate macOS apps in a folder that is synchronized with iCloud.
236
237 This most commonly affects the <span class="title-ref">Documents</span> and <span class="title-ref">Desktop</span> folders (and subfolders), but can affect other locations if they are synchronized with iCloud.
238
239 ### Packaging with { #--adhoc-sign }`
240
241 Using the `--adhoc-sign` option on macOS produces an app that will be able to run on your own machine, but won't run on any other computer. In order to distribute your app to other users, you will need to sign the app with a full signing identity.
242
243 ### Inconsistent content in non-universal wheels
244
245 When building a universal app (i.e., an app that supports both arm64 and x86_64) that uses binary wheels, Briefcase will look for `universal2` multi-architecture wheels by default. However, if such a wheel is not available, Briefcase will download a platform-specific wheel for each platform, and then attempt to merge them into a single binary.
246
247 For most wheels, this approach works without difficulty. However, the wheels for some packages include slightly different content on each platform. NumPy is a notable example - it includes static libraries (`.a` files), headers (`.h` files), and a `__config__.py` file that records the configuration options that were used at the time the wheel was built.
248
249 These files cannot be merged, as they either contain fundamentally inconsistent content, or are in a binary format that doesn't allow for multi-architecture merging.
250
251 Briefcase will warn when it finds files that cannot be merged, and will fall back to copying the version matching the platform where Briefcase has been executed (i.e., if you're running on an arm64 MacBook, the version from the arm64 wheel will be copied). You must determine yourself whether this will cause a problem at runtime.
252
253 For many forms of content, the files that cannot be merged are **not** used at runtime. For example, the `.a` and `.h` files provided by NumPy exist so that code can statically link against NumPy. They are not needed at runtime by Python code that imports and uses NumPy.
254
255 If you determine that content is not needed at runtime, it can be removed from the app using the `cleanup_paths` configuration option:
256
257 ```python
258 cleanup_paths = [
259 "**/app_packages/**/*.a",
260 "**/app_packages/**/*.h",
261 ]
262 ```
263
264 This will find and purge all `.a` content and `.h` content in your app's dependencies. You can add additional patterns to remove other unneeded content.
265
266 ### Requirements cannot be provided as source tarballs
267
268 Briefcase *cannot* install packages published as source tarballs into a macOS app, even if the package is a pure Python package that would produce a `py3-none-any` wheel. This is an inherent limitation in the use of source tarballs as a distribution format.
269
270 If you need to install a package in a macOS app that is only published as a source tarball, you'll need to compile that package into a wheel first. If the package is pure Python, you can generate a `py3-none-any` wheel using `pip wheel <package name>`. If the project has a binary component, you will need to consult the documentation of the package to determine how to compile a wheel.
271
272 You can then directly add the wheel file to the [`requires`][] definition for your app, or put the wheel in a folder and add:
273
274 ```toml
275 requirement_installer_args = ["--find-links", "<path-to-wheel-folder>"]
276 ```
277
278 to your `pyproject.toml`. This will instruct Briefcase to search that folder for compatible wheels during the installation process.
279
280 ### Adapting to Liquid Glass (macOS 26 Tahoe)
281
282 macOS 26 (Tahoe) introduced the "Liquid Glass" style to macOS apps. The stub executable used by Briefcase has been compiled with Liquid Glass styling enabled; however, at this time, most GUI toolkits (including [Toga](https://github.com/beeware/toga/issues/4188) and [Qt](https://www.qt.io/blog/qt-on-macos-26-tahoe)) are known to have some bugs with Liquid Glass adoption.
283
284 If you find that your application looks bad on macOS 26, you can enable compatibility mode and revert to the style of earlier macOS releases. To enable compatibility mode, add the following to the macOS section of your `pyproject.toml` configuration:
285
286 ```toml
287 info."UIDesignRequiresCompatibility" = true
288 ```
289
290 Once you've made this change, re-run `briefcase create` for your application.