xcode 找不到目标“x86_64-apple-ios-simulator”的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/56957632/
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:59:49  来源:igfitidea点击:

Could not find module for target 'x86_64-apple-ios-simulator'

iosswiftxcodexcode11

提问by Oleshko

I have my custom framework and it works properly in XCode 10. I rebuild it in XCode 11 beta 3, then integrated into the app, and get the following error:

我有我的自定义框架,它在 XCode 10 中正常工作。我在 XCode 11 beta 3 中重建它,然后集成到应用程序中,并收到以下错误:

Could not find module 'MyCustomFramework' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios

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

Are there some changes I have to make in "valid architectures" in the framework project?

我必须在框架项目中的“有效架构”中进行一些更改吗?

Updated:I can't pick any answer as a correct one as the framework in my case was really tiny (one class, a few methods) and almost not in use, so I decided to get rid of it and move these a few methods into main project.

更新:我无法选择任何答案作为正确的答案,因为在我的案例中的框架非常小(一个类,几个方法)并且几乎没有使用,所以我决定摆脱它并移动这几个方法进入主要项目。

回答by willhess

To solve this issue I had to create a fat library of my custom framework again using xcode 11 tools.

为了解决这个问题,我不得不使用 xcode 11 工具再次创建我的自定义框架的胖库。

To do that I did the following:

为此,我执行了以下操作:

1)Build YourCustomFrameworktarget for iOS simulator and extract framework from products folder on your desktop.

1)YourCustomFramework为 iOS 模拟器构建目标并从桌面上的产品文件夹中提取框架。

Xcode? ? ?DerivedData? ? ?Your Project ? ?Build? ? ?Products? ? ?Release-iphonesimulator

Xcode?? ?派生数据?? ?你的项目??建造?? ?产品?? ?发布-iphonesimulator

2)Build YourCustomFrameworktarget for Generic iOS Device and extract framework from products folder on your desktop.

2)YourCustomFramework为通用 iOS 设备构建目标并从桌面上的产品文件夹中提取框架。

Xcode? ? ?DerivedData? ? ?Your Project ? ?Build? ? ?Products? ? ?Release-iphoneos?

Xcode?? ?派生数据?? ?你的项目??建造?? ?产品?? ?发布-iphoneos?

3)Rename the simulator generated framework to YourCustomFramework-sim.frameworkso that it is distinguishable later.

3)将模拟器生成的框架重命名为,YourCustomFramework-sim.framework以便以后区分。

4)Use the lipo command to combine both binaries into a single fat binary file. (cd to your desktop or wherever your custom framework file is located)

4)使用 lipo 命令将两个二进制文件合并成一个胖二进制文件。(cd 到您的桌面或您的自定义框架文件所在的任何位置)

$lipo -create ./YourCustomFramework-sim.framework/YourCustomFramework ./YourCustomFramework.framework/YourCustomFramework -output ./YourCustomFramework

5)Copy YourCustomFrameworkbinary file created in above step and replace it with the binary in YourCustomFramework.frameworkfolder.

5)复制YourCustomFramework上述步骤中创建的二进制文件,并将其替换为YourCustomFramework.framework文件夹中的二进制文件。

6)From folder

6)从文件夹

YourCustomFramework-sim.framework/Modules/YourCustomFramework.swiftmodule/

copy all of the modules and paste them to

复制所有模块并将它们粘贴到

YourCustomFramework.framework/Modules/YourCustomFramework.swiftmodule/

This should solve your issue.

这应该可以解决您的问题。

回答by Serg Fugol

Swift 5.0-5.1, Xcode 11
Open Xcode, <your project>, Build Settings, Build Active Architecture Only and change to <NO> for Debug and Release. Architectures set/leave in Standard Architecture -$(ARCHS_STANDART), important is next step:
Valid Architecture: armv7, armv7s, amr64, amr64e, ADD here x86_64 and if you need add i386 for Debug and Release. (String: armv7, armv7s, amr64, amr64e, x86_64)

Swift 5.0-5.1,Xcode 11
打开 Xcode,<your project>,Build Settings,Build Active Architecture Only 并更改为 <NO> 以进行调试和发布。架构在标准架构 -$(ARCHS_STANDART) 中设置/离开,重要的是下一步:
有效架构:armv7、armv7s、amr64、amr64e,在此处添加 x86_64,如果您需要添加 i386 以进行调试和发布。(字符串:armv7、armv7s、amr64、amr64e、x86_64)

Choose any simulator in your simulator list and BUILT IT. DONE. 

在您的模拟器列表中选择任何模拟器并构建它。完毕。 

I hope it is works for you.

我希望它对你有用。




Description of Architecture:

架构描述:

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

armv64:iPhoneX、iPhone 5s-8、iPad Air — iPad Pro

armv7 : iPhone3Gs-5c, iPad WIFI(4th gen)

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

armv6 : iPhone — iPhone3G

armv6 : iPhone — iPhone3G

-the above if for real devices

-以上如果是真实设备

i386 : 32-bit simulator

i386 : 32 位模拟器

x86_64 : 64-bit simulator

x86_64:64 位模拟器

回答by emrcftci

Please check your Schemebe sure to run correct scheme.

请检查您Scheme是否确保运行正确的方案。

And then you should open XCode > -Your Main Target- > Build Active Architecture Onlyand set 'NO' for build on all the architectures.

然后你应该打开XCode > -Your Main Target- > Build Active Architecture Only并设置“NO”以在所有架构上构建。

Options:

选项:

YES- If set to yes, then Xcode will detect the device that is connected, and determine the architecture, and build on just that architecture alone.

YES- 如果设置为 yes,则 Xcode 将检测连接的设备,并确定架构,并仅在该架构上进行构建。

NO- If set to no, then it will build on all the architectures.

NO- 如果设置为 no,那么它将建立在所有架构上。

回答by AshWinee Dhakad

I have added two architectures i386 and x86_64. And set Yes to "Build Active Architecture Only". It works for me to build on every simulator devices.

我添加了两个架构 i386 和 x86_64。并将 Yes 设置为“仅构建活动架构”。它适用于我在每个模拟器设备上构建。

enter image description here

在此处输入图片说明

回答by mgyky

If you want to automate the process for your project you can try the script below that I use in my framework projects.

如果你想为你的项目自动化这个过程,你可以尝试下面我在我的框架项目中使用的脚本。

It works for both Objective-Cand the Swiftprojects. I tested on iOS and tvOS too.

它适用于Objective-CSwift项目。我也在 iOS 和 tvOS 上进行了测试。

For more detail and updates please follow my repo page.

有关更多详细信息和更新,请关注我的repo 页面

Script

脚本

#!/bin/sh

######################
# Globals
######################

# Avilable Platforms/Architectures 
# macosx | iphoneos | iphonesimulator | appletvos | appletvsimulator | watchos | watchsimulator
DEVICE_ARCH="iphoneos"
DEVICE_SIM_ARCH="iphonesimulator"

FRAMEWORK_NAME="${PROJECT_NAME}"
DEVICE_LIBRARY_PATH=${BUILD_DIR}/${CONFIGURATION}-${DEVICE_ARCH}/${FRAMEWORK_NAME}.framework
SIMULATOR_LIBRARY_PATH=${BUILD_DIR}/${CONFIGURATION}-${DEVICE_SIM_ARCH}/${FRAMEWORK_NAME}.framework
UNIVERSAL_LIBRARY_DIR=${BUILD_DIR}/${CONFIGURATION}-Universal
SUCCESS=true
EXIT_MESSAGE=$?
ROW_STRING="\n##################################################################\n"

echoPaths() 
{
    echo "${ROW_STRING}"
    echo "DEVICE_LIBRARY_PATH: ${DEVICE_LIBRARY_PATH}"
    echo "SIMULATOR_LIBRARY_PATH: ${SIMULATOR_LIBRARY_PATH}"
    echo "UNIVERSAL_LIBRARY_DIR: ${UNIVERSAL_LIBRARY_DIR}"
    echo "${ROW_STRING}"
}

