You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native iOS Share Sheet扩展未出现在建议列表求助

解决React Native iOS分享扩展突然失效的问题

1. 修复NSExtensionActivationRule配置

你的Info.plist激活规则覆盖场景不够全面,且PHSupportedMediaTypes属于Photos框架专属配置,和分享扩展的激活规则易产生冲突。建议替换并简化激活规则配置:

<key>NSExtensionActivationRule</key>
<dict>
    <key>NSExtensionActivationSupportsImageWithMaxCount</key>
    <integer>100</integer>
    <key>NSExtensionActivationSupportsMovieWithMaxCount</key>
    <integer>100</integer>
    <key>NSExtensionActivationSupportsText</key>
    <true/>
    <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
    <integer>100</integer>
    <key>NSExtensionActivationSupportsFileWithMaxCount</key>
    <integer>100</integer>
</dict>

同时移除PHSupportedMediaTypes键值对,避免冗余配置干扰。

2. 清除Launch Services缓存

日志中的NSOSStatusErrorDomain Code=-10814是Launch Services缓存异常导致的,执行以下步骤清理:

  • 关闭模拟器和Xcode
  • 打开终端,运行命令(替换设备ID为日志中的6F5B70E6-6AE4-43FB-B5BC-82C38DFB35CD):
    killall -9 com.apple.CoreSimulator.CoreSimulatorService
    rm -rf ~/Library/Developer/CoreSimulator/Devices/6F5B70E6-6AE4-43FB-B5BC-82C38DFB35CD/data/Library/Caches/com.apple.LaunchServices-0005.csstore
    
  • 重启模拟器和Xcode,重新安装主应用与扩展

3. 修复文件访问权限

NSCocoaErrorDomain Code=3328说明扩展无法正常访问共享容器文件,需确认:

  • 主应用与扩展的App Group名称完全一致,无拼写错误
  • 在扩展Info.plist中添加NSAppGroupUsageDescription键,补充访问App Group的用途说明
  • 扩展中获取文件时,必须通过App Group容器URL访问,而非直接使用传入的原始文件URL:
    NSURL *groupContainerURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:@"你的App Group ID"];
    NSURL *targetFileURL = [groupContainerURL URLByAppendingPathComponent:@"File Provider Storage/Downloads/dance-studio-invoice-design/7455237.jpg"];
    

4. 重置Xcode构建缓存

Xcode构建缓存异常也会导致扩展失效,执行以下操作:

  • 清理项目:Cmd+Shift+K
  • 删除Derived Data:Xcode → Settings → Locations → Derived Data → 点击箭头打开文件夹并删除所有内容
  • 重新构建主应用和扩展目标
  • 直接运行扩展目标,再在模拟器中触发分享操作

5. 验证签名与基础配置

  • 主应用与扩展的Bundle ID需符合后缀规则(如主应用为com.yourapp,扩展应为com.yourapp.shareextension)
  • 两者的部署目标版本完全一致,无版本差
  • 在Xcode Capabilities中确认App Group已开启,且勾选了同一个Group

内容的提问来源于stack exchange,提问作者MDIPANJAN

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 21:43:13