Skip to content

iOS app extension errors with "Cycle inside Runner" when "Thin Binary" Build Phase is before "Embed Foundation Extensions" #135056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #124287
cyanglaz opened this issue Sep 19, 2023 · 23 comments
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@cyanglaz
Copy link
Contributor

cyanglaz commented Sep 19, 2023

part of #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 cyanglaz added engine flutter/engine repository. See also e: labels. P1 High-priority issues at the top of the work list team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Sep 19, 2023
@cyanglaz cyanglaz self-assigned this Sep 19, 2023
@cyanglaz cyanglaz added the platform-ios iOS applications specifically label Sep 19, 2023
@cyanglaz cyanglaz removed the engine flutter/engine repository. See also e: labels. label Sep 19, 2023
@cyanglaz
Copy link
Contributor Author

cyanglaz commented Sep 19, 2023

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.

@cyanglaz cyanglaz added P2 Important issues not at the top of the work list and removed P1 High-priority issues at the top of the work list labels Sep 19, 2023
@Rexios80
Copy link
Member

This order works for me with an embedded watch app:

Screenshot 2023-09-26 at 12 13 47 PM

@cyanglaz cyanglaz removed their assignment Sep 26, 2023
@cyanglaz
Copy link
Contributor Author

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

@iPypeNB
Copy link

iPypeNB commented Sep 27, 2023

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
Copy link

iPypeNB commented Sep 27, 2023

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
Copy link

whitesoil commented Sep 30, 2023

I solved in this order. #135739

@45online
Copy link

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

@litang0908
Copy link

This orders works for me.

image

littleGnAl added a commit to AgoraIO-Extensions/Agora-Flutter-SDK that referenced this issue Nov 1, 2023
The user reports that it's failed to build the example with xcode 15
```
Error (Xcode): Cycle inside Runner; building could produce unreliable results.
Cycle details:
→ Target 'Runner': CodeSign /Users/joepritchard/Downloads/Agora-Flutter-SDK-main/example/build/ios/Debug-iphoneos/Runner.app

...
```
To fix it, we need to change the order in `Build Phases`. See 
- flutter/flutter#135739
-
flutter/flutter#135056 (comment)

I added a new job to cover this case and retained the old `build_ios`
job to ensure this change does not affect the user with xcode version <
15.
@steveroseik
Copy link

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
Copy link

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

Снимок экрана 2024-01-28 в 01 18 52

@NM4ik
Copy link

NM4ik commented Feb 12, 2024

@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

@dam-ease dam-ease added the customer: crowd Affects or could affect many people, though not necessarily a specific customer. label Feb 13, 2024
@jmagman
Copy link
Member

jmagman commented Mar 5, 2024

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
Copy link

NM4ik commented Apr 28, 2024

#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
Copy link

rairongf commented May 8, 2024

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

@yuskeinoue108

This comment was marked as duplicate.

1 similar comment
@TakayukiO

This comment was marked as duplicate.

@AhmedLSayed9
Copy link
Contributor

Dragging Embed Foundation Extensions to above Thin Binary worked for me:

Screenshot 2024-07-17 at 11 12 49 PM

@clementdemily
Copy link

Hey!

I’m using a 2019 MacBook Pro (Intel), and I’ve encountered a similar issue since I added an extension to manage notifications (using a popular community package) a few months ago.

I’ve been keeping the Flutter SDK and project dependencies up to date, but I noticed a problem with my iOS build process a few weeks ago.

When I run the flutter build command, after about 15 minutes of building, it randomly fails. I enjoy rolling dice when I play DnD, but not when it comes to work!

I’ve tried rearranging the build phases—sometimes it works, sometimes it doesn’t. I even created a script to wipe the Xcode and Flutter caches, and I run it before rebooting the laptop and launching the Flutter build command again.

Does anyone have any tips or a checklist to ensure the setup is configured correctly?

Here’s my current build phase process:

Capture d’écran 2024-09-09 à 16 30 18

@kaneki666
Copy link

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?

Idk why also worked for weird.Image notification was not coming now it does

@Ahmadre
Copy link

Ahmadre commented Nov 15, 2024

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

@jmagman This issue is re-appearing! Flutter is always re-arranging the build phases in XCode when doing a fresh re-build of extensions or other embeded frameworks!

Can't we be aware of this in the Flutter iOS scripts before this even happens? (Like re-arranging the build phases like it should be)

@JosephNK
Copy link

@cyanglaz thank you :)

@lumpidu
Copy link

lumpidu commented Jan 28, 2025

Without rearranging the order: click on "Copy only when installing"

Image

@lumpidu
Copy link

lumpidu commented Feb 3, 2025

Alternatively, clear setting "Input Files" inside "Thin Binary". This declares a dependency to Info.plist, which again causes the loop. Of course, if you clear this setting, this step is always run. But still better than the dreaded error described here.

@vashworth vashworth changed the title Ensure iOS app extension builds with XCode 15 iOS app extension errors with "Cycle inside Runner" when "Thin Binary" Build Phase is before "Embed Foundation Extensions" Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer: crowd Affects or could affect many people, though not necessarily a specific customer. P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests