I’m trying to get the Enet netcode transport (transports run on top of Netcode for Game Objects) working on iOS but having a lot of issues. This is the actual package and it’s installed via git url. Unity is version 2020.3.25f1.
This transport is working fine on standalone and Android, but I’m having a lot of trouble getting it working on iOS. For Android we have the compiled libs in
Assets/Plugins/Android/lib with subdirs for each architecture, and a
.so file in each one of those subdirs. I built enet from source for iOS which results in a file
libenet.a which I put in
Assets/Plugins/iOS and set to iOS only and arm64. After building in Unity, in the XCode project under UnityFramework Link Binary With Libraries I can see
libenet.a so it is in the project, it just can’t find it at runtime for some reason. I also tried putting
libenet.a in the runtime dir of the actual transport under
Packages, where the 3rd party package is installed, but no luck there either.
I’m not sure if there is a different way I need to be compiling this for iOS, a different file extension, or if I’m putting it in the wrong folder/need to change inspector settings in Unity, but I’ve tried quite a few permutations of all these and when running on iOS, it keeps giving this stack trace:
DllNotFoundException: Unable to load DLL 'enet': The specified module could not be found. at ENet.Native.enet_host_create (System.IntPtr address, System.IntPtr peerLimit, System.IntPtr channelLimit, System.UInt32 incomingBandwidth, System.UInt32 outgoingBandwidth, System.Int32 bufferSize) [0x00000] in <00000000000000000000000000000000>:0 at ENet.Host.Create (System.Nullable`1[T] address, System.Int32 peerLimit, System.Int32 channelLimit, System.UInt32 incomingBandwidth, System.UInt32 outgoingBandwidth, System.Int32 bufferSize) [0x00000] in <00000000000000000000000000000000>:0 at ENet.Host.Create (System.Int32 peerLimit, System.Int32 channelLimit) [0x00000] in <00000000000000000000000000000000>:0 at Netcode.Transports.Enet.EnetTransport.StartClient () [0x00000] in <00000000000000000000000000000000>:0 at Unity.Netcode.NetworkManager.StartClient () [0x00000] in <00000000000000000000000000000000>:0
One of the causes I have investigated is that the C# attribute DllImport was not referencing __Internal for iOS. Since this is a third party library, I am not calling DllImport myself. However I did check that this was being done internally and it looks like it is. It’s a little convoluted though, because this package/transport we’re using is a wrapper for the ENet-CSharp package, but they are using a built version of ENet-CSharp so it’s very hard to tell where it came from, what its version is, and what its source code looks like.
From what I can tell, this is the actual source code of ENet-CSharp.dll referenced in the netcode wrapper, and it looks to be using __Internal as the lib name for iOS platform.
so, I’m pretty stumped on why it can’t find the lib at runtime.