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

Flutter iOS模拟器编译报错:找不到FlutterLocalNotificationsPlugin

解决iOS模拟器中Flutter项目编译错误:Cannot find 'FlutterLocalNotificationsPlugin' in scope

问题描述

在iOS(iPhone)模拟器运行Flutter项目时,出现以下编译错误:

Xcode build done.                                           12.7s
Failed to build iOS app
Swift Compiler Error (Xcode): Cannot find 'FlutterLocalNotificationsPlugin' in scope
/Users/mojamal/Desktop/nesp_application/ios/Runner/AppDelegate.swift:14:42

Could not build the application for the simulator.
Error launching application on iPhone 15 Pro Max.

已尝试以下操作但未解决:

  • 回退至历史提交记录排查
  • 执行flutter pub upgrade → flutter pub get → flutter clean → flutter build ios → cd ios → pod install命令序列

同时收到代码签名证书提示,该提示与当前编译错误无关,可忽略。

解决方案

1. 检查AppDelegate.swift的导入语句

打开ios/Runner/AppDelegate.swift,确保文件顶部添加了插件的导入:

import FlutterLocalNotificationsPlugin

2. 验证依赖配置

  • 确认pubspec.yaml中已正确声明flutter_local_notifications依赖,版本适配当前Flutter版本
  • 执行flutter pub get后,检查ios/Podfile.lock文件中是否存在FlutterLocalNotificationsPlugin的相关记录

3. 重新生成插件注册文件

删除ios/Runner/GeneratedPluginRegistrant.swift,然后执行:

flutter clean
flutter pub get

Flutter会自动重新生成插件注册文件,确保插件被正确注册。

4. 彻底重置Pod依赖

执行以下命令清理并重新安装Pod:

cd ios
pod deintegrate
pod install

5. Xcode清理构建

打开ios/Runner.xcworkspace,执行:

Product > Clean Build Folder
然后重新构建项目。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 01:32:37