-
Notifications
You must be signed in to change notification settings - Fork 572
Description
Bug Report
Describe the bug
When building an Xcode project that integrates Flutter and Unity 6 LTS, a linker error occurs. The build fails with "Undefined symbols for architecture arm64," specifically referencing _swift_FORCE_LOAD$swift... symbols from the libUnityARKit.a library. This issue seems to be related to how Xcode 15.3 handles the linking of Swift standard libraries for static archives. Building the Unity project directly (without Flutter integration) works correctly.
To Reproduce
Steps to reproduce the behavior:
Set up a Flutter project with flutter_unity_widget_2.
Export a Unity 6 LTS project for iOS, ensuring it includes ARKit functionality (e.g., using the com.unity.xr.arkit package).
Integrate the Unity build into the Flutter iOS project.
Open the Runner.xcworkspace file in Xcode.
Attempt to build the project for the arm64 architecture (e.g., for a physical iOS device).
See the linker error in the build log.
Expected behavior
The project should build successfully without any linker errors, and the Unity content should be properly integrated and runnable within the Flutter application.
Screenshots
ImageUnity
OS: macOS
Version: Unity 6 LTS
Smartphone
Device: ( iPhone 11 Pro)
OS: iOS (18.1.1)
Additional context
The issue seems to be specific to the combination of Flutter, Unity 6 LTS, and Xcode 15.3+. I have already tried the following troubleshooting steps without success:
Adding $(inherited) to Other Linker Flags for both the Runner and UnityFramework targets.
Setting Always Embed Swift Standard Libraries to YES for both targets.
Adding a blank Swift file to the Runner target to trigger the creation of a bridging header and force Swift library linking.
Using the -force_load linker flag with the correct path to libUnityARKit.a for the UnityFramework target. The initial attempts resulted in unknown argument and Build input file cannot be found errors, which were resolved, but the Undefined symbols error persists.
The build is successful when exporting from Unity as a standalone iOS project. The problem only occurs during integration with Flutter.
This suggests a core incompatibility in how the flutter_unity_widget_2 and Xcode handle Swift library linking with static Unity archives, specifically with the swift_FORCE_LOAD$ symbols that seem to be required by Unity's ARKit library.