出现场景
在Flutter中,使用flutter run运行debug模式, 等待xcode build完成后,在install时出现以下错误。
Launching lib/main.dart on iPhone in debug mode...
Automatically signing iOS for device deployment using specified development team in Xcode project: DD2AWWF43G
Running Xcode build...
Xcode build done. 85.0s
Installing and launching...
No Provisioning Profile was found for your project's Bundle Identifier or your
device. You can create a new Provisioning Profile for your project in Xcode for
your team by:
1- Open the Flutter project's Xcode target with
open ios/Runner.xcworkspace
2- Select the 'Runner' project in the navigator then the 'Runner' target
in the project settings
3- In the 'General' tab, make sure a 'Development Team' is selected.
You may need to:
- Log in with your Apple ID in Xcode first
- Ensure you have a valid unique Bundle ID
- Register your device with your Apple Developer Account
- Let Xcode automatically provision a profile for your app
4- Build or run your project again
It's also possible that a previously installed app with the same Bundle
Identifier was signed with a different certificate.
For more information, please visit:
https://flutter.io/setup/#deploy-to-ios-devices
Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
2020-01-09 10:18:45.163 ios-deploy[43201:5238881] [ !! ] Error 0xe8008015: A valid provisioning profile for this executable was not found. AMDeviceSecureInstallApplication(0, device, url, options, install_callback, 0)
Could not install build/ios/iphoneos/Runner.app on 2fd298b64f27b47f0917050a9f7ec70cdc98f033.
Try launching Xcode and selecting "Product > Run" to fix the problem:
open ios/Runner.xcworkspace
解决方案
错误报的是证书不对。
按照提示,用xcode打开ios/Runner.xcworkspace,检查了签名设置都是正常的,使用xcode 直接run是能正常运行起来的,只是使用flutter run无法正常运行。所以应该是Flutter中有签名缓存,导致打包时使用的以前的签名。
- flutter clean
在flutter项目目录中,使用flutter clean
清理缓存. - xcode clean build
使用xcode打开ios目录,选择菜单栏中的Product->Clean Build Folder.
clean完成后,会出现以下提示
- flutter build bundle
最后在flutter项目目录下运行flutter build bundle
,重新生成ios app的二进制文件。
再次运行flutter run, 就能正常运行了。