Trouble reading a file in Resources folder...

I have done this in past projects without a problem. I have looked at related threads here. I don’t know why the following code isn’t working:

set theTracksPath to the main bundle's resource path & "/TracksData.txt"
set theFileRef to open for access theTracksPath
set theContents to read theFileRef
close access theFileRef

I keep getting a “End of File Error (-39)” error when attempting the read line above. The file was added to the project using Xcode’s Project → Add Files menu. Xcode moved the file as well. The file is a simple text file consisting of 39 lines. It was orignally creating using Smile and edited/cleaned-up in TextEdit and saved as a plain text file. I can open the file in Xcode and everything looks fine.

I posted here, because (aside from the “main bundle’s resource path”) the code works. I wrote the remainder of the routine in Smile before using it in Xcode. I know it’s probably something simple, but I can’t find it. Will somebody tell me what I’m overlooking?

Thanks in advance,
Brad Bumgarner, CTA

First, as always, you don’t need to open a file to read it. Next, try using the file path coerced to a file reference:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

THAT I did not know. :shock: I learn something new everyday. Thanks Jon.

Brad Bumgarner, CTA