Forum Xamarin.iOS

Why do iOS Release builds strip symbols necessary for PInvoke when using dllmap?

sheashea USUniversity ✭✭


I am working on a cross platform Windows/iOS app.
I have a Windows project, an iOS project and a .netstandard (core) project. The core project, which is referenced by both platform specific projects, contains a large amount of platform non-specific shared code.

The core project PInvokes a C library for some of its functionality. I have two builds of this library, libMyLibrary.dll for Windows and libMyLibrary.a for iOS, which are included in the respective projects. The core project PInvokes a large number of functions in libMyLibrary like so:
[DllImport ("libMyLibrary", CallingConvention = CallingConvention.Cdecl)]

In my iOS project I include libMyLibrary.dll.config with the following contents:

<?xml version="1.0" encoding="utf-8"?>
    <dllmap dll="libMyLibrary" target="__Internal"/>

The dllmap directive is terrific and solves a lot of problems of code organization, duplication and maintentence, except for one issue:

When symbols get stripped from Release builds of the iOS app it strips the symbols necessary to PInvoke libMyLibrary, which causes System.EntryPointNotFoundException to be thrown. Debug and simulator builds for iOS work fine. I can fix the problem with Release builds of the iOS app the by specifying the --nosymbolstrip mtouch argument, but that prevents all symbols from being stripped, which is undesirable.

As a test, I removed libMyLibrary.dll.config from the iOS project and changed the PInvokes in the core project to reference "__Internal". This in fact fixes the problem (the necessary symbols are no longer stripped) but of course this isn't a solution because it breaks the Windows app.

I can also fix the problem by appending a very long list of the specific symbols I don't want stripped to --nosymbolstrip=...

That's the best solution I've found so far, but I don't really like it because the list of symbols I have to specify is ridiculously long and I also now have to maintain that list as my project progresses.

Am I missing something?
Is this a bug?




  • BrentWeatherlyBrentWeatherly USMember, University

    Has there been any update to the issue as described? I'm running into this exact thing and it'd be great to avoid maintaining a super long list of --nosymbolstrip arguments.

Sign In or Register to comment.