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

IosSwiftXcodeXcode11

Ios Problem Overview


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:

Could not find module 'MyCustomFramework' for target 'x86_64-apple-ios-simulator'; found: 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.

Ios Solutions


Solution 1 - Ios

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.

Solution 2 - Ios

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

Solution 3 - Ios

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'

Solution 4 - Ios

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

Solution 5 - Ios

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

Solution 6 - Ios

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.

Solution 7 - Ios

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

Solution 8 - Ios

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

Solution 9 - Ios

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.

Solution 10 - Ios

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.

Solution 11 - Ios

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

Solution 12 - Ios

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.

Solution 13 - Ios

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.

Solution 14 - Ios

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.

Solution 15 - Ios

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

Solution 16 - Ios

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

Solution 17 - Ios

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.

Solution 18 - Ios

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionOleshkoView Question on Stackoverflow
Solution 1 - IoswillhessView Answer on Stackoverflow
Solution 2 - IosSerg FugolView Answer on Stackoverflow
Solution 3 - IosBob RossView Answer on Stackoverflow
Solution 4 - IosAshWinee DhakadView Answer on Stackoverflow
Solution 5 - IosAmrit GiriView Answer on Stackoverflow
Solution 6 - IosemrcftciView Answer on Stackoverflow
Solution 7 - IosWasi SadmanView Answer on Stackoverflow
Solution 8 - IosgngrwzrdView Answer on Stackoverflow
Solution 9 - IosM Abubaker MajeedView Answer on Stackoverflow
Solution 10 - Iosbrian.clearView Answer on Stackoverflow
Solution 11 - IosAkshuView Answer on Stackoverflow
Solution 12 - IosJunho LeeView Answer on Stackoverflow
Solution 13 - IosmgykyView Answer on Stackoverflow
Solution 14 - IosSiddharth KamariaView Answer on Stackoverflow
Solution 15 - IosTolga İskenderView Answer on Stackoverflow
Solution 16 - Iosislam XDeveloperView Answer on Stackoverflow
Solution 17 - IosSiddharth ProthiaView Answer on Stackoverflow
Solution 18 - IosMiguel PereraView Answer on Stackoverflow