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

时间:2019-09-24 19:09:25

标签: ios swift ios-frameworks xcode11

我有一个要归档的自定义框架,供另一个项目使用。更新到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

2 个答案:

答案 0 :(得分:2)

此行不正确

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中,似乎已经严格检查了这些文件。

答案 1 :(得分:0)

Swift 5.0-5.1,Xcode 11
打开Xcode,<您的项目>,构建设置,仅构建Active Architecture,并更改为以进行调试和发布。设置/保留标准体系结构-$(ARCHS_STANDART)中的体系结构,下一步很重要:
有效体系结构:armv7,armv7s,amr64,amr64e,在此处添加x86_64,如果需要,请添加i386进行调试和发布。 (字符串:armv7,armv7s,amr64,amr64e,x86_64)

在您的模拟器列表和内置IT中选择任何模拟器。完成。

我希望它对您有用。


建筑说明:

armv64:iPhoneX,iPhone 5s-8,iPad Air-iPad Pro

armv7:iPhone3Gs-5c,iPad WIFI(第四代)

armv6:iPhone-iPhone3G

-如果用于真实设备,则为以上

i386:32位模拟器

x86_64:64位模拟器