Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build SQLCipher from Command Line #144

Closed
chriswjones opened this issue Nov 17, 2016 · 3 comments
Closed

Build SQLCipher from Command Line #144

chriswjones opened this issue Nov 17, 2016 · 3 comments
Labels
blocked Progress is impossible due to some external blocking reason enhancement help wanted Extra attention is needed

Comments

@chriswjones
Copy link

Hi @groue i am having trouble building an iOS project from the command line (it is building and running in Xcode fine). It has GRDB embedded to use GRDBCipher. I have tracked down the issue and it seems related to #41 .

The amalgamation is failing to compile when xcodebuild is run with -sdk iphoneos. Here is the output from trying to compile GRDBCipheriOS
xcodebuild build -workspace GRDB.xcworkspace -scheme GRDBCipheriOS

...
clang: error: no such file or directory: '/Users/chris/Library/Developer/Xcode8/DerivedData/GRDB-dorpyeywouyvbhchskfwzdrnycof/Build/Products/Debug-iphoneos/libsqlcipher.a'

** BUILD FAILED **


The following build commands failed:
	Ld /Users/chris/Library/Developer/Xcode8/DerivedData/GRDB-dorpyeywouyvbhchskfwzdrnycof/Build/Intermediates/GRDB.build/Debug-iphoneos/GRDBCipheriOS.build/Objects-normal/armv7/GRDBCipher normal armv7
	Ld /Users/chris/Library/Developer/Xcode8/DerivedData/GRDB-dorpyeywouyvbhchskfwzdrnycof/Build/Intermediates/GRDB.build/Debug-iphoneos/GRDBCipheriOS.build/Objects-normal/arm64/GRDBCipher normal arm64
(2 failures)

Here is the output attempting to compile just sqlcipher amalgamation target with -sdk iphoneos
xcodebuild build -project SQLCipher/src/sqlcipher.xcodeproj -target amalgamation -sdk iphoneos

...
checking build system type... i386-apple-darwin16.1.0
checking host system type... i386-apple-darwin16.1.0
checking how to print strings... printf
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/repos/scratch/GRDB.swift/SQLCipher/src':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Command /bin/sh failed with exit code 1

** BUILD FAILED **


The following build commands failed:
	PhaseScriptExecution Run\ Script build/sqlcipher.build/Release-iphoneos/amalgamation.build/Script-9069D08A0FCE185A0042E34C.sh
(1 failure)

That script file mentioned in the error is the amalgamation post script from #41

I was able to get a GRDBCipher to compile via the command line if i first compile the amalgamation target via the command line with -sdk macosx, and remove the amalgamation target from sqlcipher's target dependencies so it will use the previously produced output rather than trying to compile it.

I have tried updating the run script in the sqlcipher amalgamation target, and no matter what i override the build will fail if i use -sdk iphoneos in the command line. Any ideas/help would be greatly appreciated. Thanks!

@groue
Copy link
Owner

groue commented Nov 18, 2016

Hello @chriswjones

I agree that SQLCipher integration is fragile, to say the least. I even had to drop Carthage support for it, because it was failing too often (read: sometimes).

It looks like the sqlcipher target from the Xcode project shipped by https://github.com/sqlcipher/sqlcipher doesn't inherit the platform of their dependent targets (GRDBCipherOSX or GRDBCipheriOS). This explains the no such file or directory: .../Debug-iphoneos/libsqlcipher.a error: when one builds, say, GRDBCipheriOS, sqlcipher may actually build a macOS library, instead of an iOS library.

I don't know if this is a bug with the Xcode project shipped by https://github.com/sqlcipher/sqlcipher, or a bug in xcodebuild, or a normal behavior 😶. This topic is just beyond my skills.

Either way, since Xcode can build both macOS and iOS GRDBCipher targets, I suppose xcodebuild can as well. We just don't know yet what arguments or environment variables are missing. Observing the building logs from Xcode may shed some light.

@groue groue changed the title Build from Command Line Build SQLCipher from Command Line Nov 18, 2016
@groue groue added enhancement help wanted Extra attention is needed labels Nov 18, 2016
@chriswjones
Copy link
Author

@groue Thanks for the response. I spent some time digging into it and did not come up with a solution to build via command line. However, I was able to get Xcode Bots to build the project successfully and build a workaround to hook into our team city build server after a bot run.

@groue
Copy link
Owner

groue commented Nov 22, 2016

@chriswjones All right, let's close this issue for now, since nobody really knows how to deal with it for good ;-) Thanks for the hint about Xcode Bots: it may well help other developers out there that will stumble upon this issue. Happy GRDB!

@groue groue closed this as completed Nov 22, 2016
@groue groue added the blocked Progress is impossible due to some external blocking reason label Nov 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Progress is impossible due to some external blocking reason enhancement help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants