Reputation: 740
I updated my Xcode but not able to build. It's failing with:
<unknown>:0: error: unable to load standard library for target 'arm64-apple-ios10.0-simulator'
Merge Script:
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="SDK"
OUTPUT_PATH="${SRCROOT}"
# 3
# If remnants from a previous build exist, delete them.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
# 4
# Build the framework for device and for simulator (using
# all needed architectures).
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch
arm64 -arch armv7 -arch armv7s only_active_arch=no defines_module=yes -
sdk "iphoneos"
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch
x86_64 -arch i386 only_active_arch=no defines_module=yes -sdk
"iphonesimulator"
Upvotes: 33
Views: 46833
Reputation: 1011
if you're building for iOS Simulator on a Mac with Apple Silicon, you encounter issues with architecture mismatches, you have to use simulator with Rosetta
Go to the menu Product → Destination → Show All Run Destinations.
This show you all available simulator, choose one with Rosetta and retry (clean build folder, build ...)
Xcode : 15.4 macOs : 14.6 (M2)
Upvotes: 0
Reputation: 5852
for new versions of Xcode try opening Xcode through Rosetta
Right click on Xcode in applications folder -> Get Info -> set Open with Rosetta to true
Upvotes: 8
Reputation: 81
I just had this issue occur randomly. There were no build errors in my code. After switching to new simulator & cleaning build folder with no luck, I restarted Xcode (11.5), and the issue self-resolved. Anytime you get weird build failures, restart Xcoode.
Upvotes: 7
Reputation: 108
For me, the following solved the problem:
From the target build Setting
setting Architectures to $(NATIVE_ARCH)
and add $(ARCHS_STANDARD)
to Valid Architectures.
This might help What's the difference between "Architectures" and "Valid Architectures" in Xcode Build Settings?
Upvotes: 2
Reputation: 1915
I got this issue a few days back so what I did was
Doing this helped me to resolve the issue and I was able to run the application again
Upvotes: 9
Reputation: 54706
Resetting all environment variables is not a solution, since that will also unset SSH keys for instance, which will cause cloning to fail in case SSH authentication is used.
However, the only problematic environment variable is LLVM_TARGET_TRIPLE_SUFFIX
, so unsetting that solves the problem.
unset LLVM_TARGET_TRIPLE_SUFFIX
carthage update 2>&1
Upvotes: 0
Reputation: 1703
Actually solved this by selecting Generic iOS Device
when building instead of a simulator device.
Edit: I should mention, in Xcode 10.
Edit 2: I'll post my universal framework script
set -e
######################
# Options
######################
REVEAL_ARCHIVE_IN_FINDER=true
FRAMEWORK_NAME="${PROJECT_NAME}"
SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework"
DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework"
UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal"
FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework"
######################
# Build Frameworks
######################
xcodebuild -project ${PROJECT_FILE_PATH} -scheme ${PROJECT_NAME} -sdk iphonesimulator -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 2>&1
xcodebuild -project ${PROJECT_FILE_PATH} -scheme ${PROJECT_NAME} -sdk iphoneos -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos 2>&1
######################
# Create directory for universal
######################
rm -rf "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${UNIVERSAL_LIBRARY_DIR}"
mkdir "${FRAMEWORK}"
######################
# Copy files Framework
######################
cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}"
######################
# Make an universal binary
######################
lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo
# For Swift framework, Swiftmodule needs to be copied in the universal framework
if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
fi
if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then
cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo
fi
######################
# On Release, copy the result to release directory
######################
OUTPUT_DIR="${PROJECT_DIR}/Output/${FRAMEWORK_NAME}-${CONFIGURATION}-iphoneuniversal/"
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR"
cp -r "${FRAMEWORK}" "$OUTPUT_DIR"
if [ ${REVEAL_ARCHIVE_IN_FINDER} = true ]; then
open "${OUTPUT_DIR}/"
fi
Upvotes: 27
Reputation: 10466
What fixed the issue in my case was clearing the environment. Apparently when running a script build phase in Xcode, there are some environment variables set which may interfere with the resolution of the Swift standard library. I had this issue while performing a carthage build from an Xcode "Run Script" phase.
Perform a command by clearing the environment with:
env -i <command>
You may want to keep the PATH and DEVELOPER_DIR environment variables though, in particular when you have multiple Xcode versions installed.
so in your case
env -i DEVELOPER_DIR="$DEVELOPER_DIR" PATH="$PATH" xcodebuild ...
Upvotes: 8
Reputation: 740
Thanks for the all answers but seems it's Xcode installation bug ..I dowloaded Xcode again and tested everything works fine in my case.
Upvotes: 0
Reputation: 2778
Install latest Xcode 10 GM seed, facing same issue tried many solution but after updating to new Xcode issue resolved. if still issue be there then try this go to File and project setting, set build system to legacy build system, clean and build.
Upvotes: -1
Reputation: 2215
Possibly connected to bad swift version
Try to check your current swift packages with
swiftenv versions
use install or uninstall commands respectively
swiftenv uninstall (install)
To install swiftenv
use
brew install kylef/formulae/swiftenv
Upvotes: 0