找不到目标'x86_64-apple-ios-simulator'的模块'MyCustomFramework';找到:arm64,armv7-apple-ios,arm

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了找不到目标'x86_64-apple-ios-simulator'的模块'MyCustomFramework';找到:arm64,armv7-apple-ios,arm相关的知识,希望对你有一定的参考价值。

我有一个要归档的自定义框架,供另一个项目使用。更新到Xcode11后,在使用该框架的项目中出现以下错误。

找不到目标'x86_64-apple-ios-simulator'的模块'MyCustomFramework';找到:arm64,armv7-apple-ios,arm64-apple-ios,arm,armv7

我的框架在Xcode10上工作正常,但在11上却不能。我的目标仅对于构建活动架构设置为NO。对于有效架构,我有以下内容; arm64e,armv7s,armv7,arm64。

我的构建脚本

exec > ${PROJECT_DIR}/${PROJECT_NAME}_archive.log 2>&1

UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal

if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"

# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"

echo "Building for iPhoneSimulator"
xcodebuild -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max' ONLY_ACTIVE_ARCH=NO ARCHS='i386 x86_64' BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" ENABLE_BITCODE=YES OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode clean build

# Step 1. Copy the framework structure (from iphoneos build) to the universal folder
echo "Copying to output folder"
cp -R "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}" "${UNIVERSAL_OUTPUTFOLDER}/"

# Step 2. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule"
fi

# Step 3. Create universal binary file using lipo and place the combined executable in the copied framework directory
echo "Combining executables"
lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${EXECUTABLE_PATH}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${EXECUTABLE_PATH}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${EXECUTABLE_PATH}"

# Step 4. Create universal binaries for embedded frameworks
#for SUB_FRAMEWORK in $( ls "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks" ); do
#BINARY_NAME="${SUB_FRAMEWORK%.*}"
#lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${SUB_FRAMEWORK}/${BINARY_NAME}" "${ARCHIVE_PRODUCTS_PATH}${INSTALL_PATH}/${TARGET_NAME}.framework/Frameworks/${SUB_FRAMEWORK}/${BINARY_NAME}"
#done

# Step 5. Convenience step to copy the framework to the project's directory
ARCHIVE_PATH="${PROJECT_DIR}/Products"
rm -rf "${ARCHIVE_PATH}"
mkdir "${ARCHIVE_PATH}"

echo "Copying to project dir"
yes | cp -Rf "${UNIVERSAL_OUTPUTFOLDER}/${FULL_PRODUCT_NAME}" "${ARCHIVE_PATH}"

open "${ARCHIVE_PATH}"

fi

答案

此行不正确

cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/${TARGET_NAME}.swiftmodule"

应该是

cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/"

您需要检入目标文件夹

"${UNIVERSAL_OUTPUTFOLDER}/${TARGET_NAME}.framework/Modules/"

如果有类似文件

x86_64-apple-ios-simulator.swiftdoc
x86_64-apple-ios-simulator.swiftmodule
x86_64.swiftdoc
x86_64.swiftmodule

在Xcode 11之前,Apple似乎忽略了这些文件,因此您的脚本运行良好。

从Xcode 11开始,似乎已经严格检查了这些文件。

以上是关于找不到目标'x86_64-apple-ios-simulator'的模块'MyCustomFramework';找到:arm64,armv7-apple-ios,arm的主要内容,如果未能解决你的问题,请参考以下文章

Mac上的Qt说找不到架构x86_64的符号[重复]

为啥找不到 composer 命令?

安装了cn_project_professional_2016_x86_x64_dvd_6966612.iso,为啥找不到project软件?

“找不到类'XMLWriter'” php 中的错误| php55w-xml-5.5.24-1.w6.x86_64.rpm 丢失

错误:检查jps时找不到libjava.so

可以在 Obj C 中链接,找不到符号,也不会在 Swift 中链接