前言
最近参与团队开发,之前一直好用的flutter打包命令居然不好用了,现在把解决方法分享给大家,希望帮助到你。
一、报错及原因
1、我们的打包命令:
flutter build ipa --release --export-method ad-hoc -t lib/flavors/xxx.dart
2、报错如下:
Building ad-hoc IPA... 13.8s
Encountered error while creating the IPA:
error: exportArchive: "Runner.app" requires a provisioning profile with the Push Notifications and Sign in with Apple features.
Try distributing the app in Xcode: "open /Users/xxx/Documents/xxx/build/ios/archive/Runner.xcarchive"
二、分析原因
1、为什么现在发现这个问题?因为我们之前都是选自动证书管理,使用上面命令打包不存在这个问题。
2、现在多人开发,使用的是P12证书方式,就得手动选择证书管理,所以导致了这个问题。
三、解决方法
1、首先要创建一个plist文件,然后在命令中指定一下plist文件路径:
flutter build ipa --export-options-plist=ios/export.plist -t lib/flavors/xxxx.dart
2、命令中,我把export.plist放到flutter项目的iOS目录下面
3、可能你会说我没有plist文件,其实plist很好找,你找你之前打包出来Runner.xcarchive文件导出即可。
4、在Xcode中点击Windows----Organizer:
5、选择导出就可以得到四个文件:
这里的ExportOptions.plist就是你想要的plist文件。
6、当你看到这里时,你就成功地构建了ipa
[✓] App Settings Validation
• Version Number: 1.1.3
• Build Number: 13
• Display Name: xxx
• Deployment Target: 11.0
• Bundle Identifier: saletop.com
[!] App Icon and Launch Image Assets Validation
! Launch image is set to the default placeholder icon. Replace with unique launch image.
To update the settings, please refer to https://docs.flutter.dev/deployment/ios
Building App Store IPA... 16.3s
Built IPA to /Users/xxx/Documents/xxx/build/ios/ipa.
To upload to the App Store either:
1. Drag and drop the "build/ios/ipa/*.ipa" bundle into the Apple Transporter macOS app https://apps.apple.com/us/app/transporter/id145087478
2. Run "xcrun altool --upload-app --type ios -f build/ios/ipa/*.ipa --apiKey your_api_key --apiIssuer your_issuer_id".
See "man altool" for details about how to authenticate with the App Store Connect API key.
总结
这就是flutter到处ipa文件时遇到的问题和解决方法,希望能帮助到你!