Laerdal / Laerdal.Dfu.iOS

Xamarin binding library around @NordicSemiconductor's DFU library. The native iOS Pod library is located here: https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library
BSD 3-Clause "New" or "Revised" License
7 stars 4 forks source link

NuGet package linker issues #1

Closed SuperCorks closed 3 years ago

SuperCorks commented 3 years ago

Hey guys,

First of all, thank you for this. It saved me a lot of time! 🙏

I've been using the older NuGet (the one that started with Xamarin) without any issue. Today I changed to the new NuGet package (the one that starts with Laerdal), but when I build I get linker issues (see logs below).

The package is wrapped in an iOS library project, so it's imported in there. I've also imported it in the iOS app project (not sure if I had to do that). Tried to build with linker behaviors: Link All, and Don't Link

Is there anything I'm missing?

Using: Xamarin 4.8.0.1821 Laerdal.Xamarin.Dfu.iOS 4.9.0.6 Visual Studio Community 2019 16.8.3

Build logs:

17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): warning MT0127: Incremental builds have been disabled because this version of Xamarin.iOS does not support incremental builds in projects that include more than one third-party binding libraries.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error : linker command failed with exit code 1 (use -v to see invocation)
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUFirmware. The symbol '_OBJC_CLASS_$_DFUFirmware' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUFirmwareSize. The symbol '_OBJC_CLASS_$_DFUFirmwareSize' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUPeripheralSelector. The symbol '_OBJC_CLASS_$_DFUPeripheralSelector' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUServiceController. The symbol '_OBJC_CLASS_$_DFUServiceController' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUServiceInitiator. The symbol '_OBJC_CLASS_$_DFUServiceInitiator' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUUuid. The symbol '_OBJC_CLASS_$_DFUUuid' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUUuidHelper. The symbol '_OBJC_CLASS_$_DFUUuidHelper' could not be found in any of the libraries or frameworks linked with your application.

I can send you a minimal replication project if you ask for it.

framinosona commented 3 years ago

Hi @SuperCorks,

Thank you for testing it and for the Log 👍. I see where it comes from and reproduced it. I'll release an updated version with this fixed soon.

SuperCorks commented 3 years ago

Epic François, thanks a lot!

framinosona commented 3 years ago

Okay just pushed v4.9.0.7. Let me know :)

Moret84 commented 3 years ago

Hello @framinosona , many thanks for your package. I have followed the issue and saw the update but unfortunately I am facing similar errors as @SuperCorks with 4.9.0.7 version.

SuperCorks commented 3 years ago

Sorry to say that 4.9.0.7 has indeed not fixed it.

17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUFirmware. The symbol '_OBJC_CLASS_$_DFUFirmware' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUFirmwareSize. The symbol '_OBJC_CLASS_$_DFUFirmwareSize' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUPeripheralSelector. The symbol '_OBJC_CLASS_$_DFUPeripheralSelector' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUServiceController. The symbol '_OBJC_CLASS_$_DFUServiceController' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUServiceInitiator. The symbol '_OBJC_CLASS_$_DFUServiceInitiator' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUUuid. The symbol '_OBJC_CLASS_$_DFUUuid' could not be found in any of the libraries or frameworks linked with your application.
17>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(711,3): error MT5211: Native linking failed, undefined Objective-C class: DFUUuidHelper. The symbol '_OBJC_CLASS_$_DFUUuidHelper' could not be found in any of the libraries or frameworks linked with your application.
framinosona commented 3 years ago

Yep, investigating still :/ Sorry about that. First, I know that I was missing [Protocol] on those classes, but now that this is fixed when trying to use them, I get "ObjCRuntime.RuntimeException: Can't register the class Laerdal.Xamarin.Dfu.iOS.DFUFirmware when the dynamic registrar has been linked away." so I'm trying to fix that now.

SuperCorks commented 3 years ago

No worries, let us know if you need any help. I haven't worked with binding libraries much, but I know there's a [PreserveAll] tag that could maybe help avoid things getting linked out.

Also, maybe adding the following mtouch argument: --optimize=-remove-dynamic-registrar (notice the - before remove)

framinosona commented 3 years ago

Yep tried the Preserve all and it didn't change that, the --optimize=-remove-dynamic-registrar could work but it would require people who use that nuget to have to add it to their project, I'm trying to prevent that. It worked before and I think it has to do with my "objective sharpie" operation. On previous versions my classes had generated names like "TtP13iOSDFULibrary29DFUPeripheralSelectorDelegate" and now my Objective sharpie doesn't generate them ... I remember that a year ago I had come up with a couple of convenient regex to change the iOS Framework .h file before sharpifying them... I'm digging through archives :)

framinosona commented 3 years ago

Found it! Before building the iOS (xcode) project I need to run:

https://regex101.com/r/li9ll8/1

Okay I'll try that and send a new package if it works :)

framinosona commented 3 years ago

OKAY ! This one should be the right one :)

https://www.nuget.org/packages/Laerdal.Xamarin.Dfu.iOS/4.9.0.11

I've tested without adding --optimize=-remove-dynamic-registrar or anything, just the Nuget and it worked. Let me know :) @SuperCorks and @Moret84

SuperCorks commented 3 years ago

Works on my side. Thanks a lot François! Cheers!

yogeshk25 commented 3 years ago

This is back again in 4.9.0.14