尝试运行 iOS Flutter 应用程序时,我在 AppDelegate.swift 文件中遇到以下错误:
No such module 'Flutter'
这就是我在调试控制台中得到的
Launching lib/main_dev.dart on iPhone 15 Pro Max in debug mode...
CocoaPods' output:
↳
Preparing
Analyzing dependencies
Inspecting targets to integrate
Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)
Using `ARCHS` setting to build architectures of target `Pods-OneSignalNotificationServiceExtension`: (``)
Fetching external sources
-> Fetching podspec for `Flutter` from `Flutter`
-> Fetching podspec for `app_links` from `.symlinks/plugins/app_links/ios`
-> Fetching podspec for `cloud_firestore` from `.symlinks/plugins/cloud_firestore/ios`
cloud_firestore: Using Firebase SDK version '11.2.0' defined in 'firebase_core'
-> Fetching podspec for `connectivity_plus` from `.symlinks/plugins/connectivity_plus/darwin`
-> Fetching podspec for `device_info_plus` from `.symlinks/plugins/device_info_plus/ios`
-> Fetching podspec for `firebase_analytics` from `.symlinks/plugins/firebase_analytics/ios`
firebase_analytics: Using Firebase SDK version '11.2.0' defined in 'firebase_core'
-> Fetching podspec for `firebase_auth` from `.symlinks/plugins/firebase_auth/ios`
firebase_auth: Using Firebase SDK version '11.2.0' defined in 'firebase_core'
-> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
firebase_core: Using Firebase SDK version '11.2.0' defined in 'firebase_core'
-> Fetching podspec for `firebase_storage` from `.symlinks/plugins/firebase_storage/ios`
firebase_storage: Using Firebase SDK version '11.2.0' defined in 'firebase_core'
-> Fetching podspec for `flutter_native_splash` from `.symlinks/plugins/flutter_native_splash/ios`
-> Fetching podspec for `image_picker_ios` from `.symlinks/plugins/image_picker_ios/ios`
-> Fetching podspec for `onesignal_flutter` from `.symlinks/plugins/onesignal_flutter/ios`
-> Fetching podspec for `package_info_plus` from `.symlinks/plugins/package_info_plus/ios`
-> Fetching podspec for `path_provider_foundation` from `.symlinks/plugins/path_provider_foundation/darwin`
-> Fetching podspec for `permission_handler_apple` from `.symlinks/plugins/permission_handler_apple/ios`
-> Fetching podspec for `share_plus` from `.symlinks/plugins/share_plus/ios`
-> Fetching podspec for `shared_preferences_foundation` from `.symlinks/plugins/shared_preferences_foundation/darwin`
-> Fetching podspec for `sqflite_darwin` from `.symlinks/plugins/sqflite_darwin/darwin`
-> Fetching podspec for `url_launcher_ios` from `.symlinks/plugins/url_launcher_ios/ios`
-> Fetching podspec for `video_player_avfoundation` from `.symlinks/plugins/video_player_avfoundation/darwin`
-> Fetching podspec for `webview_flutter_wkwebview` from `.symlinks/plugins/webview_flutter_wkwebview/darwin`
Resolving dependencies of `Podfile`
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_d_f_3.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/d/f/3/OneSignalXCFramework/5.3.0-beta-01/OneSignalXCFramework.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_4_2_c.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/4/2/c/FlutterMacOS/3.16.0/FlutterMacOS.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.3.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.2.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.2.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.2.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.2.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/3/5/Firebase/11.2.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_0_9_f.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/9/f/FirebaseFirestore/11.3.0/FirebaseFirestore.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/0/9/f/FirebaseFirestore/11.2.0/FirebaseFirestore.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_8_b_d.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/8/b/d/FirebaseCore/11.3.0/FirebaseCore.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_4_7_f.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/4/7/f/FirebaseCoreExtension/11.3.0/FirebaseCoreExtension.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_3_1_8.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/1/8/FirebaseFirestoreInternal/11.3.0/FirebaseFirestoreInternal.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_b_c_7.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/b/c/7/FirebaseSharedSwift/11.3.0/FirebaseSharedSwift.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/1/8/FirebaseFirestoreInternal/11.2.0/FirebaseFirestoreInternal.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_e_9_8.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/e/9/8/FirebaseAppCheckInterop/11.3.0/FirebaseAppCheckInterop.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_3_8_6.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240722.0/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.1/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/3/8/6/abseil/1.20240116.2/abseil.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: all_pods_versions_9_1_0.txt exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: Specs/9/1/0/gRPC-Core/1.67.0-pre1/gRPC-Core.podspec.json exists! Returning local because checking is only performed in repo update
CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
### Command
```
/usr/local/bin/pod install --verbose
```
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
CocoaPods : 1.15.2
Ruby : ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin22]
RubyGems : 3.0.3.1
Host : macOS 13.7 (22H123)
Xcode : 15.2 (15C500b)
Git : git version 2.23.0
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/
```
### Plugins
```
cocoapods-deintegrate : 1.0.4
cocoapods-plugins : 1.0.0
cocoapods-search : 1.0.0
cocoapods-stats : 1.1.0
cocoapods-trunk : 1.6.0
cocoapods-try : 1.2.0
```
### Podfile
```ruby
# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
# pod 'FirebaseFirestore', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git', :tag => '10.18.0'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
target 'OneSignalNotificationServiceExtension' do
use_frameworks!
pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# Start of the permission_handler configuration
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
]
end
# End of the permission_handler configuration
end
end
```
### Error
```
JSON::ParserError - Failed to parse JSON at file: '/Users/alimazen/.cocoapods/repos/trunk/Specs/9/1/0/gRPC-Core/1.67.0-pre1/gRPC-Core.podspec.json'.
416: unexpected token at '"src/core/ext/upb-gen/envoy/'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification/json.rb:66:in `rescue in from_json'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification/json.rb:61:in `from_json'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification.rb:759:in `from_string'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification.rb:733:in `from_file'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/source.rb:188:in `specification'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification/set.rb:58:in `block in specification_name'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification/set.rb:56:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/specification/set.rb:56:in `specification_name'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/cdn_source.rb:216:in `search'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/source/aggregate.rb:83:in `block in search'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/source/aggregate.rb:83:in `select'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/source/aggregate.rb:83:in `search'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:416:in `create_set_from_sources'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:385:in `find_cached_set'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:360:in `specifications_for_dependency'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:165:in `search_for'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:274:in `block in sort_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:267:in `each'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:267:in `sort_by'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:267:in `sort_by!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:267:in `sort_dependencies'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:60:in `block in sort_dependencies'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:77:in `with_no_such_dependency_error_handling'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/delegates/specification_provider.rb:59:in `sort_dependencies'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:754:in `push_state_for_requirements'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:744:in `require_nested_dependencies_for'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:727:in `activate_new_spec'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:684:in `attempt_to_activate'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:254:in `process_topmost_state'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:182:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:43:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/resolver.rb:94:in `resolve'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1082:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:1080:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/analyzer.rb:125:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:422:in `analyze'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:244:in `block in resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:243:in `resolve_dependencies'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:162:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
```
――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
[!] Oh no, an error occurred.
Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=Failed+to+parse+JSON+at+file%3A+%27%2FUsers%2Falimazen%2F.cocoapods%2Frepos%2Ftrunk%2FSpecs%2F9%2F1%2F0%2FgRPC-Core%2F1.67.0-pre1%2FgRPC-Core.podspec.json%27.%0A%0A416%3A+unexpected+token+at+%27%22src%2Fcore%2Fext%2Fupb-gen%2Fenvoy%2F%27&type=Issues
If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new
Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
Don't forget to anonymize any private data!
Looking for related issues on cocoapods/cocoapods...
Found no similar issues. To create a new issue, please visit:
https://github.com/cocoapods/cocoapods/issues/new
Error running pod install
Error launching application on iPhone 15 Pro Max.
Exited (1).
这是我的 Podfile
# Uncomment this line to define a global platform for your project
platform :ios, '13.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# Start of the permission_handler configuration
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.camera
'PERMISSION_CAMERA=1',
## dart: PermissionGroup.photos
'PERMISSION_PHOTOS=1',
]
end
# End of the permission_handler configuration
end
end
target 'OneSignalNotificationServiceExtension' do
use_frameworks!
pod 'OneSignalXCFramework', '>= 5.0.0', '< 6.0'
end
这是我的 AppDelegate.swift 文件
import UIKit
import Flutter
//import FirebaseCore
import FirebaseDynamicLinks
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
DynamicLinks.performDiagnostics(completion: nil)
// FirebaseApp.configure()
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
我尝试清理项目、删除 pod、podfile.lock,但都不起作用。 我认为这不相关,但我设置了口味(main_dev,main_prod)。
我尝试运行另一个 ios 应用程序,它成功了。对于这个应用程序来说,它没有。那么有人知道如何解决这个问题吗?我花了几天时间试图解决它。
按照此步骤操作: