xcode 错误:无法为目标“arm64-apple-ios10.0-simulator”加载标准库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51558933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:43:04  来源:igfitidea点击:

error: unable to load standard library for target 'arm64-apple-ios10.0-simulator'?

iosswiftxcodexcode10

提问by tp2376

I updated my Xcode but not able to build. It's failing with:

我更新了我的 Xcode 但无法构建。它失败了:

<unknown>:0: error: unable to load standard library for target 'arm64-apple-ios10.0-simulator'

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

回答by Alex Barti?

Actually solved this by selecting Generic iOS Devicewhen building instead of a simulator device.

实际上通过Generic iOS Device在构建时选择而不是模拟器设备来解决这个问题。

Edit: I should mention, in Xcode 10.

编辑:我应该提到,在 Xcode 10 中。

Edit 2: I'll post my universal framework script

编辑 2:我将发布我的通用框架脚本

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

回答by Werner Altewischer

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.

在我的案例中解决问题的是清理环境。显然,在 Xcode 中运行脚本构建阶段时,设置了一些环境变量,可能会干扰 Swift 标准库的解析。我在从 Xcode“运行脚本”阶段执行迦太基构建时遇到了这个问题。

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.

不过,您可能希望保留 PATH 和 DEVELOPER_DIR 环境变量,特别是当您安装了多个 Xcode 版本时。

so in your case

所以在你的情况下

env -i DEVELOPER_DIR="$DEVELOPER_DIR" PATH="$PATH" xcodebuild ...

回答by MrAn3

For me just restarting XCode solved it.

对我来说只是重新启动 XCode 解决了它。

回答by Shauket Sheikh

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.

安装最新的 Xcode 10 GM 种子,面对同样的问题尝试了很多解决方案,但在更新到新的 Xcode 问题后解决了。如果仍然存在问题,请尝试转到文件和项目设置,将构建系统设置为旧构建系统,清理并构建。

enter image description here

在此处输入图片说明

回答by tp2376

Thanks for the all answers but seems it's Xcode installation bug ..I dowloaded Xcode again and tested everything works fine in my case.

感谢您提供所有答案,但似乎是 Xcode 安装错误..我再次下载了 Xcode 并在我的情况下测试了一切正常。

回答by KIO

Possibly connected to bad swift version

可能与错误的 swift 版本有关

Try to check your current swift packages with

尝试检查您当前的 swift 包

swiftenv versions

use install or uninstall commands respectively

分别使用安装或卸载命令

swiftenv uninstall (install)

To install swiftenvuse

安装swiftenv使用

brew install kylef/formulae/swiftenv

回答by Dávid Pásztor

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.

重置所有环境变量不是解决方案,因为这也会取消设置 SSH 密钥,例如,如果使用 SSH 身份验证,这将导致克隆失败。

However, the only problematic environment variable is LLVM_TARGET_TRIPLE_SUFFIX, so unsetting that solves the problem.

但是,唯一有问题的环境变量是LLVM_TARGET_TRIPLE_SUFFIX, so unsetting 解决了问题。

unset LLVM_TARGET_TRIPLE_SUFFIX
carthage update 2>&1

回答by Jimmy Dawg

I just had this issue occur randomly. There were no build errors in my code. After swicthing to new simulator & cleaning build folder with no luck, I restarted xCode (11.5), and the issue self-resolved. Anytime you get wierd build failures, restart xCode.

我只是随机出现了这个问题。我的代码中没有构建错误。切换到新模拟器并清理构建文件夹但没有运气后,我重新启动了 xCode (11.5),问题自行解决。每当您遇到奇怪的构建失败时,请重新启动 xCode。

回答by oxigen

Try to add iOS 10 simulator to your xCode. enter image description here

尝试将 iOS 10 模拟器添加到您的 xCode。 在此处输入图片说明