The demo iOS application from GRDB on github runs great on the phone simulator of my iMac, but it's not clear how to get GRDB building in an iOS application of my own (part 1 of this question), with the minimal set of components (part 2 of this question).1
The GRDB installation instructions suggests offers as one option: "Swift Package Manager". Since I'm new to this programming environment, this sounded like "the right way", but after trying it, I was still left guessing at how to get my project building successfully.
Steps done so far:
Applications > Xcode (9.4 beta) > Create a new Xcode project > Single View App > "FirstDb"
import GRDB
in the view controller (obviously couldn't compile yet)cd /Users/owner/documents/xcodeprojects/firstdb
mkdir GRDB
cd GRDB
swift package init --type library
Package.swift
, adding .package(url: "https://github.com/groue/GRDB.swift.git", from: "2.10.0")
at the appropriate locationswift package resolve
(resulting in 'Fetching', 'Cloning', 'Resolving')Status
After Product > Build
, the import GRDB
line still says no such module
.
So part 1 of the question is still unresolved. I have not been able to address part 2 of the question yet. Sorry if either or both of these are brutally obvious to the well heeled Xcode developer, but after researching the problem, I found no specific guidance.
Using SPM is not a requirement, so if the other options to integrate GRDB are a better choice, I'd like to see how to integrate using one of those.
Footnote
Record
object and to be able to execute SQL statements for an iOS project. The presumption is that much of the complete package (tests, watch, etc, is not required in the project using the GRDB basics, resulting in a more compact iOS application. As indicated by the author, Swift Package Manager is only one option and is "not known to integrate with existing Xcode projects", so probably not a good choice. So to address part one of the question, the technique for integrating GRDB
using Cocoa Pods
is shown below.
Based on this tutorial, you should be able to install CocoaPods without downloading anything first if your OS is OS X 10.7 or newer.
Applications > Utilities > Terminal
sudo gem install cocoapods
pod setup --verbose
My install seemed to work fine, but generated more logging than the tutorial showed.
Applications > Xcode (9.4 beta) > Create a new Xcode project > Single View App > "FirstDb"
/Users/owner/documents/xcodeprojects/FirstDb/FirstDb.xcodeproj
import GRDB
in the view controller (obviously couldn't compile yet)Applications > Utilities > Terminal
cd /Users/owner/documents/xcodeprojects/firstdb
pod init
open -a Xcode PodFile
Make your file specify GRDB:
platform :ios, '9.0'
target 'FirstDb' do
use_frameworks!
pod 'GRDB.swift'
end
That doesn't take advantage of the versioning function available, so it will be up to you to make sure there's no breaking changes by introduced by GRDB as it is enhanced.
Now is when you download GRDB:
Applications > Utilities > Terminal
cd /Users/owner/documents/xcodeprojects/firstdb
pod install
You should see something like this:
Analyzing dependencies
Downloading dependencies
Installing GRDB.swift (2.10.0)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `FirstDb.xcworkspace` for this project from now on.
....
Now open the workspace file FirstDb.xcworkspace
(not the proj file). In the left project outline, you should see your starter project and also Pods
:
FirstDb
Pods
Build the workspace (Product > Build
), and you should see that your import GRDB
line in the ViewController is compiling without errors.