Page 1 of 2

[Resolved] File sharing under iOS

Posted: Wed Sep 14, 2016 6:50 am
by VertPingouin
Hello everyone,

I wonder if it is possible to use file sharing of itunes to feed my game with xmls (containing custom levels datas).
Currently, file sharing is activated by default in iOS source but I've no idea where I'm putting shared file.

As I can understand here
https://developer.apple.com/library/con ... -CH10-SW30

There is a fixed document folder somewhere but I don't know if love2d can access a folder outside of the .love directory or if there is a way to alter the folder used.

Anyone has any knowledge on this, it would be awesome to be able to do that !

Re: File sharing under iOS

Posted: Sun Sep 18, 2016 7:09 am
by VertPingouin
Anyone ?

Here is where I am now :
File sharing is used to transfer love projects to be able to select them within the app, but the code chunk is never called when my love project is integrated. This is not what I'm looking for, but that's a start.
I'm now sure that I can't access it within my lua code.
I think I should modify something in the xcode project to copy files in document folder to my love folder at some point, but I havn't a clue where to do it. I know vaguely how but not where (or when). Could someone at least tell me where I can get this information ? As far as I can see, i doubt it is simple but I don't want to learn th whole ios app thing just to be able to use file sharing. There must be someone that can help me on this. I just don't know if i'm at the right place to ask.

Re: File sharing under iOS

Posted: Sun Sep 18, 2016 2:04 pm
by s-ol
the filesharing permissions are already added, all you need to do is move the data to /Documents. Probably by changing the love save directory entirely tot here, which would need adjustments either here here or here

Re: File sharing under iOS

Posted: Sun Sep 18, 2016 11:57 pm
by slime
Un-fused LÖVE looks in the Documents directory for .love files, and for folders containing main.lua. You can transfer .love files or folders there via iTunes:
Image

Re: File sharing under iOS

Posted: Tue Sep 20, 2016 5:42 am
by VertPingouin
I run straight into fusing my game ! It works well unfused of course. But this is not what I'm looking for, thank you though slime, you made my life simpler for now.

@s-ol : when I look at the Filesystem object in debug mode, the appdata string is an empty string. But I've got the game_source full path. That's a beginning. For the ios.mm file, it is never accessed when game is fused but I can get the document folder from here when running it unfused. I saw that I only can access document folder path via builtin functionNSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); in objective C source files, it is done in IOS.mm but this file is never used when running fused game...

So I need to do it elsewhere...
I keep looking but I definitely lack some knowledge... I'm afraid I won't escape this without learning a few things about ios apps...

Re: File sharing under iOS

Posted: Wed Sep 21, 2016 7:30 pm
by VertPingouin
Ok, I misplaced my debug breakpoint. Ok, I've got the appdata folder now.
I'm not sure to understand what I should make of it. What is this appdata folder ?
I also have the game source folder where I could copy my xmls... But I still don't see what to do without the document folder.

Re: File sharing under iOS

Posted: Fri Sep 23, 2016 12:03 pm
by VertPingouin
Anyone ?

Re: File sharing under iOS

Posted: Fri Sep 23, 2016 1:37 pm
by s-ol
VertPingouin wrote:Anyone ?
Change the love source code so the appdata points somewhere else so the data ends up in /Documents so you can see it in iTunes.

Re: File sharing under iOS

Posted: Fri Sep 23, 2016 5:08 pm
by VertPingouin
I understand that. After doing that, my appdata folder is my documents folder. So when I add files from itunes, I can access it by accessing the filesystems appdata string. Ok I get that. I still don't know how to get documents folder on the fly but let's put that aside. Anyway it's something like

/var/mobile/Containers/Data/Application/<some hexadecimal string which I think identifies my app>/Documents/

Ok I just "bruteforcely" set my app data to match my document folder

appdata = "/var/mobile/Containers/Data/Application/037A8D0D-4D5A-4063-8C1A-890B10FEE199/Documents/";

I put some files in it, but what now ? Should I copy them ? And if so I've another issue, I can't use NSFileManager in Filesystem.cpp. Should I include something to do so ?

I'm sorry to ask so specific things and actually be begging for an easy way. You could as well have told me to rtfm but I spent so much time with my game that I am lacking some now ^^

Re: File sharing under iOS

Posted: Fri Sep 23, 2016 7:31 pm
by s-ol
VertPingouin wrote:I understand that. After doing that, my appdata folder is my documents folder. So when I add files from itunes, I can access it by accessing the filesystems appdata string. Ok I get that. I still don't know how to get documents folder on the fly
what?
but let's put that aside. Anyway it's something like

/var/mobile/Containers/Data/Application/<some hexadecimal string which I think identifies my app>/Documents/

Ok I just "bruteforcely" set my app data to match my document folder

appdata = "/var/mobile/Containers/Data/Application/037A8D0D-4D5A-4063-8C1A-890B10FEE199/Documents/";
no, you shouldn't (need to) hardcode the ID et cetera.
I put some files in it, but what now ? Should I copy them ?
what? copy which files? copy them from where to where?
And if so I've another issue, I can't use NSFileManager in Filesystem.cpp. Should I include something to do so ?

I'm sorry to ask so specific things and actually be begging for an easy way. You could as well have told me to rtfm but I spent so much time with my game that I am lacking some now ^^
If you change the path in the 'common' file there will probably not be the need to.

If you can read and write data to the Documents directory, then everything is accomplished, no? What's the problem / what are you triyng to do now?