Skip to content

Xcode "Requested but did not find extension point" 错误解决指南

最后更新:2023年9月

问题描述

在升级到 Xcode 13.3 或更高版本后,许多 Flutter 开发者在构建 iOS 应用时会遇到如下错误:

bash
Error output from Xcode build:

    2022-03-02 17:45:38.148 xcodebuild[62848:6695836] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in
    com.apple.dt.IDEWatchSupportCore
    2022-03-02 17:45:38.148 xcodebuild[62848:6695836] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of
    plug-in com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **

这个错误信息显示 Xcode 在尝试查找与 watchOS 相关的扩展点时失败,即使你正在构建的是 iOS 应用。

解决方案总结

根据社区反馈,这个问题有多种可能的解决方案。建议按以下顺序尝试:

推荐解决路径

  1. 清理项目缓存和临时文件
  2. 检查并重置 Xcode 命令行工具
  3. 检查项目配置和依赖
  4. 尝试更高级的解决方案

详细解决方案

1. 基础清理步骤

首先尝试这些简单的解决方案,它们解决了大部分情况下的问题:

bash
flutter clean
flutter pub get
bash
rm -rf ~/Library/Developer/Xcode/DerivedData
bash
cd ios
rm Podfile.lock
pod repo update
pod install

2. Xcode 命令行工具修复

如果基础清理无效,可能是 Xcode 命令行工具配置问题:

bash
# 重置到默认路径
xcode-select -r

# 或手动链接到 CommandLineTools
sudo xcode-select -s /Library/Developer/CommandLineTools
bash
# 删除现有工具
sudo rm -rf /Library/Developer/CommandLineTools

# 重新安装
xcode-select --install

3. 项目配置修复

如果上述方法无效,可能需要检查项目配置:

检查 pubspec.yaml 文件

  • 确保版本号格式正确(使用引号包围)
  • 移除可能引起冲突的包(如 dart:htmldart:js

重新生成 iOS 目录

bash
# 备份重要文件(Info.plist、GoogleService-Info.plist 等)
flutter clean
rm -rf ios
flutter create .
# 将备份的文件复制回新生成的 ios 目录
cd ios
pod install

4. 高级解决方案

对于顽固情况,尝试以下方法:

方法一:更新系统和工具

bash
# 更新所有软件(包括命令行工具)
softwareupdate --all --install --force

方法二:切换 Flutter 频道

bash
flutter channel master
flutter upgrade

方法三:检查 Apple Watch 连接

  • 某些情况下,连接的 Apple Watch 可能导致构建问题
  • 尝试暂时关闭 Apple Watch 并重新构建

方法四:修改 Xcode 插件配置

谨慎操作

此方法涉及修改 Xcode 系统文件,操作前请备份

导航至文件:

/Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Xcode/PrivatePlugIns/IDEWatchSupportCore.ideplugin/Contents/Resources/IDEWatchSupportCore.xcplugindata

使用 Plist 编辑器删除以下条目:

  • Root/plug-in/extensions/Xcode.DebuggerFoundation.AppExtensionHosts.watchOS
  • Root/plug-in/extensions/Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS

预防措施

为避免此问题再次发生:

  1. 保持工具更新:定期更新 Xcode、命令行工具和 Flutter SDK
  2. 规范版本号格式:在 pubspec.yaml 中对版本号使用引号
  3. 谨慎升级:在升级主要版本前,先在测试项目中验证兼容性
  4. 使用版本控制:确保能回退到可工作的项目状态

结论

Xcode 的 "Requested but did not find extension point" 错误通常与缓存问题或工具链配置有关,而不是代码本身的问题。大多数情况下,通过清理缓存和重置工具配置即可解决。

如果遇到此问题,建议从最简单的解决方案开始尝试,逐步向更复杂的方案过渡。记得在尝试任何可能修改系统文件的解决方案前进行备份。

社区反馈

根据 StackOverflow 上的反馈,最有效的解决方案通常是:

  1. 删除 DerivedData 目录(成功率约 30%)
  2. 清理 Flutter 缓存和重新获取依赖(成功率约 25%)
  3. 重置 Xcode 命令行工具(成功率约 20%)

希望本指南能帮助你顺利解决构建问题,继续你的 Flutter 开发工作。