Flutter build MacOS need Profile error
几个问题
1.
"Runner" requires a provisioning profile.
Select a provisioning profile in the Signing & Capabilities editor.
2.
✓Built build/macos/Build/Products/Debug/xxx_editor.app
flutter: Could not start Dart VM service HTTP server:
SocketException: Failed to create server socket (OS Error: Operation not permitted, errno = 1), address = 127.0.0.1, port = 0
#0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:1032:7)
<asynchronous suspension>
#1 _RawServerSocket.bind.<anonymous closure> (dart:io-patch/socket_patch.dart:1818:15)
<asynchronous suspension>
3.
Command ClangStatCache failed with a nonzero exit code
or
Error (Xcode): no such file or directory: '/Users/xxx/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation'
4.
[+2921 ms] Error: No macOS desktop project configured. See https://flutter.dev/to/add-desktop-support to learn about adding macOS support to a project.
问题1
这个问题是配置证书,没有配置完全导致的。你看是用真机调试还是模拟器,真机的话需要配置证书,模拟器的话不需要。
解决方法:
- 删除配置,尤其是 entitlements 文件里的定义,看有没有模拟器用不到的,删除
- 去ios或者macos文件夹下,
rm -rf Podfile.lock Pods
flutter clean
flutter pub get
问题2
主要是 entitlements 文件配置问题,需要配置对应,下面是最小配置文件,也就是默认的配置文件,如果修改了需要恢复,可以参考。
清理删除 pod 缓存的时候,别忘记是 macos 还是 ios,进错文件夹。
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
问题3
xcode 设置 derived data 路径,默认是 default 选项,改成 relative 选项,然后重新编译就可以了,神奇。
问题4
本身是可以的,但是被队友误删了,所以找不到项目支持,需要重新配置。
# 去项目目录执行命令
flutter clean
flutter pub get
flutter create --platforms macos .