IOException…

Hi there!

How are you guys today?

Until yesterday… all my game was working like a charm.

on this line of code:

textInput = TextInputStream.Open(source)

i’mg getting an IOException when sandoxing is on…

why?

You can examine the IOException in the IDE to get its “message” and so forth (which is not always super-helpful, but it’s always the first thing to check.)

It’s probably because the file is already open by your app or another app, or because source doesn’t exist (check its properties in the IDE).

1 Like

Maybe because"source" is out of scope of the sandboxed app.

Where is “source” (in the sandbox or outside) and how is it retrieved (User-dialog?)?

1 Like

source is a file inside the compiled app. on contents/resources/levels/1.txt

As Julia wrote, the very first thing is to check the reason of the exception; otherwise, how would you possibly have a clue about what went wrong?

So you should surround your problematic call in a Try block (for methods such as “TextInputThread.Open”, you should always do it anyway, even if you don’t actually get exceptions when you make tests, otherwise your app would terminate as soon as something you didn’t expect happens) and get the error message and number.

Something like that:

Try
textInput = TextInputStream.Open(source)
Var Data As String=textInput.ReadAll
textInput.close
Catch e as RuntimeException
MessageBox e.ErrorNumber.ToString+endofline+e.Message
end try

(note this code is API2)

Then you may report your finding here so we can tell you how to interpret it.

this occurs only when i activate “sandboxing”, and run the app.

source<>nil and source.exists
the problem is opening the source.

where can i learn about the scope of sandboxed app?

Do you get more information when you click the IOException and the FolderItem here?

on exception no, nothing!

on folder item… yes, it’s there

This is one starting point:

A text file in the resource folder of an app is outside the scope of the sandbox, put it in specialfoder.applicationdata oder specialfolder.documents - both will be inside the sandbox…

I’m pretty sure IOException 1 on macOS is a refusal to allow you to open a file outside of the Sandbox. To gain access you need to have the user open the file using an OpenFile or SaveFile dialog box. For internal files (part of the application) follow Thomas’s suggestions.

1 Like

ok. i read the document.

but…

how do i copy the leves of my game to this folder, during building process?…

there is no such option to do that…

remember, this is my first app i’ll send to appStore.

Maybe this will help:

1 Like

But if you look down a little further it says isReadable is False. I don’t know if that’s due to sandboxing, or if FolderItem is giving bad info.

1 Like

it’s because sandboxing.

i’m considering @AlbertoD’s suggestion about sqlLite.

Just noting that while those instructions talk about SQLite the concept is the same for normal text files as well

1 Like

I didn’t mention the blog post to change from your files to sqlite.
I mention the blog post because is mentioning how to handle files (in that case sqlite but can be applied to your files), put them in the Resources directory of your app and every time your app runs, check if you already copied them to the ApplicationSupport directory.

I have read that is what you normally do when dealing with the requirements of Sandbox.

I was already wanting to change the text files to database. Later I will store other game information.

After the example, I got excited and decided to change it. It was just the data source.

It was “vapt-vupt”!

“vapt-vupt” means really fast, and really easy.