Flutter iOS模拟器构建失败求助:prod环境运行报错
Flutter iOS多环境(Flavor)构建失败求助
我执行命令:
flutter run --verbose --flavor prod -t lib/main_prod.dart
运行Flutter iOS应用时,出现以下错误:
[+1599 ms] Could not build the application for the simulator. [ ] Error launching application on iPhone 14 Pro Max. [ +1 ms] "flutter run" took 98,846ms. [ +1 ms] #0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3) #1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:713:9) <asynchronous suspension> #2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1209:27) <asynchronous suspension> #3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #4 CommandRunner.runCommand (package:args/command_runner.dart:209:13) <asynchronous suspension> #5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) <asynchronous suspension> #6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) <asynchronous suspension> #8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9) <asynchronous suspension> #9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19) <asynchronous suspension> #10 main (package:flutter_tools/executable.dart:91:3) <asynchronous suspension>
我已完成多环境配置,Android端构建正常,但iOS端运行报错。附上项目的Info.plist内容:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>NSCameraUsageDescription</key> <string>This app needs to take camera access as user can take picture of his/her documents and save it for his/her profile.</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>magica_maids</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>$(FLUTTER_BUILD_NAME)</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>$(FLUTTER_BUILD_NUMBER)</string> <key>LSRequiresIPhoneOS</key> <true/> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UIViewControllerBasedStatusBarAppearance</key> <false/> <key>CADisableMinimumFrameDurationOnPhone</key> <true/> </dict> </plist>
排查建议
- 检查Xcode中的Flavor配置:确认
prodscheme对应的Target是否配置了正确的Bundle ID、签名信息,且关联的Info.plist文件路径无误 - 清理构建缓存:执行
flutter clean,删除iOS目录下的Pods文件夹和Podfile.lock,重新运行pod install后再尝试构建 - 查看Xcode详细错误:直接打开
ios/Runner.xcworkspace,选择prodscheme手动构建,Xcode会显示具体错误(如签名失效、依赖冲突、文件缺失等) - 验证入口文件:确认
lib/main_prod.dart文件存在且无语法错误 - 检查Info.plist变量:确认
$(PRODUCT_BUNDLE_IDENTIFIER)、$(FLUTTER_BUILD_NAME)等变量在Xcode的prod配置中已正确赋值
内容的提问来源于stack exchange,提问作者Sakhawat Hossain
相关产品推荐
相关产品推荐

