Skip to content
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

[Bug]: Dependency Cycle Error after Updating to Xcode 15 #651

Open
1 task done
shaiArn opened this issue Oct 9, 2023 · 12 comments
Open
1 task done

[Bug]: Dependency Cycle Error after Updating to Xcode 15 #651

shaiArn opened this issue Oct 9, 2023 · 12 comments

Comments

@shaiArn
Copy link

shaiArn commented Oct 9, 2023

What happened?

Hello OneSignal Unity SDK team,

I recently upgraded to Xcode version 15 and faced an issue while building my project. The error details are below.

Interestingly, a similar issue appears to be occurring with Flutter iOS builds as well. You can find a related discussion here:
https://stackoverflow.com/questions/77138968/handling-cycle-inside-runner-building-could-produce-unreliable-results-after-up

While the solution provided in the above Stack Overflow thread does work, it isn't a viable long-term fix for us. The manual intervention it requires disrupts our CI/CD system.

I hope this information aids in diagnosing the issue. If there are any additional details or clarifications needed, please let me know.

Thank you for your attention and support.

Steps to reproduce?

1. Update to Xcode 15
2. Build a Unity project that uses OneSignal SDK for iOS
3. Build an iOS build from Xcode

What did you expect to happen?

The build process to work smoothly without manual changes to Build Phase.

Unity version

2021.3.23f1 (LTS)

OneSignal Unity SDK version

3.0.1

Platform

iOS

Relevant log output

Showing All Messages
Cycle inside Unity-iPhone; building could produce unreliable results.
Cycle details:
→ Target 'Unity-iPhone': CodeSign Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app
○ That command depends on command in Target 'Unity-iPhone': script phase “[CP] Embed Pods Frameworks”
○ Target 'Unity-iPhone' has copy command from 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/OneSignalNotificationServiceExtension.appex' to 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex'
○ That command depends on command in Target 'Unity-iPhone': script phase “Unity Process symbols”
○ Target 'Unity-iPhone' has a command with output 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/<appName>.app.dSYM'
○ Target 'Unity-iPhone' has process command with output 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Info.plist'
○ Target 'Unity-iPhone' has copy command from 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/OneSignalNotificationServiceExtension.appex' to 'Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex'


Raw dependency cycle trace:

target:  ->

node: <all> ->

command: <all> ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/_CodeSignature ->

command: P0:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:CodeSign Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Frameworks/FBAEMKit.framework/ ->

directoryTreeSignature: � ->

directoryContents: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Frameworks/FBAEMKit.framework ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Frameworks/FBAEMKit.framework ->

command: P2:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:PhaseScriptExecution [CP] Embed Pods Frameworks Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-7D8413102D645D53E8525294.sh ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-7D8413102D645D53E8525294.sh ->

command: P2:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:WriteAuxiliaryFile Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-7D8413102D645D53E8525294.sh ->

node: <target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase7-copy-files> ->

command: P0:::Gate target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase7-copy-files ->

node: <Copy Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex> ->

CYCLE POINT ->

command: P0:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:Copy Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/OneSignalNotificationServiceExtension.appex ->

node: <target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase6-symbolupload> ->

command: P0:::Gate target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase6-symbolupload ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-685842A99628018F8EEBB260.sh ->

command: P2:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:WriteAuxiliaryFile Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-685842A99628018F8EEBB260.sh ->

node: <target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase5-unity-process-symbols> ->

command: P0:::Gate target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f--fused-phase5-unity-process-symbols ->

node: <execute-shell-script-4d46f0999f4e53d6791a1877ccf164d70c3f1bba89277f759c6becf1eeb525a1-target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-> ->

command: P2:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:PhaseScriptExecution Unity Process symbols Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Script-75414130B284C3C5FE31AD75.sh ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/<appName>.app.dSYM/Contents/Resources/DWARF/<appName>/ ->

directoryTreeSignature: � ->

directoryContents: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/<appName>.app.dSYM/Contents/Resources/DWARF/<appName> ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/<appName>.app.dSYM/Contents/Resources/DWARF/<appName> ->

command: P0:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:GenerateDSYMFile Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/<appName>.app.dSYM Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/<appName> ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Info.plist ->

command: P0:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:ProcessInfoPlistFile Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/Info.plist Users/user/Documents/unity__builds/<dir_name>/Info.plist ->

node: Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex ->

