swiftlyfalling / SQLiteLib

Easily build a custom SQLite static library for use in macOS and iOS frameworks and apps.
MIT License
64 stars 23 forks source link

Fix iOS builds from command line (xcodebuild -sdk) #24

Closed darrenclark closed 6 years ago

darrenclark commented 6 years ago

When building via the xcodebuild, ie:

xcodebuild -scheme sqlitelib -configuration Release -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:

This PR/commit ensures the configure script & make are always run as if we are building for macOS. (The sqlitecustom 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-08 at 11 53 08 pm

swiftlyfalling commented 6 years ago

Had this on my to-do list to improve - very nice!

EDIT: For clarification, using xcodebuild with the -destination parameter previously worked properly. This fix extends support to using xcodebuild with the -sdk parameter instead.