Best way to get code INTO Codea

Getting code OUT of Codea is easy, either export a project or use AirCode to copy / paste into your local editor of choice, But…

Since the last update when Apple (in their infinite pettiness) insisted that file sharing was turned off, it’s meant that there’s no easy way to access the local file store (either through iTunes or iExplorer on iOS 8+) to copy code INTO a codea project.

I’ve tried Aircode (creating the required tabs ahead of time) but the copy and paste has been very ropey for me and if there are any errors in the code then the tab isn’t saved so if you change tabs or restart your app you can loose large portions of code…

Does anyone have a “simple” “foolproof” way of getting code into Codea - I often write large sections of code on my laptop and I’m also looking at porting / sharing some code from some of my Corona projects so this is getting kind of a big deal for me.

I remember trying to get the community backup server working a while back and could never get it to work properly - so if that is the best solution if there’s anyone still using it can you point me at a guide for eejiits :slight_smile:

Also - how easy / feasible is it to create custom asset packs given the same restrictions on local file access?

Thanks in advance.

Have you looked at Dropbox.

EDIT: I use Dropbox for backups of all my projects. I create a single file containing all my projects (400+ projects, 1.5MB size) as a txt file using saveText and sync it with Dropbox. It also gets syncs with my PC. I use readText when I need to read the file to get a specific project.

I really like the app Working Copy. It’s an iOS git client. It’s the main way I use to get repos into Codea. You can set it up with your GitHub/ BitBucket credentials, access any repos you’ve forked/ starred/ cloned. Cloning a repo is as simple as copying the URL of the repo you want from the safari bar (you don’t even need the proper git URL), opening Working Copy and hitting +.

From there, if the code is in a single tab, then it has a copy button which places the entire code in your clipboard (seeing as even simple copying a load of text is a sh!t show in iOS Safari), for easy porting into Codea.

If it’s a multitab repo, I’ve written a Codea client for it that can bring all the tabs into a Codea project by accessing the files on the WebDAV server that Working Copy offers. I admit that this is probably overkill if you’re just wanting to pull tabs into Codea. Some kind of Dropbox based solution might be easier for that. But if you’re also wanting version control then I think going via git is worth it.

Working Copy is also excellent for getting code out of Codea. It can take the zip files that Codea outputs (either the new project export, or the full Xcode project), and do various things with them, unzip them to repositories etc.

Of course, as a full-featured git-client it’s fantastic for version control and backup.

There’s also a very nice client for it in Pythonista (if you use other iPad coding apps).

It has great links with iOS text editors (especially Textastic).

It basically has every inter-app protocol you can think of. X callback URL-schemes, iOS 8/9 open in, WebDAV, etc.

Finally, the latest version added the best JavaScript debugging console I’ve seen on iOS, if you’re also coding html/js. (I’m in the beta programme, but I think this feature is now out in the main release)

It’s one of my most-used apps (after Codea), and an essential tool IMO for coding on an iPad.

I’m not affiliated with the dev, but he’s very responsive on email to feature requests etc, and new versions come out very quickly.

Regarding asset packs, I almost exclusively use Dropbox now, with readImage and readText. Because it gives you access to your assets from your computer (though no sub folders).

If you are not against doing some source control too, then i would suggest taking a look at Codea-SCM. The site:

Discussion thread:

Thanks guys, lot’s of suggestions there. Shortly after posting I remembered DropBox text sync, it’s a bit of a faff but I guess it works (hooking up the bluetooth keyboard helps with the copy / paste).

@dave1707 I forgot that Codea allow’s for access other tab’s projects etc, I’ll have a look at putting together a simple utility to import / export code.

