From b877895ee2a94c84509ae388ef95bd1114319aae Mon Sep 17 00:00:00 2001 From: Darren Clark Date: Sun, 8 Oct 2017 23:54:35 -0400 Subject: [PATCH] Fix iOS builds from command line (xcodebuild) 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) --- SQLiteLib.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLiteLib.xcodeproj/project.pbxproj b/SQLiteLib.xcodeproj/project.pbxproj index db94acfc..991d2f7f 100755 --- a/SQLiteLib.xcodeproj/project.pbxproj +++ b/SQLiteLib.xcodeproj/project.pbxproj @@ -187,7 +187,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\necho \"Configure and generate SQLite amalgamation files\"\n\npattern=\" |'\"\nif [[ ${PROJECT_DIR} =~ $pattern ]]\nthen\necho \"Unsafe PROJECT_DIR for make - contains spaces.\"\necho \"PROJECT_DIR=${PROJECT_DIR}\"\nexit 1\nfi\n\nSDK_VERSION=$(echo ${SDK_NAME} | grep -o '.\\{3\\}$')\n\n# Configure and make the amalgamation files using the appropriate simulator SDK\nif [ ${PLATFORM_NAME} = \"macosx\" ]; then\nSDK_PLATFORM_NAME=\"macosx\"\nelif [ ${PLATFORM_NAME} = \"appletvsimulator\" ] || [ ${PLATFORM_NAME} = \"appletvos\" ]; then\nSDK_PLATFORM_NAME=\"appletvsimulator\"\nelif [ ${PLATFORM_NAME} = \"watchsimulator\" ] || [ ${PLATFORM_NAME} = \"watchos\" ]; then\nSDK_PLATFORM_NAME=\"appletvsimulator\" #watchsimulator sdk doesn't work for build?\nelif [ ${PLATFORM_NAME} = \"iphonesimulator\" ] || [ ${PLATFORM_NAME} = \"iphoneos\" ]; then\nSDK_PLATFORM_NAME=\"iphonesimulator\"\nelse\necho \"Unsupported target platform and SDK: ${PLATFORM_NAME}, ${SDK_NAME}\"\nexit 1\nfi\n\n#macOS Sierra fix - this now always run configure with the macOS SDK\necho \"XCode has selected SDK: ${PLATFORM_NAME} with version: ${SDK_VERSION}\"\necho \"Making amalgamation source with SDK_PLATFORM_NAME = ${SDK_PLATFORM_NAME}\"\n\nSDKROOT=\"$(xcrun --sdk $SDK_PLATFORM_NAME --show-sdk-path)\"\nCC=\"$(xcrun --sdk $SDK_PLATFORM_NAME -f clang)\"\nCXX=\"$(xcrun --sdk $SDK_PLATFORM_NAME -f clang++)\"\nCFLAGS=\"-isysroot $SDKROOT $OTHER_CFLAGS\"\nCXXFLAGS=$CFLAGS\nexport CC CXX CFLAGS CXXFLAGS\n\nmkdir -p \"${DERIVED_SOURCES_DIR}\"\ncd \"${DERIVED_SOURCES_DIR}\"\n\necho \"Clean-up previous files if necessary\"\n[ -e Makefile ] && make distclean\n\necho \"Configure makefile\"\n\"${PROJECT_DIR}/sqlite/configure\" --srcdir=\"${PROJECT_DIR}/sqlite/\"\n\necho \"Make SQLite amalgamation\"\nmake sqlite3.c\n\n# copy generated amalgamation files (sqlite3.c and sqlite3.h)\n# to BUILD_DIR/sqlite\nSQLITE_OUTPUT_DIR=\"${BUILD_DIR}/sqlite\"\nmkdir -p \"${SQLITE_OUTPUT_DIR}\"\necho \"Copying sqlite3.c to ${SQLITE_OUTPUT_DIR}/sqlite3.c\"\ncp ./sqlite3.c \"${SQLITE_OUTPUT_DIR}/sqlite3.c\"\necho \"Copying sqlite3.h to ${PROJECT_DIR}/sqlite3.h\"\ncp ./sqlite3.h \"${PROJECT_DIR}/sqlite3.h\"\n\necho \"Finished generating SQLite amalgamation files\"\n"; + shellScript = "set -e\n\necho \"Configure and generate SQLite amalgamation files\"\n\npattern=\" |'\"\nif [[ ${PROJECT_DIR} =~ $pattern ]]\nthen\necho \"Unsafe PROJECT_DIR for make - contains spaces.\"\necho \"PROJECT_DIR=${PROJECT_DIR}\"\nexit 1\nfi\n\n# Ensure we always run configure/make as if we were compiling for macOS (as parts of the\n# configure/make process require building & running an executable)\n#\n# The generated sqlite3.c will be built for the correct platform by Xcode via the\n# 'sqlitecustom' target\nSDK_PLATFORM_NAME=\"macosx\"\nMACOSX_VERSION_MIN=\"$(sw_vers -productVersion | cut -d '.' -f 1,2)\"\n\n\nSDKROOT=\"$(xcrun --sdk $SDK_PLATFORM_NAME --show-sdk-path)\"\nCC=\"$(xcrun --sdk $SDK_PLATFORM_NAME -f clang)\"\nCXX=\"$(xcrun --sdk $SDK_PLATFORM_NAME -f clang++)\"\nCFLAGS=\"-arch x86_64 -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_VERSION_MIN $OTHER_CFLAGS\"\nCXXFLAGS=$CFLAGS\nexport CC CXX CFLAGS CXXFLAGS\n\nmkdir -p \"${DERIVED_SOURCES_DIR}\"\ncd \"${DERIVED_SOURCES_DIR}\"\n\necho \"Clean-up previous files if necessary\"\n[ -e Makefile ] && make distclean\n\necho \"Configure makefile\"\n\"${PROJECT_DIR}/sqlite/configure\" --srcdir=\"${PROJECT_DIR}/sqlite/\"\n\necho \"Make SQLite amalgamation\"\nmake sqlite3.c\n\n# copy generated amalgamation files (sqlite3.c and sqlite3.h)\n# to BUILD_DIR/sqlite\nSQLITE_OUTPUT_DIR=\"${BUILD_DIR}/sqlite\"\nmkdir -p \"${SQLITE_OUTPUT_DIR}\"\necho \"Copying sqlite3.c to ${SQLITE_OUTPUT_DIR}/sqlite3.c\"\ncp ./sqlite3.c \"${SQLITE_OUTPUT_DIR}/sqlite3.c\"\necho \"Copying sqlite3.h to ${PROJECT_DIR}/sqlite3.h\"\ncp ./sqlite3.h \"${PROJECT_DIR}/sqlite3.h\"\n\necho \"Finished generating SQLite amalgamation files\"\n"; }; /* End PBXShellScriptBuildPhase section */