command: P0:target-Unity-iPhone-4d46f0999f4e53d6791a1877ccf164d70fa8628908142c1784945aff676e527f-:Release:Copy Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/Applications/<appName>.app/PlugIns/OneSignalNotificationServiceExtension.appex Users/user/Library/Developer/Xcode/DerivedData/Unity-iPhone-ewzqhutllyvbawgwbzvdccarkzxg/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/BuildProductsPath/Release-iphoneos/OneSignalNotificationServiceExtension.appex

Code of Conduct

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Oct 9, 2023

@shaiArn This looks like a wonky interaction between Unity(or Flutter), Cocoapods, and the fact that your app has a Notification Service Extension. I doubt this is something that can be solved by a change in the SDK, but we can investigate workarounds/setup steps that will resolve the issue.

@MTPirate89
Copy link

MTPirate89 commented Oct 11, 2023

Have same issue after upgrading to Xcode version 15
Unity verstion 2021.3.31f1 (LTS)
OneSignal Unity SDK version
https://github.com/OneSignal/OneSignal-Unity-SDK/releases/tag/3.0.11

Xcode project is generated on each player build. So we need some workaround that can be implemented in PostBuild

Update: found on Unity Forum that they are currently working on fix
https://forum.unity.com/threads/xcode-15-cycle-inside-unity-iphone-building-could-produce-unreliable-results.1496747/

@Trunksome
Copy link

I had the same issue, and got it to build by changing the order of the build phases.

Move "Embed App Extensions" of the main target to be before "Unity Process symbols for Unity-iPhone".

image

Hope this helps! Almost pulled my hair out over this one.

@shepherd-l
Copy link
Contributor

I was unable to reproduce the error in a new project with OneSignal. Could any of you provide a sample project that reproduces the error along with what Unity version and OneSignal SDK version you used?

@arrwhidev
Copy link

arrwhidev commented Nov 1, 2023

We're experiencing the same issue. I don't have a project, but I will chip in with some extra detail...

Unfortunately for us, whilst the re-ordering fix does fix the "cycle error" and the app does build, it immediately crashes when it runs on the device due to:

Error loading /var/containers/Bundle/Application/<REDACTED>/Frameworks/UnityFramework.framework/UnityFramework 
(143):  dlopen(/var/containers/Bundle/Application/<REDACTED>/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): 
Library not loaded: @rpath/AppleCoreNative.framework/AppleCoreNative
...

It's not clear to me if the re-ordering fix is actually fixing it, or if it is just plastering over one issue and causing this second issue. This second issue could be a total non-issue, in reality.

Similarly to others, this started when we tried to upgrade to XCode 15 to support iOS17, no issues prior to this.

Perhaps older version of XCode were more lenient/flexible but 15 is more strict, which is why a bunch of people are seeing this issue (I've seen it around a few forums). Even though it might not be a OneSignal issue directly, clearly there's a certain project structure that is susceptible to this issue, if we can collectively find a solution that would be great.

@flashmandv
Copy link

Hello,
Is there any update on the cycle error?
As it also happened to me using latest Xcode 15.0.1 and latest OneSignal for Unity.
The workaround does solve the compiling error but I'm not sure if production build will be stable enough

@AthanasiosGrigoroudis
Copy link

This issue is still happening with Xcode 15.2 and the latest OneSignal version and we're currently blocked from building our game. The workaround works but I haven't figured out how to automate it on post process. Does anyone have a temporary solution that works automatically?

@AthanasiosGrigoroudis
Copy link

Updating the Unity version from 2021.3 to 2022.3 fixed it for me

@xinatcg
Copy link

xinatcg commented Feb 13, 2024

same issue, Is there any workaround for unity 2021?

@xinatcg
Copy link

xinatcg commented Feb 15, 2024

find a solution by using this code with minor change: https://forum.unity.com/threads/xcode-15-cycle-inside-unity-iphone-building-could-produce-unreliable-results.1496747/#post-9397949

namespace YourNameSpace
{
    internal static class FixBuildPhasesOrderForUnityIPhone
    {
        private const string _sectionSearchKey = "Build configuration list for PBXNativeTarget \"Unity-iPhone\"";
        private const string _targetBuildPhaseKey = "ShellScript";  // changed from original post
 
        [PostProcessBuild(45)]
        private static void FixBuildPhasesOrderInProject(BuildTarget target, string pathToBuiltProject)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }
 
            // Search for order array.
            var path = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj", "project.pbxproj");
            var allLines = File.ReadAllLines(path);
 
            // Search for first line.
            var firstLine = -1;
            for (var i = 0; i + 2 < allLines.Length; i++)
            {
                if (allLines[i].Contains(_sectionSearchKey) && allLines[i + 1].Contains("buildPhases = ("))
                {
                    firstLine = i + 2;
                    break;
                }
            }
 
            // Check for error.
            if (firstLine <= 0)
            {
                return;
            }
 
            // Search for last line.
            var lastLine = -1;
            for (var i = firstLine; i + 1 < allLines.Length && i - firstLine < 30; i++)
            {
                if (allLines[i + 1].Contains(");"))
                {
                    lastLine = i;
                    break;
                }
            }
 
            // Check for error.
            if (lastLine <= 0 || lastLine == firstLine)
            {
                return;
            }
 
            var buffer = [new](http://www.google.com/search?q=new+msdn.microsoft.com) List<string>();
            for (var i = firstLine; i <= lastLine; i++)
            {
                buffer.Add(allLines[i]);
            }
 
            var index = buffer.FindIndex(x => x.Contains(_targetBuildPhaseKey));
            if (index == -1)
            {
                return;
            }
 
            var line = buffer[index];
            buffer.RemoveAt(index);
            buffer.Add(line);
 
            // Replace old lines with new ones.
            for (var i = 0; i < buffer.Count; i++)
            {
                allLines[firstLine + i] = buffer[i];
            }
 
            // Save results.
            File.WriteAllLines(path, allLines);
            Debug.Log("BuildPhases order were reordered in xCode project.");
        }
    }
}

