iOS 能力
编辑页面
了解 EAS Build 支持的内置 iOS 能力,以及如何启用或禁用它们。
For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.
当你对 iOS entitlements 进行更改时,在生成生产构建之前,这些更改需要先远程更新到 Apple 的服务器上。EAS Build 会在你运行 eas build 时,自动将 Apple Developer Console 上的 capabilities 与你的本地 entitlements 配置同步。Capabilities 是 Apple 提供的网络服务,可以把它们理解为 AWS 或 Firebase 这类服务。
可通过
EXPO_NO_CAPABILITY_SYNC=1 eas build禁用此功能
Entitlements
在 Expo 应用中,entitlements 会从 introspected app config 中读取。要编辑它们,请查看你的 app config 文件中的 ios.entitlements 字段。你可以在项目中运行 npx expo config --type introspect 来查看 introspected config,然后在结果中查找 ios.entitlements 对象。
在裸 React Native 应用中,entitlements 会从你的 ios/**/*.entitlements 文件中读取。
启用
如果 entitlements 文件中存在受支持的 entitlement,那么运行 eas build 时会在 Apple Developer Console 上启用它。如果该 capability 已经启用,EAS Build 会跳过它。
禁用
如果某个 capability 已在远程为你的应用启用,但 native entitlements 文件中不存在它,那么运行 eas build 时会自动将其禁用。
支持的 capabilities
EAS Build 只会启用它内置支持的 capabilities,任何不受支持的 entitlements 都必须通过 Apple Developer Console 手动启用。
| 支持 | Capability | Entitlement string |
|---|---|---|
| 访问 Wi-Fi 信息 | com.apple.developer.networking.wifi-info | |
| App Attest | com.apple.developer.devicecheck.appattest-environment | |
| App Groups | com.apple.security.application-groups | |
| Apple Pay Later Merchandising | com.apple.developer.pay-later-merchandising | |
| Apple Pay 支付处理 | com.apple.developer.in-app-payments | |
| 关联域名 | com.apple.developer.associated-domains | |
| AutoFill Credential Provider | com.apple.developer.authentication-services.autofill-credential-provider | |
| ClassKit | com.apple.developer.ClassKit-environment | |
| 与驱动程序通信 | com.apple.developer.driverkit.communicates-with-drivers | |
| 通知式通信 | com.apple.developer.usernotifications.communication | |
| 自定义网络协议 | com.apple.developer.networking.custom-protocol | |
| 数据保护 | com.apple.developer.default-data-protection | |
| DriverKit 允许第三方 UserClients | com.apple.developer.driverkit.allow-third-party-userclients | |
| DriverKit Audio 家族(development) | com.apple.developer.driverkit.family.audio | |
| DriverKit HID Device 家族(development) | com.apple.developer.driverkit.family.hid.device | |
| DriverKit HID EventService 家族(development) | com.apple.developer.driverkit.family.hid.eventservice | |
| DriverKit Networking 家族(development) | com.apple.developer.driverkit.family.networking | |
| DriverKit SCSIController 家族(development) | com.apple.developer.driverkit.family.scsicontroller | |
| DriverKit Serial 家族(development) | com.apple.developer.driverkit.family.serial | |
| DriverKit Transport HID(development) | com.apple.developer.driverkit.transport.hid | |
| DriverKit USB Transport(development) | com.apple.developer.driverkit.transport.usb | |
| 用于开发的 DriverKit | com.apple.developer.driverkit | |
| 扩展虚拟地址空间 | com.apple.developer.kernel.extended-virtual-addressing | |
| Family Controls | com.apple.developer.family-controls | |
| FileProvider 测试模式 | com.apple.developer.fileprovider.testing-mode | |
| 字体 | com.apple.developer.user-fonts | |
| 群组活动 | com.apple.developer.group-session | |
| HealthKit | com.apple.developer.healthkit | |
| HomeKit | com.apple.developer.homekit | |
| 热点 | com.apple.developer.networking.HotspotConfiguration | |
| 增加内存限制 | com.apple.developer.kernel.increased-memory-limit | |
| 应用间音频 | inter-app-audio | |
| Journaling Suggestions | com.apple.developer.journal.allow | |
| 低延迟 HLS | com.apple.developer.low-latency-streaming | |
| MDM 管理的关联域名 | com.apple.developer.associated-domains.mdm-managed | |
| 托管应用安装 UI | com.apple.developer.managed-app-distribution.install-ui | |
| 地图 | com.apple.developer.maps | |
| Matter 允许设置负载 | com.apple.developer.matter.allow-setup-payload | |
| 媒体设备发现 | com.apple.developer.media-device-discovery-extension | |
| Messages 协作 | com.apple.developer.shared-with-you.collaboration | |
| Multipath | com.apple.developer.networking.multipath | |
| NFC 标签读取 | com.apple.developer.nfc.readersession.formats | |
| 网络扩展 | com.apple.developer.networking.networkextension | |
| 5G 网络切片 | com.apple.developer.networking.slicing.appcategory or com.apple.developer.networking.slicing.trafficcategory | |
| App Clip 扩展的按需安装能力 | com.apple.developer.on-demand-install-capable | |
| Personal VPN | com.apple.developer.networking.vpn.api | |
| 推送通知 | aps-environment | |
| 按住说话 | com.apple.developer.push-to-talk | |
| 重新校准估算 | com.apple.developer.healthkit.recalibrate-estimates | |
| 敏感内容分析 | com.apple.developer.sensitivecontentanalysis.client | |
| 浅水与压力 | com.apple.developer.submerged-shallow-depth-and-pressure | |
| 与你共享 | com.apple.developer.shared-with-you | |
| 使用 Apple 登录 | com.apple.developer.applesignin | |
| SiriKit | com.apple.developer.siri | |
| 系统扩展 | com.apple.developer.system-extension.install | |
| 在 iPhone 上轻点支付 | com.apple.developer.proximity-reader.payment.acceptance | |
| 在 iPhone 上轻点出示 ID(仅显示) | com.apple.developer.proximity-reader.identity.display | |
| TV 服务 | com.apple.developer.user-management | |
| 时间敏感通知 | com.apple.developer.usernotifications.time-sensitive | |
| Wallet | com.apple.developer.pass-type-identifiers | |
| WeatherKit | com.apple.developer.weatherkit | |
| 无线配件配置 | com.apple.external-accessory.wireless-configuration | |
| iCloud | com.apple.developer.icloud-container-identifiers | |
| HLS 插播预览 | Unknown |
不受支持的 capabilities 要么不支持 iOS,要么没有对应的 entitlement 值。以下是所有 Apple 官方 capabilities 的列表。
能力标识符
商家 ID、App 组和 CloudKit 容器都可以自动注册并分配给你的应用。这些分配需要 Apple cookies 身份验证(在本地运行),因为官方的 App Store Connect API 不支持这些操作。
iOS 能力调试
你可以运行 EXPO_DEBUG=1 eas build 来获取有关能力同步的更详细日志。
如果你在使用此功能时遇到问题,可以通过环境变量 EXPO_NO_CAPABILITY_SYNC=1 将其禁用。
要查看当前已启用的所有能力,请访问 Apple Developer Console,并找到与你的应用匹配的 bundle identifier;如果你点击它,应该会看到当前所有已启用能力的列表。
手动设置
有两种方式可以手动启用 Apple 能力,这两种方式都需要重新生成任何现有的 Apple provisioning profiles。
Xcode
适用于不使用 Expo Prebuild 持续生成本地 android 和 ios 目录的项目的首选方法。
- 使用
xed ios在 Xcode 中打开 ios 目录。如果你没有 ios 目录,请运行npx expo prebuild -p ios来生成一个。 - 然后按照 添加能力 中提到的步骤进行操作。
Apple Developer Console
第一步是在你的 ios/[app]/[app].entitlements 中添加相应的键值对(对于多目标应用,则添加到更具体的 entitlements 文件中)。你可以参考 支持的能力 来确定应添加哪些 entitlements 键。
- 登录 Apple Developer Console。点击 "Certificates, IDs & Profiles",然后进入 "Identifiers" 页面。
- 选择与你的应用 bundle identifier 匹配的 bundle identifier。
- 向下滚动并启用某项能力,某些能力可能需要额外设置。
- 滚动到顶部并点击 "Save"。你会看到一个写着 "Modify App Capabilities" 的对话框,点击 "Confirm" 继续。你需要重新生成任何使用此 bundle identifier 的 provisioning profiles,之后它们才会在构建已签名代码的生产 .ipa 时有效。
如果添加能力的过程没有正确完成,那么你的 iOS 原生构建将会失败,并出现类似如下的错误:
❌ error: Provisioning profile "*[expo] app.bacon.hello AppStore ..." doesn't support the Associated Domains capability. ❌ error: Provisioning profile "*[expo] app.bacon.hello AppStore ..." doesn't include the com.apple.developer.associated-domains entitlement.