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

Fix iOS builds from command line #1

Closed

Conversation

darrenclark
Copy link

Changes include:

1. Fix building the iOS library from the command line

(Basically a copy/paste of the fixes made here: swiftlyfalling/SQLiteLib#24)

When building via the xcodebuild, ie:

xcodebuild -scheme sqlcipher -configuration Release -sdk -sdk iphoneos

the amalgamation target would fail when running the configure script with an error like:

Configure and generate SQLite amalgamation files
XCode has selected SDK: iphoneos with version: 1.0
Making amalgamation source with SDK_PLATFORM_NAME = iphonesimulator
Clean-up previous files if necessary
Configure makefile
checking build system type... i386-apple-darwin16.7.0
checking host system type... i386-apple-darwin16.7.0
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 `/Users/darren/Library/Developer/Xcode/DerivedData/SQLiteLib-dhjaljbzybymykdsrkatgnwuqtub/Build/Intermediates.noindex/SQLiteLib.build/Release-iphoneos/amalgamation.build/DerivedSources':
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

It turns out it was getting tripped up because it was running the configure script as if it was trying to build for iOS, causing the configure: error: cannot run C compiled programs. error.

It seems Xcode & xcodebuild differ in behaviour here:

  • Xcode runs the run script build phase as if it was compiling for macOS, even when building the library for iOS

  • xcodebuild runs the run script build phase as if it was compiling for whatever platform is specified via the -sdk option. This causes all sorts of issues for non-macOS because the Makefile builds & runs some command line utilities as part of the build process:

    build_sqlitelib

This PR/commit ensures the configure script & make are always run as if we are building for macOS. (The sqlcipher target will still build for the selected platform).

Here's the new run script build phase (as the diff is pretty unreadable):

screen shot 2017-10-09 at 6 03 03 pm

2. Misc. project file cleanup

Some project files changes inspired by the project file in https://github.com/swiftlyfalling/SQLiteLib

  • Removed the SQLCipher OSX/iOS/watchOS/tvOS schemes (these didn't seem to be building for me before I made the changes, and I believe we can use the sqlcipher target for all platforms)
  • Add a 'sqlcipher' scheme that supports all 4 of the plaforms
  • Update SUPPORTED_PLATFORMS to include all 4 platforms and their simulator counterparts, add armv7k (Watch) to VALID_ARCHS

groue and others added 10 commits April 4, 2016 07:43
This is a workaround for sqlcipher#162

But we need another fix, since SQLITE_ENABLE_UPDATE_DELETE_LIMIT
should not be used when building from the amalgation, according to
https://www.sqlite.org/compile.html#enable_update_delete_limit
Ues the same compilation options than the stock sqlite3 shipped with
OS X 10.11 and iOS 9.3, as exposed through PRAGMA compile_options.

See sqlcipher#163
For whatever reason, it seems when building inside Xcode.app, the
amalgamation target has environment variables set as if it is being
built for macOS (even when building the iOS library), so the
configure/make steps work fine.

However, when building via the command line (ie: `xcodebuild -scheme
sqlcipher -configuration Release -sdk iphoneos`), the amalgamation
target was getting environment variables set as if it was building for
iOS. This was causing the `configure` step to fail, because it thought
the compiler was broken (macOS couldn't run binaries that were being
built for iOS).

This commit fixes the issue by always running configure as if we were
building for macOS. (The sqlcipher target will still build libraries
for the correct platform, as it did before)
- Remove the SQLCipher OSX/iOS/watchOS/tvOS schemes
- Add a 'sqlcipher' scheme that supports all 4 of the plaforms
- Update SUPPORTED_PLATFORMS to include all 4 platforms
  and their simulator counterparts, add armv7k (Watch) to VALID_ARCHS
@groue
Copy link
Owner

groue commented Oct 11, 2017

Many thanks @darrenclark for your much appreciated Xcode skills! I've cherry picked your commits on top of sqlcipher v3.4.1 and pushed the result on master branch.

@groue groue closed this Oct 11, 2017
groue added a commit to groue/GRDB.swift that referenced this pull request Oct 11, 2017
@darrenclark
Copy link
Author

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants