- Home /
How to include dylibs in a package for iOS projects?
I have a PostProcessBuildAttribute
that is responsible for modifying the Xcode project settings of my iOS project. I also have a dylib in my Assets/Runtime/Plugins/iOS
directory. In my local development, the post processor adds the dylib to the xcode project using project.AddFile("path/to/lib.dylib", "Frameworks/" + dylib name, "PBXSourceTree.Absolute")
However, my ultimate goal is to include this dylib and accompanying post processor in a distributable package. When my test project imports the package (from tarball), the path to the dylib isn't the same as in development -- instead of Assets/Runtime/Plugins/iOS/...
, it becomes Packages/<my_package>/Runtime/Plugins/iOS/...
. I also can't hardcode my dylib's path using the package-version of the folder structure b/c that string is dependent on the package's version.
What's the best way to automatically detect the full path to the package, and switch to path to Assets
if the code is not installed as a package?
@bszalapski did you find any solution for that? Were you able to properly publish the iOS project to the store with the dylib?
Answer by bszalapski · Aug 02, 2021 at 06:02 PM
I ultimately went with a .framework
, which Unity pulls in automatically (I think..?). Additionally, you can write the PostProcessor to use GUIDs instead of file paths, which gets around the packaging issue.
Another option that seemed to work as well was using a static .a
instead of a .dylib
-- although it's frustrating to have to statically load the library, chances are your native plugin isn't that large, so isn't too much of a memory hit.
@bszalapski We also tried making it into a .framework but got error messages ( "bundle contains disallowed file 'Frameworks') when uploading to TestFlight. Do you by any chance have some demo/dummy project that shows how a project with such a .framework can be build in a way that can get successfully submitted to the App Store?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Any other way aside UnitySendMessage? 1 Answer
Build & Run for IOS failing 1 Answer
Localize iOS App name from Unity 1 Answer
iOS Strange Render Lag 1 Answer