Dll import issue in native plugin

Hi everybody.

We are trying to implement out first native plugin for iOS.

What we wanto do is use a third party library (is a static library .a) to implement some logic layer over it. We put third-party library in to Assets/Plugins/iOS.

All compilation & build phases went fine but we’re getting linkage into device. Static library are included into dependencies of the generated project.

DllNotFoundException: Unable to load DLL ‘libThirdParty’: The specified module could not be found.

We also try with (“ThirdParty”, “libThirdParty”, “libThirdParty.a”)
[DllImport (“ThirdParty”)]
private static extern void HelloWorldPluginFunction();

[DllImport (“libThirdParty”)]
private static extern void HelloWorldPluginFunction();

[DllImport (“libThirdParty.a”)]
private static extern void HelloWorldPluginFunction();

What we are forgetting / doing bad?. Anyone was found same problems.

Thanks in advanced,

2170232–143602–OurFirstPluginProxy.cs (896 Bytes)
2170232–143603–Archive.zip (1.24 KB)

on ios you should do
[DllImport(“__Internal”)]

Using [DllImport(“__Internal”)], XCode reports next link errors.

Undefined symbols for architecture arm64:

“_HelloWorldPluginFunction”, referenced from:

_OurFirstPluginProxy_FaceMePluginFunction_m1 in Bulk_Assembly-CSharp-firstpass_0.o

(maybe you meant: _OurFirstPluginProxy_HelloWorldPluginFunction_m1_MethodInfo, _OurFirstPluginProxy_HelloWorldPluginFunction_m1 )

ld: symbol(s) not found for architecture arm64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

remove “static” from your header

Thank you very much Alexey.

We are a bit step closer to the solution.

We have run into new difficulties. Internally our plugin uses an external framework. Simply deploy generate project we got:

"
dyld: Library not loaded: @rpath/FaceMe.framework/FaceMe

Referenced from: /private/var/mobile/Containers/Bundle/Application/98E85F0B-E7D9-4C66-A49E-996EDF311F47/ProductName.app/ProductName

Reason: image not found
"

Even so after

  • Add framework reference.
  • Add framework to embedded binaries setting.
  • Add a extra copy build step to install frameworks in Frameworks
  • Set ‘@executable_path/Frameworks’ to Runpath search Paths

Same result! :-(.

Is it possible to create a native plugin that use external framework?.

Thank in advanced

Could you please check out this?
http://stackoverflow.com/questions/25909870/xcode-6-and-embedded-frameworks-only-supported-in-ios8

OH!!! It’s alive!

Very thx povilas.

I understand this is an old thread, but this is the only place I’ve seen any hope for a week now as I’m getting the exact kind of error as op

I’m getting this error in Xcode

Undefined symbols for architecture arm64:
  "__unityTapticIsSupport", referenced from:
      _TapticManager_IsSupport_mADBE6C1751030925D79B930DDB17B1D746603C29 in Assembly-CSharp5.o
      _TapticManager__unityTapticIsSupport_mD9FBB8237C589E9CA90CE31B718C8D8859237DCB in Assembly-CSharp5.o
     (maybe you meant: _TapticManager__unityTapticIsSupport_mD9FBB8237C589E9CA90CE31B718C8D8859237DCB)
  "__unityTapticImpact", referenced from:
      _TapticManager_Impact_m756F7B9F2CEEEF90D0A9EA7EDABAE56E6EA18F2C in Assembly-CSharp5.o
      _TapticManager__unityTapticImpact_m4F8AA189DEFAB5590E8A08680DB6FE07C6682FB3 in Assembly-CSharp5.o
     (maybe you meant: _TapticManager__unityTapticImpact_m4F8AA189DEFAB5590E8A08680DB6FE07C6682FB3)
  "__unityTapticSelection", referenced from:
      _TapticManager_Selection_m52193285DA40B5A88C065CA88214F3FE524F8AA6 in Assembly-CSharp5.o
      _TapticManager__unityTapticSelection_m06C11D6513340D0518D65E8C065777895D1D4CC1 in Assembly-CSharp5.o
     (maybe you meant: _TapticManager__unityTapticSelection_m06C11D6513340D0518D65E8C065777895D1D4CC1)
  "__unityTapticNotification", referenced from:
      _TapticManager_Notification_mAC7242D4C817986B9B2943B730CA4166CFA23969 in Assembly-CSharp5.o
      _TapticManager__unityTapticNotification_m3B907AA8EB1DB3F0EDE84D1130A56E04B9F37109 in Assembly-CSharp5.o
     (maybe you meant: _TapticManager__unityTapticNotification_m3B907AA8EB1DB3F0EDE84D1130A56E04B9F37109)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I believe this is the code in question

using System.Runtime.InteropServices;

namespace TapticPlugin
{
    public enum NotificationFeedback
    {
        Success,
        Warning,
        Error
    }

    public enum ImpactFeedback
    {
        Light,
        Medium,
        Heavy
    }

    public static class TapticManager
    {

        public static void Notification(NotificationFeedback feedback)
        {
            _unityTapticNotification((int)feedback);
        }

        public static void Impact(ImpactFeedback feedback)
        {
            _unityTapticImpact((int)feedback);
        }

        public static void Selection()
        {
            _unityTapticSelection();
        }

        public static bool IsSupport()
        {
            return _unityTapticIsSupport();
        }

        #region DllImport

#if UNITY_IPHONE && !UNITY_EDITOR
        [DllImport("__Internal")]
        private static extern void _unityTapticNotification(int type);
        [DllImport("__Internal")]
        private static extern void _unityTapticSelection();
        [DllImport("__Internal")]
        private static extern void _unityTapticImpact(int style);
        [DllImport("__Internal")]
        private static extern bool _unityTapticIsSupport();
#else
        private static void _unityTapticNotification(int type) { }

        private static void _unityTapticSelection() { }

        private static void _unityTapticImpact(int style) { }

        private static bool _unityTapticIsSupport() { return false; }
#endif

        #endregion // DllImport
    }

}

How would I get this to stop throwing that error?

There was a recent(?) change in unity where you now need to make sure the files get linked to the framework, rather than the app in xcode.