homuler / MediaPipeUnityPlugin

Unity plugin to run MediaPipe
MIT License
1.8k stars 467 forks source link

Building to iOS and embedding unity into swift app #1258

Open jacobwelchvirtusense opened 2 months ago

jacobwelchvirtusense commented 2 months ago

Plugin Version or Commit ID

v0.15.0

Unity Version

2021.3.16f1

Your Host OS

Windows

Target Platform

iOS

Target Device

iPad

[Windows Only] Visual Studio C++ and Windows SDK Version

No response

[Linux Only] GCC/G++ and GLIBC Version

No response

[Android Only] Android Build Tools and NDK Version

No response

[iOS Only] XCode Version

15.3

Build Command

python build.py build --desktop cpu --opencv cmake -vv

Bug Description

I am getting the same issue as this ticket here: https://github.com/homuler/MediaPipeUnityPlugin/issues/1042

When running from editor and in standalone iOS builds everything works as intended, but when trying to integrate the unity project as a library into an iOS swift app it is unable to fine the necessary MediaPipeUnity files.

Steps to Reproduce the Bug

  1. Build a normally working iOS build
  2. Integrate the iOS build into a swift application (if you are unsure how to do this here is a tutorial https://www.youtube.com/watch?v=xx-ypR2yJZw)
  3. Try to run the xCode project on a mobile device

The resulting error will be that the project has "(no such file)" when referring to MediaPipeUnity.

Log

dyld[8336]: Library not loaded: @rpath/MediaPipeUnity.framework/MediaPipeUnity Referenced from: <798BC7D6-7C50-34E0-A8EC-0C3B80819760> /private/var/containers/Bundle/Application/8692E076-E0A5-4C50-B96E-3D44378A5C9D/ProactiveStrides.app/Frameworks/UnityFramework.framework/UnityFramework Reason: tried: '/private/var/containers/Bundle/Application/8692E076-E0A5-4C50-B96E-3D44378A5C9D/ProactiveStrides.app/Frameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/usr/lib/swift/MediaPipeUnity.framework/MediaPipeUnity' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/Users/hitheshr/Library/Developer/Xcode/DerivedData/ProactiveStrides-emhctmkgrkdgphbfbtywaeuhhhir/Build/Products/Debug-iphoneos/PackageFrameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/private/preboot/Cryptexes/OS/Users/hitheshr/Library/Developer/Xcode/DerivedData/ProactiveStrides-emhctmkgrkdgphbfbtywaeuhhhir/Build/Products/Debug-iphoneos/PackageFrameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/private/var/containers/Bundle/Application/8692E076-E0A5-4C50-B96E-3D44378A5C9D/ProactiveStrides.app/Frameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/usr/lib/swift/MediaPipeUnity.framework/MediaPipeUnity' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/Users/hitheshr/Library/Developer/Xcode/DerivedData/ProactiveStrides-emhctmkgrkdgphbfbtywaeuhhhir/Build/Products/Debug-iphoneos/PackageFrameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/private/preboot/Cryptexes/OS/Users/hitheshr/Library/Developer/Xcode/DerivedData/ProactiveStrides-emhctmkgrkdgphbfbtywaeuhhhir/Build/Products/Debug-iphoneos/PackageFrameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file), '/private/var/containers/Bundle/Application/8692E076-E0A5-4C50-B96E-3D44378A5C9D/ProactiveStrides.app/Frameworks/MediaPipeUnity.framework/MediaPipeUnity' (no such file)

Screenshot/Video

No response

Additional Context

No response

jacobwelchvirtusense commented 1 month ago

For whoever is curious about integrating unity as a library with the MediaPipeUnityPlugin, I have found the solution to the above problem. At least for iOS that is.

You will need to add the MediaPipeUnity.framework to the main xCode project's frameworks folder along with your unity project as you would normally. A window will pop-up and check "Copy items if needed". You will also need to add the MediaPipeUnity framework to the main xCode project's Frameworks, Libraries, and Embedded Content and set it to Embed & Sign.

homuler commented 1 month ago

What specific actions would you like this project to take?

jacobwelchvirtusense commented 1 month ago

If you could make a note somewhere that the MediaPipeUnityPlugin for iOS needs to be in the root xCode project that would be helpful.

homuler commented 1 month ago

Could you attach an XCode screenshot that shows the settings? I don't plan to support UaaL, but I can leave a link to this issue in the documentation.

jacobwelchvirtusense commented 3 weeks ago
Folder Screenshot xCodeProject
  1. Basically drag the MediaPipeUnity.framework folder into the root directory (the folder not the project) of your base xCode project.
  2. Drag the folder into the Frameworks folder of your base xCode project.
  3. A menu should pop up, the only thing you need to change is toggle on the "Copy items if needed" option.
  4. Make sure it is set to embed and sign in the base xCode project's general settings.

I'll also note here for other Unity people who want to use Unity as a library that this often a problem with other plugins too. Basically if you see that framework files are missing just add them to your base xCode project framework folder just like this.