Search code examples
androidswiftcocos2d-iphone

Can Cocos2D-Swift code written in Swift be ported to Android?


I'm new to game development and I'm very interested in Cocos2D-Swift, specially because of the Android compatibility. I know Objective-C code can be ported to Android, but can I say the same of Swift?

Thanks in advance.


Solution

  • Swift support for Android via the SpriteBuilder Android plugin is currently in development. However there's no release date yet.

    Since you're new to game development I think it's fair to say that you can use Swift without having to worry about cross-platform development at this point.

    It's more important to get your first app running and out there, or just getting it to a stage where you're so hopelessly lost that you'd rather start it anew or a different project altogether, taking with you what you've learned. Personally I find that every new game I start developing with a new engine ends up being completely refactored at least once throughout development just due to how much better you can work with the engine once you've learned how to (best) use it.

    If your app is successful and you want to port it to Android but Swift support weren't available yet and you really need to port, there's always the option to transcribe Swift code to Objective-C. It's fairly straightforward (albeit tedious) and if you're lucky someone even made a two-way Swift-ObjC converter by that time.