Unity iPhone and External Accessories

Does the Unity iPhone API support Apple's External Accessories API? In other words, is it possible to write an app using Unity that communicates with an iPhone accessory?

Nope, Unity doesn't support the external accessory API, but if you use Unity Advanced you can write your own native C functions to access that API, and call those functions from inside Unity.

Actually you can do it, but it takes jumping through a couple of hoops.

First you have to build your project for iOS so that the Xcode project is generated. Then you edit the Xcode project and add the External Accessory Framework. You also have to add a new entry in the plist for the Support External Accessories. Here you have to add the protocol that the External Accessory requires. This is only needed if you are not using one of the generic communication protocols. If it is a Bluetooth device and example would be the standard Serial Port Protocol.

The problem is that none of this is supported in the Unity IDE. You have to do it all in the Xcode IDE. I have done this and it works. The problem is that if you build the Unity project again and hit Replace everything is over written. If you choose Append then only the Framework stays. You have to re-add the Supported Protocol each time you build.

There are also some posted about how to copy the plist file to your Unity project and then create a script to copy it over the auto generated one. I am going to work on trying that soon, but have not done it yet, so I cannot give feedback on that yet.

I have added a Feature Request to address this. If you are interested in helping it get noticed then you can view it here:

Unity Feature Request