flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
163.13k stars 26.84k forks source link

Ensure iOS app extension builds with XCode 15 #135056

Open cyanglaz opened 9 months ago

cyanglaz commented 9 months ago

part of https://github.com/flutter/flutter/issues/124287

When building iOS app extension with XCode 15, an error has shown:


Showing All Messages
Cycle inside Runner; building could produce unreliable results.
Cycle details:
→ Target 'Runner': ExtractAppIntentsMetadata
○ Target 'Runner' has copy command from '/Users/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Products/Debug-iphoneos/FlutterShare.appex' to '/Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex'
○ That command depends on command in Target 'Runner': script phase “Thin Binary”
○ Target 'Runner' has process command with output '/Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/Info.plist'
○ Target 'Runner' has copy command from '/Users/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Products/Debug-iphoneos/FlutterShare.appex' to '/Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex'

Raw dependency cycle trace:

target:  ->

node: <all> ->

command: <all> ->

node: /Users/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/Objects-normal/arm64/ExtractedAppShortcutsMetadata.stringsdata ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:ExtractAppIntentsMetadata ->

node: <target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-copy-files> ->

command: P0:::Gate target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49--fused-phase4-copy-files ->

node: <Copy /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex> ->

CYCLE POINT ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex /Users/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Products/Debug-iphoneos/FlutterShare.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/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Intermediates.noindex/Runner.build/Debug-iphoneos/Runner.build/Script-3B06AD1E1E4923F5004D2608.sh ->

node: /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/Info.plist ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:ProcessInfoPlistFile /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/Info.plist /Users/ychris/tmp/test_extension/ios/Runner/Info.plist ->

node: /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex ->

command: P0:target-Runner-18c1723432283e0cc55f10a6dcfd9e0288a783a885d8b0b3beb2e9f90bde3f49-:Debug:Copy /Users/ychris/tmp/test_extension/build/ios/Debug-iphoneos/Runner.app/PlugIns/FlutterShare.appex /Users/ychris/Library/Developer/Xcode/DerivedData/Runner-ezvtmtjulscpwdbkciycnelbyryh/Build/Products/Debug-iphoneos/FlutterShare.appex

This error prevents Flutter from supporting app extension for iOS 17 and above.

cyanglaz commented 9 months ago

Workaround: In XCode, moving the "Embed Foundation Extensions" build phase to above "Run Script" solved the issue.

At the moment, I'm not sure if there is anything Flutter can do to prevent this.

Rexios80 commented 9 months ago

This order works for me with an embedded watch app:

Screenshot 2023-09-26 at 12 13 47 PM
cyanglaz commented 9 months ago

I'm not actively working on this since there is an easy workaround.

iPypeNB commented 9 months ago

The change of "Embed Foundation Extensions" worked for me, but is there any reason why it happens? can it affect the performance of my app?

iPypeNB commented 9 months ago

since I applied the above mentioned solution, the flutter project started to create a build folder inside the ios folder, does anyone know why this is happening? how can I fix it?

Screenshot 2023-09-27 at 1 28 27 PM

without realizing it I made a commit but today while detailing I realized the existence of this folder that was not there before.

whitesoil commented 9 months ago

I solved in this order. #135739

45online commented 8 months ago

I re-downloaded xcode 14.3 and run it with the following command line. /Applications/Xcode14.3.app/Contents/MacOS/Xcode --help

litang0908 commented 8 months ago

This orders works for me.

image
steveroseik commented 7 months ago

This order works for me with an embedded watch app:

Screenshot 2023-09-26 at 12 13 47 PM

WOOWW, THANK YOU! Other solution were long and useless

rr8733380 commented 5 months ago

What could be wrong if I have everything molested like this. Why does it not work?

Снимок экрана 2024-01-28 в 01 18 52
NM4ik commented 4 months ago

@dam-ease

142907 My issue was closed by addressing it to related issues, but the problem is that I did all the suggested solutions, but I still get the error

I created a test project and added a notification service extension to xCode. I changed the build phases there in the order of the queue and attach a screenshot.

image

But I still get an error when building on a physical device. I have no idea at all how to solve it, because on my second computer on m2 pro, the same project runs without problems

jmagman commented 4 months ago

I updated the App Clip website to reflect the order needed for the build phases.

Drag Embedded App Clips to above Thin Binary.

https://github.com/flutter/website/pull/10145/files#r1489922511 https://docs.flutter.dev/platform-integration/ios/ios-app-clip#step-2---add-an-app-clip-target

This should also be done for https://docs.flutter.dev/platform-integration/ios/app-extensions

NM4ik commented 2 months ago

142907

135056

Finally, I managed to install the application on a real device in --release mode and all the others and finally i can do archive for my app!

The problem of Command ValidateEmbeddedBinary failed with a nonzero exit code was solved for me, which was related to the NotificationService. Although it is strange that on my working mac mini m2 pro there were no problems with assembly, but on my home m2 macbook it was not possible in any way.

Apparently, xCode was updated and I was able to go to the error log and see the problem, although the error was not clickable before.

And so, I found such an offer there: "The CFBundleShortVersionString string of the application extensions (3.0.0) must match the string containing the parent application (3.0.5)."

I started searching the project for version 3.0.0 and found a match with MARKETING_VERSION. I found the MARKETING_VERSION code in my Notification Service, changed it to the desired product version 3.0.0 -> 3.0.5 and everything worked!

image

I do not know how this can happen at all, some kind of magic, I'm shocked :)

rairongf commented 1 month ago

Is there a workaround that doesn't require opening the project with XCode?

yuskeinoue108 commented 1 month ago

I also have the same issue.

TakayukiO commented 1 month ago

I also have the same issue.