简体   繁体   中英

Unity iOS Plugin for Bluetooth communication - Swift or Objective-C

I want to create a native iOS plugin for Unity to enable an iPhone app to communicate over Bluetooth and use Unity to display the received data.

From my current point of view I see two ways:

  • Create a Swift library: Preferred as I already have knowledge in Swift, but as it seems I would have to create Objective-C bridge classes to be able to access the Swift methods in Unity.

  • Learn Objective-C and create an Objective-C library

As it seems Objective-C is required anyway but using Apple's recommended programming language Swift would be a more recent approach.

Which way would currently be best-practice?

Unity only knows Objective-C. Therefore you would need to write in Objective-C or write in Swift and have some kind of bridge, as you mentioned.

As Bluetooth has a lot of boilerplate code and some level of complexity and swift is much nicer and you know it already , I would try the bridge-approach first. The Bridge-API will be easy and not change much over time.

There are some projects like unity-swift that can help you to get started.

You will know very fast if this is an approach that fits you, even before you start with the Bluetooth stuff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM