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

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

找不到目标“ x86 _ 64-apple-ios-Simulator”的模块“ MyCustomFramework”; 找到: arm64,arm64-apple-ios

在框架项目的“有效体系结构”中是否需要做一些更改?

更新: 我不能选择任何正确的答案,因为我的框架实在太小了(一个类,几个方法) ,而且几乎没有使用,所以我决定摆脱它,把这几个方法移到 main project 中。

118993 次浏览

Please check your Scheme be sure to run correct scheme.

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

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.

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

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

To do that I did the following:

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

Xcode⁩ ▸ ⁨DerivedData⁩ ▸ ⁨Your Project ▸ ⁨Build⁩ ▸ ⁨Products⁩ ▸ ⁨Release-iphonesimulator

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

Xcode⁩ ▸ ⁨DerivedData⁩ ▸ ⁨Your Project ▸ ⁨Build⁩ ▸ ⁨Products⁩ ▸ ⁨Release-iphoneos⁩

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

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)

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

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

6) From folder

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.

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_STANDARD), important is next step:
Valid Architecture: armv7, armv7s, arm64, arm64e, ADD here x86_64 and if you need add i386 for Debug and Release. (String: armv7, armv7s, arm64, arm64e, 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

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

armv6 : iPhone — iPhone3G

-the above if for real devices

i386 : 32-bit simulator

x86_64 : 64-bit simulator

Alternative Solution

This question is actually about Creating Custom Framework. Even years after posting, people still visiting the page fixing similar issues. I think we need to head up for other solutions as well.

After Xcode 11 now Xcode fully supports using and creating binary frameworks in Swift. Simultaneously support devices and Simulator with the new XCFramework bundle type. XCFrameworks support the binary distribution of Swift and C-based code (C, C++, Objective-C). A single XCFramework can contain a variant for the simulator, and for the device. This means you can ship slices for any of the architectures, including the simulator, any Apple OS, and even separate slices for UIKit and AppKit apps.

You can check the repo if you're interesting the using a library for creating Custom Framework.

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

Run it again and copy the new Framework

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.

enter image description here

For the XCode-12 Valid Architectures has been moved under User-Defined option at the very bottom as VALID_ARCHS

I encountered this issue on my M1 MacBook.

To solve this I've added to following lines to my host app Podfile:

post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

Edit: Adding this line as well helped with runtime issues:

config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'

For the new M1 Mac with Xcode 12 I encountered the same issue. I was able to solve it by setting Build Active Architecture Only = 'Yes' and adding VALID_ARCHS = arm64 armv7 arm64-ios-simulator (essentially excluding x86_64 and x86_64-ios-simulator architecture) in the Build Settings.

enter image description here

This is because all your library are not flexible with m1 chip. so right click on xcode, get info and tick open as rosetta. open your project, clean and build. Finally, run your project as before :D

For all pods on mac M1 chip you need to add 'x86_64-apple-ios-simulator' support in architectures in build setting. So process will be like,

  1. go to pods, select that the error target add x86_64-apple-ios-simulator in it. enter image description here

  2. Set "build active architecture". to No in pods specific target.

enter image description here

It will solve this problem. More in project setting. you can set "build active architecture" according to your requirement.

At this time i am using xcode 12.5

For this i have edited User-Defined option at the very bottom with VALID_ARCHS

Select the target and go to Build Setting

Click the plus icon and you will see

enter image description here

Add VALID_ARCHS and $(ARCHS_STANDARD) value

or you can use -> armv7, armv7s, arm64, arm64e, x86_64, i386

enter image description here

if you think @willhess answer is hard you can use this script

open Build Phases -> click plus button -> New Run Script Phase and add below code

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


mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"


cp -a "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework"
"${UNIVERSAL_OUTPUTFOLDER}/"




SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi




lipo -create -output
"${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}"
"${BUILD_DIR}/${CONFIGURATION}-
iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}"
"${BUILD_DIR}/${CONFIGURATION}-
iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"




cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework"
"${PROJECT_DIR}"


open "${PROJECT_DIR}"

Then build simulator and any ios device, your project folder will be open and your fat framework will be there

in my case show this alert because Pod 'MessageKit', '~> 3.3.0' have this problem but just change Deployment info To iOS 13 For MessageKit All Done

Since Valid Archs isn't available for Xcode 12, you will create a user defined setting by hitting + and typing VALID_ARCHS with the x86_64 and additional architectures.

This is all I needed in my Podfile:

post_install do |pi|
pi.pods_project.targets.each do |t|
t.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end

I had to set 'Build Active Architecture Only' from Debug:Yes/Release:No to Debug:No/Release:No for any Pod target showing the error

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

where PODNAME is the pod throwing the error when you compile.

Delete your pods and install pods with this command "arch -x86_64" pod install

That error means your custom framework has been built for any ios device (an actual device) and you are trying to use this custom framework on a simulator where your app is being tested.
The solution is very simple. Just rebuild your custom framwork for simulator you want to test it out(e.g. Iphone 13 simulator) not for 'Any iOS Device'. And replace the old framework with the newly compiled framework.

You need to change the Architecture settings for both Project and Pods project files.

Select project settings then write Architecture in the search bar. After that change the `Build Active Architecture Only" to false NO for all targets.

Then add x86_64-apple-ios-simulator to the Architectures propriety.

You need to do the same for the Pods project setting.

Set the 'Build Active Architecture Only' to 'No'. Please look at the image below.

enter image description here

I was facing this issue for RxSwift while running unit tests. Changing the build settings of Pods project and setting the Build Active Architecture to No, fixed the issue for me enter image description here

I found quite easy solution For Mac M1 Chip, Xcode 14.1. My project has both Pod And SPM

  • Go to Applications > Xcode > Get Info > checked "Open using Rosetta"
  • File > Packages > Reset Package Caches
  • Close Xcode, run Pod Install again
  • Open Xcode and build

Thats's it all.