Skip to content

Commit 52df763

Browse files
Merge pull request #1 from swiftlyfalling/initial-release
Initial release
2 parents ec32f7c + 7dfa48c commit 52df763

File tree

1,499 files changed

+766464
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,499 files changed

+766464
-2
lines changed

.gitignore

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
### C ###
2+
# Object files
3+
*.o
4+
*.ko
5+
*.obj
6+
*.elf
7+
8+
# Precompiled Headers
9+
*.gch
10+
*.pch
11+
12+
# Libraries
13+
*.lib
14+
*.a
15+
*.la
16+
*.lo
17+
18+
# Shared objects (inc. Windows DLLs)
19+
*.dll
20+
*.so
21+
*.so.*
22+
*.dylib
23+
24+
# Debug files
25+
*.dSYM/
26+
*.su
27+
28+
29+
### OSX ###
30+
*.DS_Store
31+
.AppleDouble
32+
.LSOverride
33+
34+
35+
# Thumbnails
36+
._*
37+
38+
# Files that might appear in the root of a volume
39+
.DocumentRevisions-V100
40+
.fseventsd
41+
.Spotlight-V100
42+
.TemporaryItems
43+
.Trashes
44+
.VolumeIcon.icns
45+
.com.apple.timemachine.donotpresent
46+
47+
# Directories potentially created on remote AFP share
48+
.AppleDB
49+
.AppleDesktop
50+
Network Trash Folder
51+
Temporary Items
52+
.apdisk
53+
54+
## Obj-C/Swift specific
55+
*.hmap
56+
*.ipa
57+
*.dSYM.zip
58+
*.dSYM
59+
60+
## Playgrounds
61+
timeline.xctimeline
62+
playground.xcworkspace
63+
64+
# Swift Package Manager
65+
#
66+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
67+
# Packages/
68+
.build/
69+
70+
# CocoaPods
71+
#
72+
# We recommend against adding the Pods directory to your .gitignore. However
73+
# you should judge for yourself, the pros and cons are mentioned at:
74+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
75+
#
76+
# Pods/
77+
78+
# Carthage
79+
#
80+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
81+
# Carthage/Checkouts
82+
83+
Carthage/Build
84+
85+
# fastlane
86+
#
87+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
88+
# screenshots whenever they are needed.
89+
# For more information about the recommended setup visit:
90+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
91+
92+
fastlane/report.xml
93+
fastlane/Preview.html
94+
fastlane/screenshots
95+
fastlane/test_output
96+
97+
98+
### Xcode ###
99+
# Xcode
100+
#
101+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
102+
103+
## Build generated
104+
build/
105+
DerivedData/
106+
107+
## Various settings
108+
*.pbxuser
109+
!default.pbxuser
110+
*.mode1v3
111+
!default.mode1v3
112+
*.mode2v3
113+
!default.mode2v3
114+
*.perspectivev3
115+
!default.perspectivev3
116+
xcuserdata/
117+
118+
## Other
119+
*.moved-aside
120+
*.xccheckout
121+
*.xcscmblueprint

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 swiftlyfalling
3+
Copyright (c) 2016 swiftlyfalling (https://github.com/swiftlyfalling)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

100644100755
Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,153 @@
1-
# SQLiteLib
1+
SQLiteLib
2+
==========
3+
24
Easily build a custom SQLite static library for use in OSX and iOS frameworks and apps.
5+
6+
If you need a specific version of SQLite, or specific SQLite compilation options/features, read on.
7+
8+
9+
---
10+
11+
**May 29, 2016: SQLiteLib updated for SQLite 3.13.0** ([changelog](CHANGELOG.md)).
12+
13+
**Requirements**: iOS 8.0+ / OSX 10.9+, Xcode 7.3+
14+
15+
**SQLite Included:** 3.13.0
16+
17+
18+
### Installation
19+
20+
#### Manual Installation (ex. into a Framework)
21+
22+
1. Download a copy of SQLiteLib.
23+
2. Embed the `SQLiteLib.xcodeproj` project in your own project.
24+
3. Add the SQLiteLib.`sqlitecustom` target in the **Target Dependencies** section of the **Build Phases** tab of your application target.
25+
4. Add `libsqlitecustom.a` to the **Linked Frameworks and Libraries** section of the **General** tab of your target.
26+
27+
That's it! (You'll probably also want to `#include "sqlite3.h"` somewhere. SQLiteLib copies this generated file to its project directory.)
28+
29+
#### Using in Swift
30+
31+
You probably shouldn't be using the raw SQLite C API in Swift. There are a bunch of great libraries available that wrap it.
32+
33+
For example: ([GRDB.swift](https://github.com/groue/GRDB.swift)).
34+
35+
36+
### Customization
37+
38+
By default, SQLiteLib builds SQLite with options that match the built-in system version of SQLite on OSX and iOS (as of OSX 10.11.5, iOS 9.3.2), [with one exception*](#additional-details).
39+
40+
#### Specifying Additional SQLite Compilation Options
41+
42+
> By default, SQLiteLib compiles SQLite with options that match the built-in OSX/iOS version of SQLite (as of OSX 10.11, iOS 9.3.2), with one exception*.
43+
> You only need to follow the steps below if you wish to customize the options.
44+
45+
To specify additional options:
46+
47+
1. Open `SQLiteLib-Custom.xcconfig`
48+
2. Modify `CUSTOM_SQLLIBRARY_CFLAGS` to specify the additional options.
49+
50+
For example, to specify SQLITE\_ENABLE\_PREUPDATE\_HOOK, you would modify it like this:
51+
```ini
52+
CUSTOM\_SQLLIBRARY\_CFLAGS = -DSQLITE\_ENABLE\_PREUPDATE\_HOOK
53+
```
54+
55+
That's it.
56+
There is no need to modify any other files.
57+
58+
59+
#### Compiling a Specific Version of SQLite
60+
61+
SQLiteLib currently ships with the source for SQLite 3.13.0.
62+
63+
If you'd like to compile a newer (or older) version, the process is simple:
64+
65+
1. Download a snapshot of the complete (raw) source tree for SQLite for the version you'd like.
66+
2. Replace the contents of SQLiteLib's "sqlite" subdirectory with the contents of the SQLite raw source tree snapshot.
67+
68+
> **IMPORTANT**:
69+
> You **must** use the complete raw SQLite source. The amalgamation source will *NOT* work properly.
70+
>
71+
> SQLiteLib internally builds the amalgamation source using the steps specified in ([How To Compile SQLite](https://www.sqlite.org/howtocompile.html#amal)).
72+
>
73+
> Setting compilation options using the SQLite amalgamation is not guaranteed to work:
74+
> > The versions of the SQLite amalgamation that are supplied on the download page are normally adequate for most users. However, some projects may want or need to build their own amalgamations. A common reason for building a custom amalgamation is in order to use certain compile-time options to customize the SQLite library. Recall that the SQLite amalgamation contains a lot of C-code that is generated by auxiliary programs and scripts. Many of the compile-time options effect this generated code and **must be supplied to the code generators before the amalgamation is assembled**.
75+
76+
**Quick Guide to Using the Latest version of SQLite**:
77+
The snapshop of the complete (raw) source tree for the *current* version of SQLite is available on the ([SQLite Download Page](https://www.sqlite.org/download.html#old)) under: **Alternative Source Code Formats**.
78+
You'll want the file named "sqlite-src-*version*.zip".
79+
> Do **NOT** use the file beginning with "sqlite-preprocessed" - it will not work properly.
80+
81+
82+
### Additional Details
83+
84+
#### Default Compilation Options
85+
86+
The built-in OSX/iOS version of SQLite were built with the following compilation options (as of OSX 10.11.5, iOS 9.3.2):
87+
88+
> Fetched using `PRAGMA compile_options;`
89+
90+
- MacOSX (10.11.5)
91+
- ENABLE_API_ARMOR
92+
- ENABLE_FTS3
93+
- ENABLE_FTS3_PARENTHESIS
94+
- ENABLE_LOCKING_STYLE=1
95+
- ENABLE_RTREE
96+
- ENABLE_UPDATE_DELETE_LIMIT
97+
- OMIT_AUTORESET
98+
- OMIT_BUILTIN_TEST
99+
- OMIT_LOAD_EXTENSION
100+
- SYSTEM_MALLOC
101+
- THREADSAFE=2
102+
103+
- iPhoneOS (9.3.2)
104+
- ENABLE_API_ARMOR
105+
- ENABLE_FTS3
106+
- ENABLE_FTS3_PARENTHESIS
107+
- ENABLE_LOCKING_STYLE=1
108+
- ENABLE_RTREE
109+
- ENABLE_UPDATE_DELETE_LIMIT
110+
- MAX_MMAP_SIZE=0
111+
- OMIT_AUTORESET
112+
- OMIT_BUILTIN_TEST
113+
- OMIT_LOAD_EXTENSION
114+
- SYSTEM_MALLOC
115+
- THREADSAFE=2
116+
117+
SQLiteLib uses these settings with one exception - on iOS:
118+
119+
The SQLite code (verified in: 3.13.0) uses a deprecated function (`gethostuuid()`).
120+
121+
D. Richard Hipp (SQLite architect), suggests working around this on iOS using `-DSQLITE_ENABLE_LOCKING_STYLE=0`:
122+
> "The SQLITE_ENABLE_LOCKING_STYLE thing is an apple-only extension that
123+
> boosts performance when SQLite is used on a network filesystem. This
124+
> is important on MacOS because some users think it is a good idea to
125+
> put their home directory on a network filesystem.
126+
>
127+
> I'm guessing this is not really a factor on iOS."
128+
129+
Thus, SQLiteLib uses SQLITE_ENABLE_LOCKING_STYLE=1 on OSX,
130+
**but on iOS, SQLiteLib compiles with ENABLE_LOCKING_STYLE=0**.
131+
132+
This removes the code that uses the deprecated function, but doesn't get rid of the warning that "`gethostuuid() is disabled`" (as of 3.13.0).
133+
To prevent this warning, SQLiteLib separately specifies `-Wno-#warnings` when building for iOS.
134+
135+
All of these base settings are configured in the SQLiteLib.xcconfig file.
136+
It is strongly recommended that you do not edit this file. If you'd like to specify additional compilation options, see [the instructions above](#specifying-additional-sqlite-compilation-options)
137+
138+
#### Build Locations
139+
140+
SQLiteLib generates intermediate files in [${DERIVED_SOURCES_DIR}](https://developer.apple.com/library/mac/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW43).
141+
142+
The generated SQLite amalgamation files are copied to:
143+
"${BUILT_PRODUCTS_DIR}/sqlite3.c"
144+
"${PROJECT_DIR}/sqlite3.h"
145+
146+
#### Notes
147+
148+
##### "sqlite3.c" shows as red/missing in Xcode
149+
150+
Xcode (verified in Version 7.3.1 (7D1014)) will always show "sqlite3.c" as red/missing, even after a build.
151+
This is a UI issue in Xcode - the path is properly set in the project.pbxproj file to be "Relative to Build Products", and the build should succeed.
152+
153+

SQLiteLib-Custom.xcconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
// Custom additions to the SQLite compilation options
3+
// These are merged with the default options (for OSX / iOS)
4+
//
5+
// As an example, SQLITE_ENABLE_PREUPDATE_HOOK is set below.
6+
// (On SQLite 3.13.0+, this enables pre-update hook functionality.)
7+
//
8+
// For more information on the options, see: https://www.sqlite.org/compile.html
9+
10+
// Added to OTHER_CFLAGS in all cases
11+
CUSTOM_SQLLIBRARY_CFLAGS = -DSQLITE_ENABLE_PREUPDATE_HOOK

SQLiteLib.xcconfig

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//
2+
// NOTE: DO NOT EDIT THIS FILE!
3+
// To specify additional custom SQLite compilation options, edit "SQLiteLib-Custom.xcconfig"
4+
//
5+
6+
#include "SQLiteLib-Custom.xcconfig"
7+
8+
// SQLiteLib targets OS X 10.9
9+
MACOSX_DEPLOYMENT_TARGET = 10.9
10+
11+
// SQLiteLib targets iOS 8.0
12+
IPHONEOS_DEPLOYMENT_TARGET = 8.0
13+
14+
// Supported platforms
15+
SUPPORTED_PLATFORMS = iphonesimulator macosx iphoneos appletvsimulator appletvos watchsimulator watchos
16+
17+
// Compilation options used by stock sqlite3 shipped with Apple operating systems
18+
//
19+
// Mac OSX 10.11.5:
20+
// ENABLE_API_ARMOR
21+
// ENABLE_FTS3
22+
// ENABLE_FTS3_PARENTHESIS
23+
// ENABLE_LOCKING_STYLE=1
24+
// ENABLE_RTREE
25+
// ENABLE_UPDATE_DELETE_LIMIT
26+
// OMIT_AUTORESET
27+
// OMIT_BUILTIN_TEST
28+
// OMIT_LOAD_EXTENSION
29+
// SYSTEM_MALLOC
30+
// THREADSAFE=2
31+
32+
// iOS 9.3.2:
33+
// ENABLE_API_ARMOR
34+
// ENABLE_FTS3
35+
// ENABLE_FTS3_PARENTHESIS
36+
// ENABLE_LOCKING_STYLE=1
37+
// ENABLE_RTREE
38+
// ENABLE_UPDATE_DELETE_LIMIT
39+
// MAX_MMAP_SIZE=0
40+
// OMIT_AUTORESET
41+
// OMIT_BUILTIN_TEST
42+
// OMIT_LOAD_EXTENSION
43+
// SYSTEM_MALLOC
44+
// THREADSAFE=2
45+
46+
// IMPORTANT:
47+
// The system SQLite library is compiled with SQLITE_ENABLE_LOCKING_STYLE=1 on both OSX 10.11 & iOS 9.0.
48+
// However, the SQLite code (verified in: 3.13.0) uses a deprecated function on iOS (gethostuuid()).
49+
//
50+
// D. Richard Hipp (SQLite architect), suggests working around this on iOS using -DSQLITE_ENABLE_LOCKING_STYLE=0
51+
// "The SQLITE_ENABLE_LOCKING_STYLE thing is an apple-only extension that
52+
// boosts performance when SQLite is used on a network filesystem. This
53+
// is important on MacOS because some users think it is a good idea to
54+
// put their home directory on a network filesystem.
55+
//
56+
// I'm guessing this is not really a factor on iOS."
57+
// Source: https://groups.google.com/forum/#!topic/sqlite-dev/7yjGulq3LmY
58+
// Via: https://github.com/clemensg/sqlite3pod/issues/1
59+
//
60+
// Thus, SQLITE_ENABLE_LOCKING_STYLE=1 is used on OSX,
61+
// and SQLITE_ENABLE_LOCKING_STYLE=0 on iOS/tvOS/watchOS.
62+
//
63+
// (Note: This doesn't get rid of the warning that "gethostuuid() is disabled" (as of 3.13.0). Uncomment the lines below to do so.)
64+
//
65+
// ↓ UNCOMMENT THE LINES BELOW to remove "gethostuuid() is disabled" warning on iOS/tvOS/watchOS.
66+
WARNING_CFLAGS[sdk=iphoneos*] = -Wno-#warnings
67+
WARNING_CFLAGS[sdk=iphonesimulator*] = -Wno-#warnings
68+
WARNING_CFLAGS[sdk=appletvos*] = -Wno-#warnings
69+
WARNING_CFLAGS[sdk=appletvsimulator*] = -Wno-#warnings
70+
WARNING_CFLAGS[sdk=watchos*] = -Wno-#warnings
71+
WARNING_CFLAGS[sdk=watchsimulator*] = -Wno-#warnings
72+
// ↑ UNCOMMENT THE LINES ABOVE to remove "gethostuuid() is disabled" warning on iOS/tvOS/watchOS.
73+
74+
// The common set of compilation options (on OSX and iOS).
75+
// NOTE: To add more compilation options, see SQLiteLibCustom.xcconfig.
76+
SQLLIBRARY_BASE_CFLAGS = -DSQLITE_ENABLE_API_ARMOR -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT -DSQLITE_OMIT_AUTORESET -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_SYSTEM_MALLOC -DSQLITE_THREADSAFE=2 -DSQLITE_OS_UNIX=1 $(CUSTOM_SQLLIBRARY_CFLAGS)
77+
78+
SQLLIBRARY_OSX_ADDITIONAL_CFLAGS = -DSQLITE_ENABLE_LOCKING_STYLE=1
79+
SQLLIBRARY_IOS_ADDITIONAL_CFLAGS = -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_MAX_MMAP_SIZE=0
80+
SQLLIBRARY_RELEASE_CFLAGS = -DNDEBUG
81+
SQLLIBRARY_ARMV6_CFLAGS = -mno-thumb
82+
83+
SQLLIBRARY_CFLAGS = $(SQLLIBRARY_BASE_CFLAGS)
84+
SQLLIBRARY_CFLAGS[sdk=iphoneos*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
85+
SQLLIBRARY_CFLAGS[sdk=iphonesimulator*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
86+
SQLLIBRARY_CFLAGS[sdk=appletvos*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
87+
SQLLIBRARY_CFLAGS[sdk=appletvsimulator*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
88+
SQLLIBRARY_CFLAGS[sdk=watchos*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
89+
SQLLIBRARY_CFLAGS[sdk=watchsimulator*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_IOS_ADDITIONAL_CFLAGS)
90+
SQLLIBRARY_CFLAGS[sdk=macosx*] = $(SQLLIBRARY_BASE_CFLAGS) $(SQLLIBRARY_OSX_ADDITIONAL_CFLAGS)
91+
92+
OTHER_CFLAGS = $(SQLLIBRARY_CFLAGS)
93+
OTHER_CFLAGS[arch=armv6] = $(SQLLIBRARY_ARMV6_CFLAGS) $(SQLLIBRARY_CFLAGS)
94+
OTHER_CFLAGS[config=Release] = $(SQLLIBRARY_CFLAGS) $(SQLLIBRARY_RELEASE_CFLAGS)
95+
OTHER_CFLAGS[config=Release][arch=armv6] = $(SQLLIBRARY_ARMV6_CFLAGS) $(SQLLIBRARY_CFLAGS) $(SQLLIBRARY_RELEASE_CFLAGS)

0 commit comments

Comments
 (0)