FWIW - If any is interested in porting code to / from Corona, I’ve found that the Class.lua implementation ( helps to make my modules / classes more portable. Ultimately I want to create a more concrete implementation of the display stage (which should be fairly easy using the translate() function).

Is it worth creating a new thread specifically to discuss porting issues?

Here’s a link to my socket-based method:

These methods are all great, but would be even better if we had a listProjects() and newProject/createProject command, one of the most frequently requested features over the past few years. I’d urge anyone reading to up-vote these tickets:

In the absence of listProject there is the trick of grabbing the name of a project’s dependencies by looking at the Info.plist (why the name of the project itself isn’t recorded anywhere I don’t know!) You can see it here:

BTW, @dave1707 is that your code in the above link? Also, do you have an up-to-date version somewhere?

@yojimbo2000 Yes, that’s my code. I have a better version that uses saveText and readText and is easier to use. I figured no one was using it so I never posted an update.

You should put it in a gist/ github repo so that people can find the most up-to-date version more easily.

I’ll clean it up some before I put it on github.

Thanks, looking forward to it!

One advantage of using the Lua file io method is that you can actually name the files .lua put them into folders etc, and they won’t show up in the asset picker, cluttering it up (but you can still access the files in Dropbox on the desktop of course). I imagine if you’re using savetext for every Codea project, the Dropbox asset picker must become almost unusable.

@yojimbo2000 Not sure why you think the Dropbox asset picker would be almost unusable. When I create a backup file (400+ projects), all of the projects are in 1 file. I can have several backup files and it’s no problem seeing them in the Dropbox folder. I can extract as many projects out of the backup file as I want.

Ok, I thought you were saving them to separate files.

Is it worth creating a new thread specifically to discuss porting issues?

@TechDojo I’d certainly be interested in hearing more about this. Are you porting to Android?

@yojimbo2000, yes and no (sortof), I’m actually porting the code to use Corona, which gives me the cross platform output.

I did actually release an app written purely in Codea and then decided to re-write it in Corona specifically to get Android compatibility (although that wasn’t the only reason otherwise the 8000+ downloads on iOS vs the 44 on Android would have made the effort a waste of time :slight_smile: )

But having bitten the bullet now, I’ll probably do all of my releases via Corona but I still want to prototype using Codea.

Like a lot of other environments Corona often uses the require command to include modules which use the standard pattern of declaring a local table inside the module, attaching functions and variables to it and then returning it.

What I did in my (Corona) main.lua was to require the Class.lua file - that way the class() command was added to the global scope then I could pretty much use files I’d written in Codea directly, especially library / utility classes that have no visual output.

I always try and keep a clean separation between logic and rendering which makes transitioning between the different direct mode (Codea) and retained mode (Corona) rendering engines easier.

This might seem like a lot of faff, but the reasoning is that I want to use as much of my free (or wasted) time developing apps, a lot of that time is during my daily commute (1hr train each way) and it’s not always feasible / practical to pull out a 15" laptop so I rely on my iPad mini / bluetooth keyboard.

Using Codea’s built in class system is great and I can run code / tests to make sure stuff works and then I can extract the code and include it with the rest of my Corona project.

Obviously I want to be able to sync back any changes I make on my laptop so I’m no reliant on one environment (hence the original question), so anything I can do to lessen the gaps between the two is a win for me.

@dave1707 : It’d be great if you could share your code :slight_smile:

@TechDojo It’s close, I changed the way I extracted projects. I was having trouble with - in the name because for gmatch, - is a magic character and doesn’t match. A project with multiple tabs are extracted into 1 tab and then when you do the paste into project all of the tabs get separated and created. I was able to backup Cargo-Bot, extract it, paste it into a test project, and run it OK. I figured Cargo-Bot was a good test because it’s so big and has 47 tabs. If I can handle Cargo-Bot, anything else should work too.

@TechDojo 8000+ downloads, good work! Why Corona and not one of the other Lua based cross -platform IDEs, Gideros or Moai? I’ve heard lots of good things about Moai, and I’ve heard that the Rapanui layer makes it very similar to Corona/ Codea (ie more high level), but with the advantage of it being free/ open source. I’ve not tried any of them yet though.

@Yojimbo2000 not wishing to brag :slight_smile: but as of today it’s well on it’s way to 9000 and after the Apple tax it’s earned about $630 (off just over 300 IAP sales), which is not a vast sum, but it’s more than paid for my Apple dev account this year and given the family a couple of nice treats. With proper marketing it could do a lot better. I have another similar app aimed at a different sector of the same niche and that one was paid only and did practically nothing - and only started to pick up once I made it free (currently just over 400 units).

My first app is making on average about $2 per day now which whilst is not going to set the world on fire is a good indication of how a decent second income could be made, simply write, publish repeat and keep pushing the marketing and exploit the long tail, throw in regular updates and grow your business incrementally (10 apps behaving like that would pull in over $7000 per year - which if nothing else would pay for a very nice family holiday and help with Christmas).

If approached correctly, each successive app get’s easier and easier to write as you can reuse more and more code and your systems and processes get fine tuned to be more efficient. And the better you get at your craft and the better you know your target audience increases the possibility / probability of a more successful app.

The main lesson learnt here is that any app can be “successful” if given the right marketing push and also the key to getting traction is to have the download free with a single IAP to unlock the game, not only that the call to action (CTA) to actually complete the purchase has to be very much in your face at the correct time, hiding the button away on a settings screen just results in no purchases (I know from experience :))

As for Corona - IMHO it’s the most stable, most feature rich and best supported of all of the platforms and since it went free for all basic uses including building and submitting it was a no brainer.

I was very active on the Gideros boards for a long time (I think I’m still #4 in the total post count), I think Gideros is a fantastic system and is more closely aligned to the philosophy of Codea with it’s class system. The on device testing is brilliant but unfortunately the company behind it had to open source it when they ran out of money (if anything their licencing model was too generous), I did back it on Kickstarter for desktop builds and HTML5 output but I think the heart has gone out of it whereas Corona is still going from strength to strength. I looked at Moai but it didn’t seem as easy to get into as the others.

At the end of the day I evaluated all of the major platforms and made my decision based on my own situation and needs and weighed up all the pro’s and con’s and settled on a combo of Codea & Corona