Currently trying to create a wrapper for an iOS framework on Unity.
I made a .bundle, containing basic objective-c code :
sample.h :
#import <Foundation/Foundation.h>
extern "C"
{
void SampleFunction(); // this is going to call already bridged swift or objc code
}
sample.mm :
#import "Sample.h"
#import <SDK/SDKFunctions.h>
void SampleFunction()
{
// my sweet functions calls
}
The SDK is included in the bundle as a .framework (references in "Linked Frameworks and libraries"). The bundle target is iOS.
The bundle builds successfully.
The bundle is placed in Unity under "Assets/Plugins/iOS", marked as "iOS" and "Add to Embedded Binaries"
Then, in Unity, there is a simple C# script calling SDK functions :
sample.cs
public class BundleImportSample : MonoBehaviour {
#if UNITY_IOS
[DllImport("__Internal")]
private static extern void SampleFunction();
#endif
void Start()
{
#if UNITY_IOS
SampleFunction();
#endif
}
}
When I test this code in the editor I get the following error :
EntryPointNotFoundException: SampleFunction
If I build the generated project on iOS, I get a similar issue :
ld: symbol(s) not found for architecture arm64
Note : I used the following tutorial as guideline : http://blog.mousta.ch/post/140780061168
Why is SampleFunction() not found in __Internal ?
Code was fine.
The issue was about slices in the .bundle. It was built for i386 / x86_64 instead of arm64 / armv7 /armv7s.
To avoid this issue check the following options on your target :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With