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

Facebook授权登录时App崩溃,已配置URL Scheme仍报错求助

解决Facebook授权时因URL Scheme未注册导致的闪退问题

问题详情

点击Facebook授权按钮后应用直接闪退,Xcode控制台抛出异常:

Terminating app due to uncaught exception 'InvalidOperationException', reason: 'fb6259922858****' is not registered as a URL scheme. Please add it in your Info.plist

用户已配置的Info.plist内容如下:

<key>CFBundleURLTypes</key>
<array>
  <dict>
  <key>CFBundleURLSchemes</key>
  <array>
    <string>fb6259922858*****</string>
  </array>
  </dict>
</array>
<key>FacebookAppID</key>
<string>6259922858*****</string>
<key>FacebookClientToken</key>
<string>ecbb0530f7ba58151a053ce5****</string>
<key>FacebookDisplayName</key>
<string>Helpster</string>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>fbapi</string>
  <string>fb-messenger-share-api</string>
  <string>fbauth2</string>
  <string>fbshareextension</string>
</array>

排查与解决步骤

  • 核对URL Scheme拼写:确保CFBundleURLSchemes里的fb6259922858*****和异常提示的fb6259922858****完全一致,检查末尾星号对应的实际字符是否有遗漏、拼写错误,注意大小写(iOS虽不区分大小写,但严格匹配更稳妥)。
  • 补全URLTypes结构:给CFBundleURLTypes下的字典添加CFBundleURLName字段(可选但能避免配置识别问题),示例结构:
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>com.yourcompany.yourapp</string> <!-- 替换为你的应用Bundle ID -->
        <key>CFBundleURLSchemes</key>
        <array>
          <string>fb6259922858*****</string>
        </array>
      </dict>
    </array>
    
  • 清理重建项目:
    1. 关闭Xcode,删除项目的DerivedData文件夹(路径:~/Library/Developer/Xcode/DerivedData)
    2. 重新打开项目,按Shift+Command+K执行Clean Build Folder
    3. 重新运行项目
  • 检查Target配置:如果项目有多个Target,确认当前运行的Target的Info.plist里确实添加了该URL Scheme,别配置到了错误的Target上。
  • 验证AppID匹配性:确认FacebookAppID的数字部分和URL Scheme里fb后面的数字完全一致,当前配置里这部分是匹配的,但再核对一遍实际的Facebook AppID是否正确。

内容的提问来源于stack exchange,提问作者steind.VY

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.17 07:10:32