Updating sqlite3 API - objective-c

I want to update/upgrade the standard Leopard install of Sqlite3 to >3.5 to use the new sqlite_xxx_v2 methods from a Cocoa project.
I can't seem to find any information on how to do this. Does anyone have any tips or a site that outlines the update procedure.
Also is 3.5+ supported on the iPhone. I understand it's embedded so shouldn't be an issue...

What you want to do is grab the amalgamation sources from http://sqlite.org/download.html . Then just compile that into / add it to your project. You don't want to replace the system sqlite- that'll have unintended consequences in other applications. Plus, I'm pretty sure the system sqlite isn't a stock sqlite... Apple has probably made their own modifications to it that core data relies on.
You can read up on the amalgamation stuff here: http://sqlite.org/amalgamation.html , but in short: '''The amalgamation is a single C code file, named "sqlite3.c", that contains all C code for the core SQLite library and the FTS3 and RTREE extensions'''
I'd also suggest not using the sqlite calls directly, they weren't designed to be used that way (says the author of sqlite). Instead, there are a number of cocoa wrappers out there, including fmdb: http://code.google.com/p/flycode/source/browse/trunk/fmdb/ (which I wrote) :)
-gus

You don't really want to upgrade the system version of SQLite on Mac OS X. The reason is that all Mac OS X software is qualified against the versions of the packages that it includes, as built by Apple's build process. Installing a different version of a package, or even building the same version yourself but doing so slightly differently than Apple does, may result in a system that behaves unexpectedly.
Finally, if you embed a newer version of SQLite — or any Open Source library or framework included with Mac OS X — into your own application, you should be sure to integrate the Darwin changes for it from Apple's public source site. That way you can be sure you'll get as close to the same behavior as possible from the library you've built yourself as the version Apple ships, which is especially important when it comes to functionality like file locking in databases.

I don't believe i've updated my version, but it's currently at 3.4.2, and i'm able to use the new methods with the current version.
And i'm running 10.5.5 with the latest (public) iPhone SDK.

It would likely be easier to just drop the library into your project and link it in from there.

Related

Adding an SQL extension to a precompiled Lua 5.2 project

I have looked into at least 6 different SQL Lua extensions, and they all seem to have their latest version compatible with up to version 5.1 of Lua. I have had zero success in implementing any of them into my current project which uses Lua 5.2, with the best case scenario ending in either silent program crashes or attempt to call global 'module' (a nil value).
I am not the original project owner, so I am trying not to be forced into changing the source code for it (though more recently, I have even gone down that road now).
And often times, it is unclear if these crashes are related to the way the project itself operates, the way the project implements Lua (as a static library), the way that Lua tries to implement it's extensions, the way the extensions implement their dependencies, a versioning conflict, or some sort of crazy combination of each. It's practically impossible to debug a silent crash in this manner, because the source of evil could literally be anything.
As the answer states in this question, I have even tried supporting the module function (which most lua sql extensions utilize, but was deprecated in 5.2), but the program still crashes or just complains about a seemingly infinite amount of missing dependencies. And after spending hours of tracking down (what would seem to be) all of the dependencies it would complain about, it still crashes.
Changing the project's source code to use the Lua 5.1 source appears to break the functionality of the project, resulting in various compiler errors regarding missing 5.2-related functions. Linking the MySQL C/C++ connector to the project results in rather vague runtime errors, which seem to conflict with the way the project implements Lua 5.2.
Are there ANY sqlite/MySQL extensions out there which actually work with Lua 5.2 on a 32-bit Windows machine? Preferably, "out-of-the-box" precompiled binaries with Lua source/ffi bindings?
OR alternatively, are there any clear instructions on how to get this set up properly, without having to scavenge through separate instructions across the web for each required assembly?

Vala or GTKmm for a new database-centric project?

