XCode starter

I really love Corona for it’s ease of use, the graphics system is so capable and the physics engine is so manipulable. But now there are plugins and somewhere inspired by Scott H’s work, I want to expand the offerings.

My big problem is XCode and the fact that every time over the past years that I’ve tried to get going with it, I’ve failed utterly. It is so completely alien to what I know that I find any tutorial is quite simply not a “from scratch” experience - they  all require assumptions which are extremely difficult (impossible?) to avoid making differently when you have years of experience in another system.

Simply trying to get XCode playgrounds to show me something when the default template code should run out of the box was confusing - until I realised that it’s not going to actually show a window; Everything it renders is right there in the code window (at least, that’s how it appears to me.)

I still haven’t had time to go through your videos, but I will ASAP! Thank you again!

Hey @agramonte, a little off topic, but what tool did you use to record your video and what’s the little icon in your top bar which looks like a speedometer?

Back on topic… I notice that you’re working with .mm and .h files, so that code is Obj-C; Is Swift supported for plugin development?

Anyone interested in writing plugins for Corona should watch this series by Adrian Gomez:

https://www.youtube.com/playlist?list=PLzlEhF55FpRIXXk0rDpKU9Yn1pNYF8D-W

  1. The speedometer is a the BassJump II utility. It is a subwoofer for your Macbook. More gimmicky than useful. Mine is in a box somewhere in a closet. It is only $34.00 now. Much cheaper than when I first got it. 

  2. I use just QuickTime to both edit and record. My machine can’t handle anything else.

  3. I do not believe Swift is supported. I have not seen any documentation or examples in Swift, but the limitation I don’t believe is Corona. It might be LUA bindings. If you look at other Lua game engines processes to create native plugins those are very similar to Corona. Rob would probably know more.

I found this two year old quote from Rob (it might need a little updated), but I think everything he said still holds true:

So here’s the deal.

 

  1. You cannot make plugins in Swift. Plugins use static .a libraries. Swift cannot produce these. Swift can create frameworks, but that’s not something we can use in Corona SDK. It will probably be a big engineering effort to get there.

 

  1. There is no good Swift-Lua interface. Lua was built for C++. In Xcode, you can mix Objective-C and C++ (and C for completeness) in the same files. This makes Lua->C++ easy and you can make Objective-C calls as needed.

 

  1. What you can do is have a Swift class and have a C++ wrapper. In other words lets say you have a Lua call:

 

library.show()

 

That would call a C++ function called show(). It would then take parameters you passed from Lua and turned into Objective-C data types like NSDictionary, NSString, etc. and it would call your Swift classe’s show() method.

 

We are going to produce a sample project that makes this all possible, but it needs to go through a code review before we can upload it to our Github repo.  So we might have something soon if we don’t find further issues.

 

The project is setup to basically make a non-plugin plugin if that make sense. Its called Plugin in the code and gives you plugin like access (i.e. local library = require( “plugin.library” ) in your Lua code), it’s just not a distributed standalone plugin.

 

Rob

Swift should be supported. Initially, we did not because Swift could only create frameworks and not “.a” library files. But we started supporting frameworks some time back. Back when I messed with it last time, there were some extra things needed to set up a Swift to C bridge. But that was like in Swift 1 and 2 days. We are now up to Swift 4 I think and I don’t know if that’s still required or not. I can ask an engineer to chime in more on this.

I do know that we had Swift working for CoronaCards for certain. You might want to grab some of those projects from our GitHub account and poke around in them. The Swift-C bridging isn’t really anything Corona specific.

Rob

Hey!

Corona does support Swift at this point, as well as dynamic libraries (packaged in frameworks), which can contain Swift. However, Lua Bindings is a problem. It can be easily bypassed by using Swift-Objective C bridging. This allows to write parts of code with Swift, but still all interface has to be written with ObjectiveC (or C) because of lua_ calls. This probably can be helped with usage of some wrapper, but I didn’t look into it.

If you have some codebase written in Swift, I can probably provide with example of plugin which uses swift, so you can make a plugin out of it.

Thanks guys - I have no code in Swift or Obj-C at the moment. Just starting out with all this. I have an idea for a plugin, but it’s a long way to go with a lot of learning ahead, yet…

Hi Guys,

Can you anyone share some formal tutorial for using Swift in app development. I am not looking for plugin to be developed. i am developing an app in which i am suppose to use Swift code. So if possible please help me.

You can try some free course, like https://www.udacity.com/course/intro-to-ios-app-development-with-swift–ud585