checkSuccess()
{
    if [[ -z $EXIT_MESSAGE ]]; then
        SUCCESS=false
        exitWithMessage
        exit 1
    fi
}

exitWithMessage() 
{
    echo "${ROW_STRING}"

    if [ "$SUCCESS" = true ] ; then
        echo "\n\n\n  Completed with Success! "
    else
        echo "\n\n\n  Completed with Errors! Please check line above for details:"
        echo "${EXIT_MESSAGE}"
    fi

    open /tmp/${FRAMEWORK_NAME}_archive.log
    echo "\n  For more details you can always check the /tmp/${FRAMEWORK_NAME}_archive.log file.  \n\n\n"
    echo "${ROW_STRING}"
}

######################
######################
######################



######################
# Starting the logging
######################

exec > /tmp/${FRAMEWORK_NAME}_archive.log 2>&1
echo "\n ? Starting the Universal Framework work... \n\n\n"

######################
# Echo the PATHS
######################

echoPaths

######################
# Make sure the output directory exists
######################

mkdir -p "${UNIVERSAL_LIBRARY_DIR}"

######################
# Step 1: Build Frameworks
######################

echo "${ROW_STRING}"
echo "\n\n\n  Step 1-1: Building for ${DEVICE_SIM_ARCH}"
echo "${ROW_STRING}"

EXIT_MESSAGE="$(xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" -configuration ${CONFIGURATION} -sdk ${DEVICE_SIM_ARCH} ONLY_DEVICE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" -UseModernBuildSystem=NO clean build)"

checkSuccess

echo "${ROW_STRING}"
echo "\n\n\n  Step 1-2: Building for ${DEVICE_ARCH} \n\n\n"

EXIT_MESSAGE="$(xcodebuild BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" -workspace "${WORKSPACE_PATH}" -scheme "${TARGET_NAME}" ONLY_DEVICE_ARCH=NO -configuration ${CONFIGURATION} -sdk ${DEVICE_ARCH}  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" -UseModernBuildSystem=NO clean build)"

checkSuccess


######################
# Step 2. Copy the frameworks
######################

echo "${ROW_STRING}"
echo "\n\n\n  Step 2: Copy the framework structure for ${DEVICE_ARCH}"
echo "${ROW_STRING}"

cp -R "${DEVICE_LIBRARY_PATH}" "${UNIVERSAL_LIBRARY_DIR}/"



######################
# Step 3. Create the universal binary
######################

echo "${ROW_STRING}"
echo "\n\n\n  Step 3: The LIPO Step"
echo "${ROW_STRING}"

lipo -create "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -output "${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}"



######################
# Step 4. Copy the Swiftmodules. 
# This step is necessary only if your project is Swift. For the Swift framework, Swiftmodule needs to be copied in the universal framework. 
######################
echo "${ROW_STRING}"
echo "\n\n\n  Step 4: Copy the Swiftmodules"
echo "${ROW_STRING}"


if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then

cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo

else 
    echo "?? Couldn't any Swift module file for SIMULATOR!"
fi


if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then

cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo

else 
    echo "?? Couldn't any Swift module file for DEVICE!"
fi



######################
# Step 5. Remove the existing copy of the Universal framework and copy the framework to the project's directory
######################

echo "${ROW_STRING}"
echo "\n\n\n  Step 5 Copying in the project directory"
echo "${ROW_STRING}"

rm -rf "${PROJECT_DIR}/${FRAMEWORK_NAME}.framework"

yes | cp -Rf "${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework" "${PROJECT_DIR}"


######################
# Step 6. Open the project's directory
######################

echo "${ROW_STRING}"
open "${PROJECT_DIR}"
echo "${ROW_STRING}"



######################
# Step 7. Open the log file on Console application
######################

exitWithMessage

Best.

最好的事物。

回答by Miguel Perera

For me it was a setting missing. In Xcode go to: File->Workspace Settings . In Build System change it to "Legacy Build system".

对我来说,这是一个设置缺失。在 Xcode 中转到: File->Workspace Settings 。在 Build System 中,将其更改为“Legacy Build System”。

Run it again and copy the new Framework

再次运行并复制新的Framework