I have been asked to develop a new, small, custom-specific CRM (Customer Relationship Manager) that will be used mainly on Linux desktops (compatibility with Windows and Mac OS X would be appreciated but it is not required).
This seems to be a good opportunity to try the new Vala language and some of its libraries (most notably libgda and the rest of Gnome-DB) but, of course, I still have to deliver a working product to the customer in time so... I'm still scratching my head and wondering.
To develop this application I would need:
A "glue" language (Vala itself). This is OK.
A GUI Library (GKT+ 2.X or 3.X). This is OK.
A database abstraction layer (libgda). Here I have some doubt.
Maybe a MVC framework like Bakery (Bakery 2.6 seems to be working
with GTKmm 2.4 only. It does not work with the GObject-enabled GTKmm
3, as long as I can see.).
Maybe a ORM like Hiberlite (libgda supplies data-aware widgets
and other tools but it is not a full-blown ORM, as long as I know).
At the moment, I'm confident about the first two items, only. Even the real amount of Vala support for libgda is not very clear to me (The ValaDoc describes as supported the interface of a old version of LibGDA while the Gnome-DB website says that the new 4.2 and 5.X versions of the library are GObject- and Vala- enabled). Most likely, Bakery and Hiberlite would not be available any time soon for Vala.
The nearest alternative seems to be:
C++
GTKmm (2.X)
Maybe Bakery 2.6
libgda
Maybe Hiberlite
A more mature stack but... maybe so mature to be fated.
Hence: would you try Vala for a new database-centric project like this?
Or would you wait for a more mature and more rich Vala ecosystem?
Thanks
Vala just means native compilation without requiring a framework (and versions) to bother about. Connecting to database still looks premature and definitely undocumeted (that's how I came to this post). Besides, there is no IDE. Glade is not really and IDE, but an interface designer.
Try out Lazarus and you will be in for a surprise, how conveniently database front ends can be developed. Pretty mature, native compilation, ready to use third party components, database support right through the IDE, options of using Gtk or Qt.
And it gives native exe's on Windows, Linux and Mac. Nothing comes even remotely close if you are developing cross-platform database front ends. Development time would be a fraction and performance comparable to C, if not equal.

porting from ios to windows

I'm about to write code for Windows that has somewhat similar functionality to the one existing in already written application for iPhone. I'm thinking of separating common functionality to form a component and compile it to both to iPhone and to Windows. This code is written in Objective C and uses RestKit and Core Data (and probably sqlite). Is compiling it for Windows a viable task? As I understand it GCC could compile Objective C on Windows but I'm unsure about the RestKit and Core Data api availability on Windows. I have seen two names that could be of use: GNUStep and Cocotron but I don't know if they will play well together with RestKit.
Note: I have no idea about iOS development so I might be confusing things. Any help is appreciated.
You will not easily be able to share this functionality between your applications. CoreData uses a custom opaque (not documented) format for the sql store. You would be hard pressed to reverse engineer this.
You will probably save a lot of time by rewriting that part for windows, rather than trying to get it working. There really isn't much iOS code that can be reused under windows, unless you have written pure C or C++.

Objective-C source code

Where can I find the source code for the Objective-C language? Is it open-source or is there an open-sourced implementation of it available?
It really depends on what you mean by Objective-C, there are compilers, runtimes and libraries for it.
http://opensource.apple.com/ Contains much of Apple's source code for OS X and iOS.
you can also see http://clang.llvm.org/ for a compiler.
GNUstep is an open source implementation of OpenStep (Cocoa).
I think you are asking for Cocoa - and this is not open source. All you have are the header and reverse engineering tools.
Looking around, I've found several copies of Objective-C's source code. Apple maintains it at http://opensource.apple.com/source/objc4/, which is up to date as of OS X 10.9.x Mavericks at version 551.1, but I have also found several repositories GitHub that are copies of this main repository which people have made at various points in time, so they may or may not be as up to date as Apple's main repository. These include the GitHub repositories "opensource-apple/objc4" at version 532.2; "bavarious/objc4," which is up to date at version 551.1; "macmade/OBJC4-437.1-Runtime," which obviously includes just the Objective-C runtime at version 437.1; "Apple-FOSS-Mirror/objc4" at version 532.2; "aosm," which is up to date at version 551.1; "robertvojta/objc4," which is up to date at version 551.1; "j4n0/objc4-532," which is obviously at version 532.0; and "chenniaoc/objc4-551.1," which is obviously up to date at version 551.1. Personally, it seems to me that robertvojta/objc4 is the best repository from which you could possibly fork code due to the fact that it's got every single release from Apple's Open Source website so far copied over to it.
There is no one source code. There would be as many different versions as there are compilers for the language. They would likely be written in a low-level language such as assembly or C, and be vastly complicated. For whichever compiler you are interested in, you will need to confirm that it is open-source, which I find unlikely. Even then, it may be difficult.

OS X Mac and writing a twain scanning application

Can someone point me to the correct place to start development of a twain scanning appliation for the MAC osx. I have done some simple objective c development in the past, but nothing interfacing with a device.
If you're talking about Objective-C and TWAIN on the Mac, this page on the twain.org site has a DMG you can download which contains a sample project called TWAINClientCocoa.
It's from 2002 or something so it requires a little finagling to get it to load and build (rename the .pbproj folder to be a .xcode folder so it will open in Xcode and then do an "upgrade" when you're in Xcode) but it works (just tried it last week) and should give you a good starting point. It relies on the concept of the TWAIN source providing its on GUI but that's something you could modify.
If someone if still interested in this, I have just written a TWAIN client on macOS for my application. This documentation is quite helpful.
The main problem doing this today is that the PicHandle returned by native transfer mode requires some deprecated functions to operate on. On my system (10.13) I can workaround this by making up the headers for those functions but they might be removed totally some time in the future. It's probably worth trying to use memory transfer mode which is more complex.