I have an app I’m writing that has a set of embedded lua scripts in them. I’d like to be able to edit the scripts on the iPad – is this possible?
The workflow I was thinking of was:
- start my app and test;
- go to my text editor on the iPad and make changes to the lua script;
- close my app;
- restart my app to reload the script;
- goto 1.
EDIT: I can add the “Open In” option to my app and open the text file as per this question, however, once I do that does the text editor then save the file back to where it came from? or does it just use a copy? This assumes I can find a text editor that will open lua files, I imagine there’s one around somewhere.
As @danielbeard correctly stated this will not work as straightforwardly as expected on a desktop (or more permissive mobile) OS due to iOS sandboxing model, which effectively constrains application data to the application itself, although it is worth noting the issue at hand is not the sandboxing per se, which also exists in newer versions of OS X, but the fact iOS offers no unifying file system layer which is mirrored into applications’ sandboxes. You can plainly and pretty simply see that for yourself by editing a text document on your desktop in Lion’s TextEdit. TextEdit sees the document being located in its sandbox –
~/Library/Containers/com.apple.TextEdit/Data/Desktop, but it is also clearly saved onto your desktop~/Desktop– at the same time; both directories are, for the purpose of the sandbox, one.the cross-application file layer does not exist in iOS. This means that in iOS, it is not possible to edit one and the same physical copy of a file in multiple applications, as every app needs a copy in its own sandbox. It is however possible to “pass” files from app sandbox to app sandbox (strictly speaking: to copy them) via the “Open In” mechanism supported since iOS 3.2, as seen when opening Mail attachments in other apps.
If your app implements the ability to forward its
.luadocuments via this mechanism, any text editor recognizing the file type can receive a copy into its own sandbox. I’m hazy as to implementation details, not being an iOS dev myself, but if the rules of UTI declaration from OS X and some stuff I have observed while using my iDevices holds true, you can even insert the file type into thepublic.textUTI hierarchy in your own app, which will add support for it to all text editors on the device.If the receiving editor implements “Open in” too, and your app has registered as being able to edit
.luafiles, the editor can later copy the edited file back to your app’s sandbox. What happens there (de-duplication, versioning, overwriting with or without prompting) would be up to you, within the constraints imposed by the iOS SDK, which I know nothing about.The following Apple Developer documents may provide a useful starting point: