Page 1 of 1

Reading files on iOS

Posted: Tue Oct 21, 2014 11:18 am
by garyth123
I haven't done much LC for a while and need a reminder on how to access files, required by my app, on a mobile (iOS).

My code is:

Code: Select all

   if the environment is "development" then 
      open file specialFolderPath("Desktop") & tSectionName for read
      read from file specialFolderPath("Desktop") & tSectionName until EOF
   else if the environment is "mobile" then
      open file specialFolderPath("engine") & tSectionName for read
      read from file specialFolderPath("engine") & tSectionName until EOF
   end if
tSectionName is a file path built up outside of the if statement.

I have tried Add Folder... and Add File... but my files are not being read.

Incidentally I cannot get Copy Referenced Files unchecked.

I did have this working a few months ago when I last was working on this project but can't understand what is now preventing it from working. This may be due to some change that I've introduced in the last day or two, but I would be very grateful if someone could remind me of what I should be doing to get my files read.

Re: Reading files on iOS

Posted: Tue Oct 21, 2014 11:51 am
by Klaus
Hi Garyth,

I may repeat myself, but ALWAYS USE BRACKETS when concatenating object and filenames!
...
open file (specialFolderPath("Desktop") & tSectionName) for read
...

Or put the the new name into a variable first, which requires less typing in the end, so this is my favourite:
...
put specialFolderPath("Desktop") & tSectionName into tFilename
open file tFilename for read
...

Please spread the word :D


Best

Klaus

Re: Reading files on iOS

Posted: Tue Oct 21, 2014 12:54 pm
by garyth123
Thanks Klaus. But why then does what I have got work for "development"?

The first of your suggestions (commented out lines below) "compiles" without any errors but the files are still not read on my iPad.

However the second of your suggestions (uncommented lines below) gives the following error:

group "section": compilation error at line 38 (Commands: missing ',') near "into", char 46

Code: Select all

  else if the environment is "mobile" then
      put file specialFolderPath("engine") & tSectionName into tSection --this is line 38
      //open  file (specialFolderPath("engine") & tSectionName) for read
      open file tSection for read
      //read from file (specialFolderPath("engine") & tSectionName) until EOF
      read from file tSection until EOF
   end if
I take it that I am correct in putting specialFolderPath("engine") and that my Destination Folder is correct (see attached image).

Re: Reading files on iOS

Posted: Tue Oct 21, 2014 1:11 pm
by Klaus
Hi Garyth,
garyth123 wrote:Thanks Klaus. But why then does what I have got work for "development"?
because you are lucky!
See below, should not work at all :D
garyth123 wrote:However the second of your suggestions (uncommented lines below) gives the following error:
group "section": compilation error at line 38 (Commands: missing ',') near "into", char 46

Code: Select all

  else if the environment is "mobile" then
      put file specialFolderPath("engine") & tSectionName into tSection --this is line 38
 ...[/quote]
Sorry, my and your fault :D 
You have a FILE to much in the line, I forgot the important SLASH  :oops: ! 
...
put specialFolderPath("engine") & "/" & tSectionName into tSection
...
[quote="garyth123"]I take it that I am correct in putting specialFolderPath("engine") and that my Destination Folder is correct (see attached image).[/quote]
Yes, everything you add here will be found in -> specialfolderpath("engine")

Are you using the latest version 6.6.4?
i think there was a bug with copying files into the standalone on iOS.


Best

Klaus

Re: Reading files on iOS

Posted: Tue Oct 21, 2014 2:16 pm
by garyth123
Okay, apologies for missing those errors.

I was using 6.6.3 but have downloaded and installed 6.6.4. This requires Xcode 6 and iOS 8 SDK. Each time I attempt to build my app LC says I need iOS 8 SDK. How do I let LC know that I have this in Xcode 6?

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 10:29 am
by garyth123
Can I just ask about how to work with LC 6.6.4 and Xcode.

With LC 6.6.3 and Xcode 5.1 I get a green square for the Available Device SDKs: 5.0, 7.0, 7.1

With LC 6.6.4 I get a red square and if try to point it to the Xcode 6 app bundle it gives an error message "The chosen folder is not a valid iOs SDK".

So if I need LC 6.6.4 to be able to copy my files, and need iOS8.1 to work with LC 6.6.4, but am not able to point to the SDK how am I supposed to develop an iOS app?

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 11:51 am
by Klaus
Hi Garyth,

looks like LC 6.6.5 just came out, please try again with this version:
http://downloads.livecode.com/livecode/


Best

Klaus

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 11:58 am
by garyth123
Ok, thanks for alerting me to the latest stable version of LC.

I get a green square and SDKs 5.0, 7.0, 7.1, 8.1 are available but still getting the error message as per the attached.

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 12:00 pm
by Klaus
Sorry, no idea... :(

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 12:10 pm
by LCNeil
Hi Garyth,

This error means that LiveCode cannot find Xcode 6.1 as this is required for device builds when using 6.6.5.

What I would recommend doing is removing all versions of Xcode from your mobile preferences and only linking Xcode 6.1. This will narrow down any Xcode related issue and will allow you to build and iOS standalone.

Kind Regards,

Neil Roger
--
LiveCode Support Team ~ http://www.runrev.com
--

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 12:13 pm
by garyth123
Thank you Neil that has worked.

Re: Reading files on iOS

Posted: Wed Oct 22, 2014 12:21 pm
by garyth123
Thanks everybody, my app is working once again.