Xamarin.iOS unrecognized selector sent to class

Xamarin.iOS unrecognized selector sent to class

First, the problem

When attempting to bind Baidu push the iOS SDK, encounters unrecognized selector sent to class this problem causes app to crash.

On this issue, a lot of online search, or stick a post it here Other Linker Flags

Second, the solution in native iOS

The solution to this problem encountered three:
in the Other Linker Flags in plus parameters needed to add a link to a document library, used generally have the following three parameters:

1. -ObjC

This flag tells the linker to the library defined in Objective-C classes are loaded and Category to come. After compiling this app becomes large (because the code loaded Other objc come). But if the class and category, then a static library, only to join the flag down.

2. -all_load

This flag is devoted to a bug -ObjC's. -ObjC used later, if the library is not only a category or class when the category does not come loaded. Workaround is to add or -all_load -force-load. -all_load will force the linker to the target files are loaded in, even without objc code.

3. -force_load

This flag does things with -all_load in fact is the same, but you need to specify -force_load to be fully loaded library file path, this is the case, you're just completely loaded with a library file, without affecting the rest of the library files needed loaded, -force_load available after xcode3.2.

Three, Xamarin.iOS in solution

So how to solve this problem in Xamarin.iOS binding it?

Baidu to push, for example: libBPush.a

When you add a file to bind the project, set up automatic generation operation of the file Xamarin will provide ObjcBindingNativeLibrary, and creates a special file called libBPush.linkwith.cs of.
Code is as follows:


using ObjCRuntime;

[assembly: LinkWith ("libBPush.a", SmartLink = true, ForceLoad = true]

We need to make the following modifications: Add LinkerFlags in LinkWith in = "-ObjC" such a sentence


using ObjCRuntime;

[assembly: LinkWith ("libBPush.a", SmartLink = true, ForceLoad = true , LinkerFlags = "-ObjC")]

Such problems can be solved Baidu push-bound, of course, to analyze specific issues it.

Guess you like

Origin www.cnblogs.com/devin_zhou/p/11994086.html