iOS uses C # preprocessing commands, multiple SDK coexistence

Source: Internet
Author: User

When we use Unity to connect 91,XY Assistant and so on SDK. We need to use [DllImport ("__internal")] to declare a C + + method call.

Different SDKs will always have different methods. I am used to writing XYSDK class, BAIDU91SDK class inside the various [DllImport ("__internal")] declared method

The problem is, if we release the XY SDK, and the method of the SDK is not placed in the Xcode project. So the compilation does not pass. We need to put the method of the C + + package into the project.

We can use pre-processing commands (to choose to compile some code) so that we do not need to publish XY, but also to put the method of the C + + encapsulated in Xcode compiled

#defineBaidusdk//#define XYSDK//If we need to send that version of the SDK, we'll comment out the other # define.usingUnityengine;usingSystem.Collections; baidu91sdk{#if(BAIDUSDK)[DllImport ("__internal")]    Private Static extern voidbuy props ();#endif}xysdk{#if(XYSDK)[DllImport ("__internal")]    Private Static extern voidOpen the hover window ();#endif}

The above code is simple #define BAIDUSDK. Define a preprocessing command variable (it is a token)

#if (BAIDUSDK) {//If the tag is defined

The code inside will be compiled

}

This is the implementation code selection compile O (∩_∩) o~

iOS uses C # preprocessing commands, multiple SDK coexistence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.