Maddening FolderItem error

This little snippet works fine in Xojo2018r4 (either through the IDE or a compiled app) on Mac OS X 10.10:

Dim fi as FolderItem Dim t as TextInputStream fi = GetFolderItem("").Child("Definition Files").Child("DATA.CSV") if fi.Exists then t = TextInputStream.Open(fi) //do stuff t.Close end if

However, if deploying on macOS 10.12 (“Sierra”), I trap an error. I then used the Remote Debugger on the target machine (macOS 10.12) and find that the error is at: “if fi.Exists”… it returns a “Nil Object exception” (with “fi” being the nil object).

I have verified that the folder “Definition Files” exists below the app’s location, and the file “DATA.CSV” exists in that folder. In other words, the folder and file structure is identical in both (10.10 and 10.12) machines.

So, why is this simple code crashing?

Thanks in advance.

New security measures added since 10.10 prevent you from being able to rely on any item existing next to the application. In effect, you need to implement your app as if GetFolderItem() doesn’t exist.

On a technical level, what’s happening is your app is being translocated. Just the app is being moved to it’s own sandbox location. The Definition Files is not going with it, and so when you GetFolderItem("").Child("Definition Files") you get a non-existent item. You then get a nil object by trying to use .Child("DATA.CSV") on a folder that doesn’t exist.

You should investigate how to properly package your app for Mac using a CopyFiles step.

Getfolderitem("") will not return the path you are thinking it is on 10.12 and above. Unless the app is code signed macos moves it to a private location. App translocation or something.

Print out the path to see what I mean. Putting files in a fixed location would work.