The build phases change from

image

to

image

@Trunksome
Copy link

I noticed something interesting: when I build the xcode project on Windows and then run it on my Mac, I'm getting the dependency cycle error and need to shift around the build phases. When I build the xcode project with Unity running on my Mac, I can build just fine without having to touch the build phases.

@DavidJaksztaST
Copy link

find a solution by using this code with minor change: https://forum.unity.com/threads/xcode-15-cycle-inside-unity-iphone-building-could-produce-unreliable-results.1496747/#post-9397949

namespace YourNameSpace
{
    internal static class FixBuildPhasesOrderForUnityIPhone
    {
        private const string _sectionSearchKey = "Build configuration list for PBXNativeTarget \"Unity-iPhone\"";
        private const string _targetBuildPhaseKey = "ShellScript";  // changed from original post
 
        [PostProcessBuild(45)]
        private static void FixBuildPhasesOrderInProject(BuildTarget target, string pathToBuiltProject)
        {
            if (target != BuildTarget.iOS)
            {
                return;
            }
 
            // Search for order array.
            var path = Path.Combine(pathToBuiltProject, "Unity-iPhone.xcodeproj", "project.pbxproj");
            var allLines = File.ReadAllLines(path);
 
            // Search for first line.
            var firstLine = -1;
            for (var i = 0; i + 2 < allLines.Length; i++)
            {
                if (allLines[i].Contains(_sectionSearchKey) && allLines[i + 1].Contains("buildPhases = ("))
                {
                    firstLine = i + 2;
                    break;
                }
            }
 
            // Check for error.
            if (firstLine <= 0)
            {
                return;
            }
 
            // Search for last line.
            var lastLine = -1;
            for (var i = firstLine; i + 1 < allLines.Length && i - firstLine < 30; i++)
            {
                if (allLines[i + 1].Contains(");"))
                {
                    lastLine = i;
                    break;
                }
            }
 
            // Check for error.
            if (lastLine <= 0 || lastLine == firstLine)
            {
                return;
            }
 
            var buffer = [new](http://www.google.com/search?q=new+msdn.microsoft.com) List<string>();
            for (var i = firstLine; i <= lastLine; i++)
            {
                buffer.Add(allLines[i]);
            }
 
            var index = buffer.FindIndex(x => x.Contains(_targetBuildPhaseKey));
            if (index == -1)
            {
                return;
            }
 
            var line = buffer[index];
            buffer.RemoveAt(index);
            buffer.Add(line);
 
            // Replace old lines with new ones.
            for (var i = 0; i < buffer.Count; i++)
            {
                allLines[firstLine + i] = buffer[i];
            }
 
            // Save results.
            File.WriteAllLines(path, allLines);
            Debug.Log("BuildPhases order were reordered in xCode project.");
        }
    }
}

The build phases change from

image to image

can you explain what exactly you need to change to move Unity process symbols to the very end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants