Open shaiArn opened 1 year ago
@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.
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/
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".
Hope this helps! Almost pulled my hair out over this one.
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?
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.
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
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?
Updating the Unity version from 2021.3 to 2022.3 fixed it for me
same issue, Is there any workaround for unity 2021?
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
to
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.
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
to
can you explain what exactly you need to change to move Unity process symbols to the very end?
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?
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
Code of Conduct