clemensg / sqlite3pod

The repository for the sqlite3 podspec used in CocoaPods.
https://www.sqlite.org
MIT License
27 stars 17 forks source link

Compile issue on iOS #1

Closed weibel closed 9 years ago

weibel commented 9 years ago

The FMDB/standalone podspec currently downloads sqlite 3.8.9. On iOS I run into a compile error on line 31999 of sqlite3.c.

sqlite3.c:31999:9: 'gethostuuid' is unavailable: not available on iOS

There are no problems on sqlite 3.8.8.3.

Is this something that should be reported on sqlite.org?

clemensg commented 9 years ago

Hi! Yes, this is a bug in SQLite 3.8.9, more specifically in the proxyGetHostID function in src/os_unix.c. Please report it to the sqlite-dev and/or sqlite-users mailing list.

The problem is the use of gethostuuid which was behind the following ifdef in 3.8.8.3

#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\
               && __MAC_OS_X_VERSION_MIN_REQUIRED<1050

In 3.8.9 they replaced it with

# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
                            (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))

And as it does not exist on iOS 7 and above it fails. Should be either removed (as the use of gethostuuid is not encouraged at all) or limited to iOS 6 and before.

clemensg commented 9 years ago

I reported the bug on sqlite-dev

weibel commented 9 years ago

Thanks for the quick reply. I have not been approved for any of the lists yet.

clemensg commented 9 years ago

@weibel SQLite maintainer Richard Hipp responded and asked if we can work around this bug by compiling with -DSQLITE_ENABLE_LOCKING_STYLE=0.

Looks good to me, it does compile and run in the simulator. Can you confirm that?

I'll also think about a small test suite for iOS and OS X to detect similar bugs before pushing new versions to CocoaPods trunk.

clemensg commented 9 years ago

More info from the maintainer

The SQLITE_ENABLE_LOCKING_STYLE thing is an apple-only extension that
boosts performance when SQLite is used on a network filesystem.  This
is important on MacOS because some users think it is a good idea to
put their home directory on a network filesystem.

I'm guessing this is not really a factor on iOS.

And

We will work on a permanent fix.  But that will take a lot longer.
clemensg commented 9 years ago

As the podspec should now be fixed, use the version from Git until a new version bump occurs and I can push a new version to CocoaPods Trunk. So for now, just add pod 'sqlite3', git: 'git@github.com:clemensg/sqlite3pod.git' to your Podfile.

weibel commented 9 years ago

The workaround works and my project compiles again with 3.8.9. Thanks for taking the time to fix this.

It would be a very unusual situation for an iOS app to have a SQlite DB on a network drive. I think people would use other technologies for this use case.