Unity macOS
Build your Unity project with Hive SDK as a macOS app, then sign it for your distribution method.
Requirements¶
- macOS 15 or later
- Only Apple Silicon (arm64) builds are supported.
- Build in the Unity Editor for macOS. The Unity Editor for Windows does not copy the SDK frameworks into the app bundle.
Pre-build settings¶
Before building, open File > Build Settings... in the Unity Editor and check the target platform and player settings.
- Configure the build.
- Target platform: macOS
- Architecture: Apple Silicon
- Create Xcode Project: Leave unchecked.
- To configure the player, click Player Settings... at the lower left of the Build Settings... window or select Player in the Inspector window.
- Scripting Backend: IL2CPP
- Bundle Identifier: The bundle ID of the app registered in Hive Console
- Prepare hive_config.xml. Select macOS in Unity Config Editor to create Assets/Plugins/macOS/res/hive_config.xml.
Warning
Hive SDK Unity for macOS does not support Create Xcode Project. If you enable this option, the Xcode project will omit the SDK files listed in Post-build processing, so an app built in Xcode will fail to load the SDK. Leave the option unchecked and build an app bundle (.app).
Post-build processing¶
When Unity finishes the build, Assets/Hive_SDK_v4/Editor/PostProcess/HivePostprocess.cs copies these files into the app bundle (.app).
| Source | Location in the app bundle | Notes |
|---|---|---|
| Assets/Plugins/macOS/res/hive_config.xml | Contents/Resources/hive_config.xml | |
| Assets/Hive_SDK_v4/Plugins/desktop/hive_string | Contents/Resources/hive_string | |
| Assets/Hive_SDK_v4/Plugins/macOS/libHIVE_SERVICE.dylib | Contents/Frameworks/libHIVE_SERVICE.dylib | Required. The SDK fails to load without this file. |
| Assets/Hive_SDK_v4/Plugins/macOS/HIVEUIFramework.framework | Contents/Frameworks/HIVEUIFramework.framework | Required. The SDK fails to load without this framework. |
| Assets/Hive_SDK_v4/Plugins/macOS/AppleFramework.framework | Contents/Frameworks/AppleFramework.framework | Used for Sign in with Apple, Mac App Store purchases, and Age Range. Only these features stop working if the framework is missing. |
Warning
The SDK plugin (HIVE_PLUGIN.bundle) looks for these files in Contents/Frameworks. Keep the copied files in their original locations. If a required file is missing, the Unity Console logs an error. Reinstall the Hive SDK macOS package if this occurs.
Configure entitlements¶
Unity and Hive SDK post-build processing do not create an entitlements file for macOS apps. Create the entitlements file for app signing and add the keys needed for your distribution method and features. For Developer ID distribution, use only the keys that method supports.
- File format: A plist text file with the .entitlements extension
- File location: Save the file anywhere. For example, save it as
macOS/<APP_NAME>.entitlementsin the Unity project. Avoid the build output folder because Unity can overwrite it on the next build. - Usage: Specify the file with the
--entitlementsoption of thecodesigncommand in Signing and distribution.
| Key | Feature | Mac App Store, TestFlight | Developer ID |
|---|---|---|---|
com.apple.developer.applesignin | Sign in with Apple | Add when using this feature. Enable Sign in with Apple for the App ID in the Apple Developer portal. | Omit this key. The app fails to launch if you include it. |
com.apple.developer.declared-age-range | Age Range | Add when using this feature. The provisioning profile must allow it. | Omit this key. Age Range applies to apps distributed through the store, and Developer ID distribution does not support Mac App Store purchases (In-App Purchase). |
com.apple.security.app-sandbox | App Sandbox | Required | Optional |
com.apple.security.network.client | Hive SDK server communication | Required | Required if you use App Sandbox |
com.apple.security.network.server | Google and X login, identity verification, adult verification, parental consent | Required | Required if you use App Sandbox |
com.apple.security.files.user-selected.read-only | Profile image selection and WebView attachments | Required | Required if you use App Sandbox |
com.apple.security.network.client: Without this key, server communication fails during SDK initialization, login, and similar operations.com.apple.security.network.server: The app receives the result from the external browser on a local port (127.0.0.1). Without this key, the browser may fail to open or the app may fail to receive the result.com.apple.security.files.user-selected.read-only: Without this key, the file picker fails to open.- Mac App Store, TestFlight explains the additional
com.apple.application-identifierandcom.apple.developer.team-identifierkeys for Mac App Store distribution. Omit them for Developer ID distribution.
Note
See Apple's Supported capabilities (macOS) for feature availability by distribution method. The Developer ID column shows that Sign in with Apple, In-App Purchase, and Game Center are unsupported.
<?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>com.apple.developer.applesignin</key>
<array>
<string>Default</string>
</array>
<key>com.apple.developer.declared-age-range</key>
<true/>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
The com.apple.developer.applesignin and com.apple.developer.declared-age-range keys are omitted. If you do not use App Sandbox, you can also omit all com.apple.security.* keys.
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
Note
Unity builds the app without App Sandbox, so local testing may not reveal missing entitlements. After you sign the app with App Sandbox for a Mac App Store or TestFlight build, Hive SDK server communication and services such as Google and X login may fail. Before distribution, run the command below to verify that the signed app includes com.apple.security.app-sandbox, com.apple.security.network.client, and com.apple.security.network.server.
Verify the entitlements with the following command.
Signing and distribution¶
Sign the built app in a terminal according to your distribution method. The examples use --deep to also sign frameworks and libraries in Contents/Frameworks and Contents/PlugIns inside the app bundle.
Mac App Store, TestFlight¶
Prerequisites¶
| Item | Description |
|---|---|
| Apple Distribution certificate | Used to sign the app. Install it in the keychain. |
| Mac Installer Distribution certificate | Used to sign the .pkg file. It appears in the keychain as 3rd Party Mac Developer Installer. |
| Mac App Store provisioning profile | The .provisionprofile file created in the Apple Developer portal using the app's bundle ID. |
| Entitlements file | The file you created in Configure entitlements. |
Use the following commands to check which certificates are installed.
security find-identity -v -p codesigning # Apple Distribution
security find-identity -v # 3rd Party Mac Developer Installer
Additional entitlements keys¶
To sign for Mac App Store distribution, add the two keys below to the entitlements file in addition to the keys in Configure entitlements. Their values must match the provisioning profile.
<key>com.apple.application-identifier</key>
<string><TEAM_ID>.<BUNDLE_ID></string>
<key>com.apple.developer.team-identifier</key>
<string><TEAM_ID></string>
Sign the app and create the .pkg file¶
-
Check the app version. The Mac App Store accepts up to three numeric components in
CFBundleShortVersionString. Set Version in Unity Player Settings to a format such as1.0.0, or update it with the following command. -
Include the provisioning profile in the app bundle.
-
Sign the app.
codesign --force --deep --timestamp \ --sign "Apple Distribution: <TEAM_NAME> (<TEAM_ID>)" \ --entitlements macOS/<APP_NAME>.entitlements \ <APP_NAME>.appIf two or more certificates have the same name in the keychain, the command returns an
ambiguouserror. In that case, pass the 40-character hash returned bysecurity find-identity -v -p codesigningto--sign. -
Create the .pkg file.
-
Verify the signatures.
-
Use Transporter to upload the .pkg file to App Store Connect.
Distribution outside the Mac App Store (Developer ID)¶
To distribute the app directly from a website or another channel outside the Mac App Store, submit the Developer ID-signed app to Apple for notarization. Gatekeeper blocks apps that have not been notarized when users try to open them.
Unsupported features¶
Apple does not support the following features for macOS apps distributed with Developer ID. Check the Developer ID column in Apple's Supported capabilities (macOS). If your app needs these features, distribute it through Mac App Store, TestFlight.
| Feature | Notes |
|---|---|
| Sign in with Apple | The Developer ID provisioning profile does not include the com.apple.developer.applesignin entitlement. |
| Mac App Store purchases (In-App Purchase) | This method does not use Mac App Store purchases, so Age Range, which applies to store-distributed apps, does not apply. |
| Game Center |
Warning
If you sign with Developer ID while the entitlements file includes com.apple.developer.applesignin or com.apple.developer.declared-age-range, the app fails to launch. Remove these keys from the entitlements file for Developer ID distribution.
Prerequisites¶
| Item | Description |
|---|---|
| Developer ID Application certificate | Used to sign the app and the .dmg file. Install it in the keychain. There is no separate notarization certificate. |
| App Store Connect API key | Used to submit the app for notarization. You need the .p8 file created in Users and Access > Integrations > App Store Connect API in App Store Connect, its Key ID, and the Issuer ID. |
| Entitlements file | The file you created in Configure entitlements. Omit com.apple.developer.applesignin and com.apple.developer.declared-age-range. |
Developer ID distribution does not require a provisioning profile.
Sign and notarize the app¶
-
Sign the app. Apple rejects notarization submissions without Hardened Runtime (
--options runtime) and a secure timestamp (--timestamp). -
Create and sign the .dmg file.
-
Submit the app for notarization. With
--wait, the command waits for the result. This usually takes a few minutes.xcrun notarytool submit <APP_NAME>.dmg \ --key AuthKey_<KEY_ID>.p8 --key-id <KEY_ID> --issuer <ISSUER_ID> \ --waitIf the result is
Invalid, run the following command to see why. -
Staple the notarization ticket to the .dmg file. This lets users launch the app offline.
-
Verify the signature and notarization.
codesign --verify --deep --strict --verbose=2 <APP_NAME>.app xcrun stapler validate <APP_NAME>.dmg spctl -a -t open --context context:primary-signature -vv <APP_NAME>.dmgThe app is ready for distribution when
spctlreportsacceptedandsource=Notarized Developer ID.