[Resolved] File sharing under iOS

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

[Resolved] File sharing under iOS

Post 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 !
Last edited by VertPingouin on Sun Sep 25, 2016 7:54 pm, edited 1 time in total.
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post 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.
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: File sharing under iOS

Post 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

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
slime
Solid Snayke
Posts: 3159
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: File sharing under iOS

Post 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
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post 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...
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post 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.
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post by VertPingouin »

Anyone ?
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: File sharing under iOS

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
VertPingouin
Prole
Posts: 9
Joined: Wed Sep 14, 2016 6:41 am

Re: File sharing under iOS

Post 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 ^^
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: File sharing under iOS

Post 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?

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 5 guests