在近期升级Xcode15.2的小伙伴,如果遇到了升级后原来flutter的项目无法运行,并遇到类似下面的错误信息时
Error (Xcode): Cycle inside Runner; building could produce unreliable results. This usually can be resolved by moving the shell script phase 'Thin Binary' so that it runs before the build phase that depends on its outputs.
Cycle details:
→ Target 'Runner': CodeSign /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app
○ Target 'Runner' has process command with output '/Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist'
○ Target 'Runner' has copy command from '/Users/xxx/.../build/ios/Debug-iphonesimulator/serviceext.appex' to '/Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/PlugIns/serviceext.appex'
○ That command depends on command in Target 'Runner': script phase “Thin Binary”
Raw dependency cycle trace:
target: ->
node: <all> ->
command: <all> ->
node: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/_CodeSignature ->
command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:CodeSign /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app ->
node: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist/ ->
directoryTreeSignature: m ->
directoryContents: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist ->
CYCLE POINT ->
node: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist ->
command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:ProcessInfoPlistFile /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist /Users/xxx/Desktop/ios_project/testflutterios111/ios/Runner/Info.plist ->
node: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/PlugIns/serviceext.appex ->
command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/PlugIns/serviceext.appex /Users/xxx/.../build/ios/Debug-iphonesimulator/serviceext.appex ->
node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase3-thin-binary> ->
command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase3-thin-binary ->
node: <execute-shell-script-18c1723432283e0cc55f10a6dcfd9e02f1eee2015e8ff5ebcd27678f788c2826-target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-> ->
command: P2:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:PhaseScriptExecution Thin Binary /Users/xxx/Library/Developer/Xcode/DerivedData/Runner-dlwaxybktfgviicyqlkxiaamunev/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh ->
node: /Users/xxx/.../build/ios/Debug-iphonesimulator/Runner.app/Info.plist
Could not build the application for the simulator.
Error launching application on iPhone 15 Pro.
首先是flutter版本和开发工具版本以及os系统版本如下
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.0, on macOS 14.2.1 23C71 darwin-x64, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.85.1)
[✓] Connected device (5 available)
[✓] Network resources
其次,你需要进入iOS项目,点击左侧目录里的第一个Runner项目,右侧内容中找到TARGETS,点击第一个target,然后右侧选择Build Phases,将里面的内容重新排序,排序的顺序按照下面的顺序进行调整
Target Dependencies (1 item)
Run Build Tool Plug ins (0 items)
(CP] Check Pods Manifest.lock
Embed Frameworks (o items)
Embed Foundation Extensions (1 item)
[CP] Embed Pods Frameworks
Run Script
Compile Sources (2 items)
Link Binary with Libraries (1 item)
Copy Bundle Resources (6 items)
Thin Binary
[CP] Copy Pods Resources
调整后运行就可以解决上面的报错问题了。如果还不行,可能有缓存,使用flutter clean或者Xcode里的clean清理下项目。