Skip to content

Conversation

@darrenclark
Copy link
Contributor

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:

  • 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 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

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
sqlitelib -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 sqlitecustom target will still build libraries
for the correct platform, as it did before)
@swiftlyfalling
Copy link
Owner

swiftlyfalling commented Oct 10, 2017

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.

@swiftlyfalling swiftlyfalling merged commit 69e0d4d into swiftlyfalling:master Oct 10, 2017
@swiftlyfalling swiftlyfalling changed the title Fix iOS builds from command line (xcodebuild) Fix iOS builds from command line (xcodebuild -sdk) Oct 11, 2017
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