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.09k stars 505 forks source link

[INFO] Managing external frameworks #877

Open alexandrefresnais opened 9 months ago

alexandrefresnais commented 9 months ago

Hi everyone!

Is your feature request related to a problem? Please describe.

When building my iOS Unity Project with the solution, I need to add all the <library>.framework files from the Unity-iPhone project to the 'Runner' project in the Frameworks, Libraries, and Embedded content section. For example, I needed to add the ARDK.framework from Niantic's AR SDK (otherwise I would get a Library not loaded error) and the ARKit.framework (otherwise I had symbol not found error).

Describe the solution you'd like

Either documentation on the process, or an automatic way to add these load these libraries.

Describe alternatives you've considered

Adding these frameworks by hand.

Additional context

For additional context, I am fairly new to Xcode and Flutter so I might be missing something.

alexandrefresnais commented 9 months ago

I would like to add that I am also encountering this kind of problem with Android, where I get java.lang.ClassNotFoundException on classes that come from plugins. Any help would be appreciated.

jamesncl commented 9 months ago

I don't think you're missing anything. For some context, the way that Unity exports projects for iOS isn't primarily meant to be embedded in another app like flutter - the Unity-iPhone project it produces is made to be run on it's own. Unity has some basic but not particularly helpful documentation. What this package does is manually try to merge the Unity-iPhone and Runner projects via C# scripts which modify the build process, so I think for now, until the author updates this package, you will have to manually copy things as you are doing.

I'm not sure how active the author is anymore, so I've actually started to make my own package flutter_embed_unity which achieves the same thing, as I need to rely on it into the future and need it to be well documented and maintainable. I've completely rewritten how it works so it's still in beta and it's not battle-hardened, but it might be worth trying to see if you still get the same problem. If you do, raise an issue and I'll have a look, because it sounds like a worthwhile enhancement. However I'm not sure right now how to achieve this automatically. For iOS, it might be possible via the custom ProjectExporterIos.cs build script using PBXProject (a Unity tool for manually editing Xcode project files), however I don't have much experience myself with Xcode so would appreciate any help. For Android, I suspect this may be an easier fix by editing the build.gradle files, which are a lot easier to work with than xcproj files.