Xamarin. ios references third-party SDK, xamarin. iossdk
Introduction
It is true that Xamarin is an excellent cross-platform solution, but it still cannot be implemented directly in all Native methods. For example, various third-party libraries only support java/oc native sdks and cannot be directly used. However, if you can't use it directly, you can't expand the APP function, and you can't use the wheel you have created? The answer is no! In Xamarin, You can reference the Jar package in java and file A in oc to achieve this!
What is archive?
File a is the class library in iOS. I think it is called file a because the file extension generated by file a is.. Example:
How to Create File
1. Create a new project in XCode, select Cocoa Touch Static librar in framework & library under iOS, enter the Product Name, and select the storage address. The project is created.
2. Project Overview
3. Click the TestClassLib. h file generated by default in the left sidebar and add a public static method to the file. To reference the project calling method of File.
4. Open TestClassLib. m and write the specific implementation method for the add method.
5. Set CodeSigning in project settings to Developer.
6. Build For Running
7. After running successfully, expand the Products folder and you will be able to see the required a file. Show in finder. In Debug-iphonesimulator, file a is used for the iPhone device simulator; In Debug-iphoneos, file a is used for the real machine. If there is only one type (as shown in Figure 1) after opening the folder, we need to Build For Running again. before re-compiling, in xcode, adjust the compilation target (figure 2 below). When you open the finder, you can see two types (figure 3 below)
Reference file a in the Xamarin Project
1. In an existing Xamarin project, add a new project, select a project of the Bindings Library type, write the project name, and create the project successfully.
2. In the created Bindings Library, add an existing project, select the file a we just created, and confirm that the file BuildAction is ObjcBindingNativeLibrary.
3. Download Objective Sharpie -- tool link for converting c # code: https://files.xamarin.com /~ Upper/ObjectiveSharpie/ObjectiveSharpie-3.0.8.pkg
1. Enable terminal
1. Confirm the Xcode SDK version and enter sharpie xcode-sdks.
2. Switch to the location where you want to generate the file
3. input the conversion command sharpie bind-output
4. sharpie bind-output TestClassLib-namespace TestClassLib-sdk iphoneos9.3./TestClassLib/*. h
4. Replace ApiDefinition. cs in the Bindings Library with the ApiDefinition. cs generated by Objective Sharpie.
Note that the tool generates ApiDefinitions, while the original project is ApiDefinition. If there is more than one s, you must not change the file name. Otherwise, an error is reported.
In addition, errors in ApiDefinition do not need to be ignored, and build will not report errors.
5. Well, our operation is almost over now. Next, write the code and call the method in file.
Conclusion
Okay, this article is over. Although I didn't take any SDK on the market as an example, I think it would be better to teach people to fish than to teach them to fish. I know how to make file a and reference file, most sdks should be ready.
References: https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/
Https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-sharpie/