Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building to iOS and embedding unity into swift app #1258

Open
jacobwelchvirtusense opened this issue Sep 4, 2024 · 7 comments
Open

Building to iOS and embedding unity into swift app #1258

jacobwelchvirtusense opened this issue Sep 4, 2024 · 7 comments
Labels
type:docs Improvements or additions to documentation

Comments

@jacobwelchvirtusense
Copy link

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: #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 jacobwelchvirtusense added the type:bug Something isn't working label Sep 4, 2024
@jacobwelchvirtusense
Copy link
Author

jacobwelchvirtusense commented Sep 4, 2024

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
Copy link
Owner

homuler commented Sep 7, 2024

What specific actions would you like this project to take?

@jacobwelchvirtusense
Copy link
Author

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
Copy link
Owner

homuler commented Sep 10, 2024

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.

@homuler homuler added type:docs Improvements or additions to documentation stat:awaiting response Awaiting response from author and removed type:bug Something isn't working labels Sep 18, 2024
@jacobwelchvirtusense
Copy link
Author

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.

@homuler homuler removed the stat:awaiting response Awaiting response from author label Oct 14, 2024
@mosolab
Copy link

mosolab commented Nov 18, 2024

Hi @jacobwelchvirtusense, could you also mention next steps how to use library in swift script? Or what to look for?
Thank you in advance!

@jacobwelchvirtusense
Copy link
Author

Hi @jacobwelchvirtusense, could you also mention next steps how to use library in swift script? Or what to look for? Thank you in advance!

To use unity in a swift app follow these tutorials https://medium.com/@salaheddine.ly/part-i-integrating-unity-games-to-react-native-apps-for-beginners-for-android-4c48031e2829

That's what I followed at least, hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants