juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.15k stars 525 forks source link

Vuforia 10.12 on iOS: "Does not contain bitcode" error when trying to build #746

Closed felix330 closed 1 year ago

felix330 commented 1 year ago

I've been trying to setup a new Flutter project with a Unity project containing Vuforia 10.12. However, as soon as Vuforia is added to the Unity project, the Flutter project will no longer build. I'm getting this error message:

'/Volumes/project/ios/UnityLibrary/Frameworks/com.ptc.vuforia.engine/Vuforia/Plugins/iOS/VuforiaEngine.framework/VuforiaEngine' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target.

I've already tried setting "enable bitcode" to false on all targets, but the error will still show up. Upon further research, Vuforia has just removed bitcode support in its most recent release, with the reason that bitcode is no longer allowed for app submissions. Does this mean that I can't use the most recent Vuforia with the Unity widget and that if I were to use an older version, it would not be able to be submitted to the app store? Or is there anything else I could do about this error?

timbotimbo commented 1 year ago

You can try to disable bitcode in the export script. FlutterUnityIntegration\Editor\XcodePostBuild.cs There should be a "ENABLE_BITCODE", "YES" line in there.

This hasn't been updated since bitcode got deprecated recently.

felix330 commented 1 year ago

@timbotimbo Thank you. This did get me one step further, as now the app will build successfully. However, it crashes immediately upon startup, with a message stating that it can't find VuforiaEngine. The Vuforiaengine framework does seem to exist in XCode however. I've tried re-adding it to the Unity-iPhone target, but no luck. Any ideas?

lldb) dyld[10151]: Library not loaded: @rpath/VuforiaEngine.framework/VuforiaEngine Referenced from: /private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/UnityFramework.framework/UnityFramework Reason: tried: '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/usr/lib/swift/VuforiaEngine.framework/VuforiaEngine' (no such file), '/usr/lib/swift/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/usr/lib/swift/VuforiaEngine.framework/VuforiaEngine' (no such file), '/usr/lib/swift/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/private/var/containers/Bundle/Application/085F4E7E-DBC1-4AE7-9BE9-D0F9B15203B7/Runner.app/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file), '/System/Library/Frameworks/VuforiaEngine.framework/VuforiaEngine' (no such file)

timbotimbo commented 1 year ago

Looka like Vuforia has docs about using it with Unity as a library, which is used here.

https://library.vuforia.com/unity-extension/using-vuforia-engine-unity-library-uaal#ios-specific-steps

felix330 commented 1 year ago

I did eventually make it work. The steps are similar, but not the same as the ones in Vuforia's docs. Here are the slightly convoluted steps:

  1. Drag VuforiaEngine and UnityDriver from their subfolder within frameworks into the frameworks folder of the Unity-iPhone project.
  2. Drag VuforiaEngine and UnityDriver from the frameworks folder of Unity-iPhone into the frameworks folder of runner.
  3. Remove all the old framework references to VuforiaEngine and UnityDriver on Unity-iPhone and UnityFramework
  4. Drag the frameworks back in from the frameworks folder of "Runner"
  5. Also add the frameworks on the general tab of the "Runner" project itself