Create new folders in IOS apps?

I’m trying to resolve an IOS app store submission that keeps getting rejected.

Thanks to Jason King’s Crash Symbolocator application I know it is happening in the open event of the app and there is only one thing that happens there. An Sqlite database is being copied from the resources folder in the app to an external folder so it can be read. I think it’s one of the following two things.

  1. I accidentally left some debug code that sent some messages to the debug log. Perhaps there is no debug log and this generates the error. Seems to work fine when I copy the app to my iphone/ipad.

  2. Before the Sqlite database is copied from the resources folder, a new folder is created in the Documents folder. Are you permitted to do this on an IOS device in the documents folder?

Any comments regarding whether this could be the problem?

I can tell you that #1 is not the problem and I doubt that #2 is the problem. Have you checked that your SQLite database is actually being copied where you think it is being copied? You can check this in the iOS Simulator by looking at the folders that represent your app’s location while you’re running your app and you can actually watch folders and files being created and moved around. My app makes a couple of folders (but in Library\Caches, not within Documents) and moves files into and out of Documents and I found it was very useful being able to check this in the Simulator.

Another useful thing is to reset your iOS Simulator (or change to a device that you haven’t used before) in order to simulate a new installation of your app on a new device. It could be that you have files in the right place from a previous installation but that are not being copied to the right place in your current version.

I’m not clear, but are you getting rejected because of a crash you cannot replicate on your devices?

As Jason noted, perhaps you are copying the DB, but still accessing the original file, which would be a no-no as it is read-only when it is in the app bundle. Of course if this were the case, I’d expect you to easily see the crash on your own devices.

Yes, according to Jason’s Symbolocator program, the error is happening in the open event of the app and the only code in it is to copy the Sqlite DB from the resources folder to a folder created in the documents folder. Runs perfectly in the simulator and on my iphone/ipad and a few other people’s in the office.

This app is so simple and is only a reference app. here is the all the code in the app event.

[code]
'-----------------------------------------------------------------------------------------------------
'— COPY DB FROM RESOURCES TO DOCS FOLDER
'-----------------------------------------------------------------------------------------------------

dim ForceCopyDB As Boolean = True

dim f_doc As FolderItem
f_doc = SpecialFolder.Documents.Child(kAppDBPrefix+"_DATA")

if DebugBuild then
System.DebugLog(f_doc.Path)
end

if not f_doc.Exists then
f_doc.CreateAsFolder
end

dim f_DB As FolderItem

f_DB = f_doc.Child(kAppDBPrefix + kAppDBExt)

if not f_DB.Exists or ForceCopyDB then

'---  DB IS LOCATED IN RESOURCES FOLDER
dim f As FolderItem
f = Xojo.io.SpecialFolder.GetResource("ACAIR.dat")

if f <> nil then
  
  if f_DB.Exists then
    f_DB.Delete
  end
  
  '---  COPY TO DOCS FOLDER
  f.CopyTo(f_DB)
end

end

if f_DB.Exists then

dim db As New SQLiteDatabase
db.DatabaseFile = f_DB
if  db.Connect() then
  
  rs = db.SQLSelect("Select * from ACA")
  
  if rs = nil or rs.EOF then
    
    if DebugBuild then
      System.DebugLog("Oops, can't create recordset")
    end
    
  end
  
else
  
  if DebugBuild then
    System.DebugLog("Oops, can't connect to database."+EOL()+f_DB.Path)
  end
  
end

end[/code]

See anything strange?

Jason

I don’t think that could be the problem, because this app has been tested on at least 6 different devices and it HAS to execute the code in the open event of the app or the rest of it would not work. Why? Because I’m reading the DB that contains the text that is displayed on every remaining screen of the app. If it was not working, the app would show nothing.

What does the report from the App Store review process say?

if not f_DB.Exists or ForceCopyDB then

ForceCopyDB will always be true, perhaps your overwriting the DB file ?
Not sure but it could be that it’s not allowed.

Maybe the issue is with Documents. You may want to copy to ApplicationData instead.

ApplicationData folder doesn’t seem to be working for me.

Darn, I forgot that it does not work in there.

For iOS you only have DOCUMENTS (read/write) and RESOURCES (read only)

So Dave, are you saying that I don’t have to copy the database from the resources folder if I’m not going to write to it???

This is a reference application so the information in the database is for display only. The database never gets written to. In fact, I’m transferring the data to a recordset in the open event and never touching the database again.

[quote=202347:@John Fatte]So Dave, are you saying that I don’t have to copy the database from the resources folder if I’m not going to write to it???

This is a reference application so the information in the database is for display only. The database never gets written to. In fact, I’m transferring the data to a recordset in the open event and never touching the database again.[/quote]

If you only read, you don’t have to copy the database.

If you want to write any time, then yes like dave said you have to have it in the documents folder when your writing to the DB

Not sure that is a true statement… Since you cannot open the database in “READ ONLY” mode, Apple may reject you app, as they have no way of knowing your “intent”

I think I agree with Dave. You could have one option hidden away that tries to write the database that would crash the app so they probably won’t let you read from a database in the resources folder.

Why not store the data as a TEXT File, and read it into a dictionary. THAT you can do using on the RESOURCE directory.

Actually, alongside Documents you also have a Library folder and a tmp folder. All three folders, and any sub-folders, are read/write within the app’s sandbox.

@John Fatte it might be helpful to know the rejection message that you are receiving from the App Store review process in iTunes Connect?

Here is the details of the rejection notice I received… not very helpful, but it does point to a problem with the open event code.

“We were unable to review your app, as it crashed on launch. We have attached detailed crash logs to help troubleshoot this issue.”

Dave - I have a number of alternative, but this was the first IOS app I did and I figured I might as well get some experience with using an SQLITE db.

[quote=202528:@John Fatte]Here is the details of the rejection notice I received… not very helpful, but it does point to a problem with the open event code.

“We were unable to review your app, as it crashed on launch. We have attached detailed crash logs to help troubleshoot this issue.”[/quote]

They mention details attached. Could you post the crash logs they attached on DropBox or something ? They may tell the whole story to people who know how to read them.