SQLite ICU (unicode support) for Mac updated

See my blog article on using the ICU library with SQLite in Xojo:

http://blog.tempel.org/2015/09/xojosqliteextensions.html

I have now updated the demo project to include a 64 bit build of the dylibs.

Download here:

http://files.tempel.org/RB/SQLite%20Extensions%20Demo.zip

Thank you, Thomas, greatly appreciated.

After adding it to my old SQLiteDatabase project, I had only to modify (in the Install method):
db as REALSQLDatabase into db as SQLiteDatabase.

Thomas,
after downloading Xojo 18v3 and running my app in the debugger:

dim f as FolderItem = dir.Child(lib_name + SystemDylibExtension)
returns nil

Could the cause be that this version of Xojo has got an upgraded SQLlite plugin?

The only modification I made to your package was to rename the folder as “SQLite ICU Extension64bit”
Such folder is seen in
dir = GetFolderItem("").Parent.Child(“SQLite ICU Extension64bit”)

but its content “sqlite3_icu_extension.dylib” is ignored although present in the folder.

Yet, last month, using a Xojo version 2017 (in debug mode), everything was working OK.

Any idea what could be the reason?
Thank you.

Protected Function Install(db as SQLiteDatabase) as Boolean
  // Loads an SQLite extension library file that provides full unicode support
  
  dim dir as FolderItem
  #if DebugBuild
    // load locally - assuming that it's placed next to the project file
    dir = GetFolderItem("").Parent.Child("SQLite ICU Extension64bit")
  #else
    // load from app's Frameworks folder, where it should be copied into when building a standalone app
    dir = App.ExecutableFile.Parent.Parent.Child("Frameworks")
  #endif
  const lib_name = "sqlite3_icu_extension"
  dim f as FolderItem = dir.Child(lib_name + SystemDylibExtension)
  dim cmd as String = "SELECT load_extension ("""+NativePath(f)+""", ""sqlite3_icu_init"")"
  db.SQLExecute(cmd)
  if db.Error then
    MsgBox "Can not load ICU lib: " + db.ErrorMessage
    return false
  end
  
  return true
End Function

What do you mean with “is ignored”? Everything works fine for me with the ICU extension in 2018r3. But I commented out the #if DebugBuild and use an IDEScript to copy the extension into the Frameworks folder.

Sorry for my wording. By “is ignored” I wanted to express the idea that the “sqlite3_icu_extension.dylib” item is physically present in the folder, yet is not “seen” during execution time.

Anyway, the issue is that in debug mode f returns NIL:
dim f as FolderItem = dir.Child(lib_name + SystemDylibExtension)

I just tested my project again with 2017r3, and it shows the same issue (contrary to what I said in my previous post). Probably, testing the ICU extension last month, I had just launched the app without actually loading any db file.

MBP running 10.12.6.

Unfortunately I’m confined to debug mode only, since I do not have (yet) a license for 2017r3 or 2018r3 to build the app.

Needless to say that 32bit project with “old” ICU extensions works OK in 2016r1.1 (both debugging the app and after building it).

Thank you.

If it helps: after building my app with 2016r1.1 (64bit) and loading a db file, a message pops up saying that the extension could not be loaded because
“myapp.app/Contents/Frameworks/sqlite3_icu_extension.dylib.dylib, 10): image not found”

Please check if the path and the name of the extension are correct:

#if Target32Bit then const lib_name = "sqlite3_icu_extension" #Elseif Target64Bit then const lib_name = "sqlite3_icu_extension_64" #Endif

Or whatever the name of your 64bit ICU extension is. I still think that your code doesn’t find the extension.

Hardcoding the culprit line, that is, instead of
const lib_name = “sqlite3_icu_extension”
dim f as FolderItem = dir.Child(lib_name + SystemDylibExtension)

if I enter:
dim f as FolderItem = GetFolderItem("").Parent.Child(“SQLite ICU Extension64bit”).Child(lib_name + SystemDylibExtension)
or
dim f as FolderItem = GetFolderItem("").Parent.Child(“SQLite ICU Extension64bit”).Child(“sqlite3_icu_extension.dylib”)

then, loading a db file, I get the warning that the extension could not be loaded because
“…/sqlite3_icu_extension.dylib.dylib, 10): image not found”

I’ll have to dig into it, because Thomas’s “SqliteDemo” does work OK.
Meantime, thank you for your suggestion.

OK. Issue solved.

#if DebugBuild // load locally - assuming that it's placed next to the project file dir = GetFolderItem("").Parent.Child("SQLite ICU Extension") #else

The folder was indeed placed next to the project file. Tha’s why it could not be found.
In fact, I think, dir = GetFolderItem("").Parent.Child(“SQLite ICU Extension64bit”) supposes that the folder be next not to the project file, but to the folder containing the project file. So moving the folder outside the folder containing the project file solved the issue.
Then, I moved it back next to the project file and modified the code:

#if DebugBuild // load locally - assuming that it's placed next to the project file dir = GetFolderItem("SQLite ICU Extension") #else

Thanks to Thomas for the valuable package, and to Beatrix for her suggestions.