Getting error "No such module" using Xcode, but the framework is there
IosXcodeSwiftIos Problem Overview
I'm currently coding in Swift, and I've got an error:
> No such module Social
But I don't understand, because the module is in my project, declared in "Linked frameworks and Libraries" and in "Embedded Binaries".
The frameworks is in Objective-C, so I wrote a Bridge Header for it.
Please, how can I make Xcode recognize the framework?
Ios Solutions
Solution 1 - Ios
In case it's Friday afternoon or anytime after 1am:
Opening xcodeproj
instead of xcworkspace
will cause an error like this...
Solution 2 - Ios
I'm not sure why this happens, but one way to solve your issue is to go into your build settings and defining the Framework Search Paths to a folder which contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT)
and set it to recursive.
Solution 3 - Ios
Make sure that the naming of you configurations in the sub projects matches that of the "parent" project. If the configuration naming don't match exactly (case-sensitive), Xcode will abort the archive process and show the error "No such module ..."
That is, if you have a "parent" project with a configuration named "AppStore" you must make sure that all subprojects also have this configuration name.
See my attached screenshots.
Solution 4 - Ios
I am not quite sure why Martin R's answer in the comments for the question is so disregarded:
Make sure that you tried simply skipping import of the framework as it is already added with the bridging header.
Hope this helps
Solution 5 - Ios
I had the same issue using Cocoapods and Swift. I didn't notice the following lines in the Podfile:
# Uncomment this line if you're using Swift
# use_frameworks!
So, all I had to do was change it to:
# Uncomment this line if you're using Swift
use_frameworks!
...aaand it worked :)
Solution 6 - Ios
Please compare this screenshot with your build setting. It may this work. Go to the framework search path:
Solution 7 - Ios
The following steps worked for me.
- Quit xcode
- Run
"pod update"
in terminal - Open
.xcworkspace
and build again.
Solution 8 - Ios
In my case, after many attempts to figure out what I was doing wrong importing a framework I eventually discovered that the framework itself was the problem. If you are not getting your framework from a trusted source you should inspect the framework and ensure that it contains a Modules folder with a module.modulemap file inside it. If module.modulemap is not present, you will get the "No such module 'MyFramework'" error.
If the Modules folder is missing the "MyFramework.swiftmodule" folder then the framework will be found but Xcode won't know about its contents so you will get different errors.
Solution 9 - Ios
I was experiencing this problem as well. The fix for me was that the Archive schemes between the two projects didn't match. I have an xcworkspace with a framework project and an app project. The problem was that in the Archive scheme for my app, I was using a different Build Configuration than the framework was using for it's Archive scheme. I set both Build Configurations to Release, and that fixed the issue.
Solution 10 - Ios
Assuming the Framework really is there and in the path, etc... delete the ~/Library/Developer/Xcode/DerivedData/ModuleCache directory (and clean the project and delete the project-specific derived data for good measure).
When you do the standard cleanup, the ModuleCache directory doesn't get rebuilt.
Solution 11 - Ios
Be sure, that Find implicit Dependencies
in Build options in Scheme is on!
Solution 12 - Ios
No such module Compile error
It is compile time error. You can get it in a lot of case:
.xcodeproj
was opened instead of.xcworkspace
module.modulemap
or.swiftmodule
[About]
Objective-C Library/Framework Target
make sure that generated binary contains module.modulemap
file and it's headers are located in Build Phases -> Headers section
Framework Search Paths
consumer -> framework
If you try to build an app without setting the Framework Search Paths
(consumer). After setting the Framework Search Path
to point to the framework resources, Xcode will build the project successfully. However, when you run the app in the Simulator, there is a crash for reason: Image not found
about
It can be an absolute path or a relative path like $(SRCROOT)
or $(SRCROOT)/..
for workspace
Import Paths
Swift consumer -> Swift static library
The Import Paths
(consumer) should point to .swiftmodule
Find Implicit Dependencies
When you have an implicit dependency but Find Implicit Dependencies
was turned off
CocoaPods
- Check if this dependency is existed in a target
pod deintegrate
pod install
CocoaPods UI Test Bundle
for App Target
where used additional dependency from CocoaPods. To solve it use inherit!
[About] in Podfile
Solution 13 - Ios
What worked for me is thishttps://stackoverflow.com/questions/30809206/cocoapods-pod-install-modules-cannot-be-imported?rq=1">this</a> solution to another question. Closing Xcode and reopening the project as workspace.
Go to your project folder and open .xcodeworkspace
file.
Once you open the workspace (instead of project), Pods should appear as top level project in Project Navigator.
Solution 14 - Ios
There are several potential misconfigurations the issue can arise for,
- Please confirm that you have opened the
.xcworkspace
but not.xcodeproj
file. Also make sure you have buildSocial
first before you buildTriviaApp
. - Make sure that iOS Deployment Target is set same for all modules with main app. For example is
TriviaApp
s deployment target is set to9.0
,Social
s deployment target also need to be set to9.0
. - Make sure your main module (
TriviaApp
) and your used framework (Social
) have same set of configurations. i.e. If your Project has three configurations,Debug
,Release
,ReleasePremium
than your Social framework also need to have three configurationsDebug
,Release
,ReleasePremium
. Also make sure that the archive configuration is set same for bothTriviaApp
andSocial
. i.e. if yourTriviaApp
s archive scheme is set toReleasePremium
, yourSocial
s archive scheme also need to be set intoReleasePremium
. - Please assure that you do not need to import
Social
in each.swift
files when its already added in theBridging-Header.h
. - In case of issue came from Pod files, make sure you have uncommented
#use_frameworks!
intouse_frameworks!
from youPodfile
. Sometime re installing pod works ifSocial
has any dependency on pods. - If none of the above steps works, delete your derived data folder and try re building.
Solution 15 - Ios
For me Build Active Architecture Only was set to Yes for the selected configuration. This did the trick:
Select "Pods" from the left project navigator > Select "Build Settings" > Build Active Architecture Only to No
Solution 16 - Ios
I also encountered the same error a few days back. Here's how I resolved the problem:
The error is "module not found"
-
Create Podfile in your root project directory
-
Install cocoapods (a dependency manager for Swift and iOS projects)
-
Run pod install
-
Go to Project Build Settings:
-
Create a new bridging header file: e.g TestProject-Bridging-Header.h and put under Swift Compiler → Objective-C Generated Interface Header Name (ref, see the image above)
-
In TestProject-Bridging-Header.h file, write #import "Mixpanel/Mixpanel.h"
-
In your Swift file the code should be: Import Mixpanel (i.e name of library)
That's all.
Solution 17 - Ios
Ok, how the same problem was resolved for me was to set the derived data location relative to the workspace directory rather than keeping it default. Go to preferences in xcode. Go to locations tab in preferences and set Derived data to Relative. Hope it helps.
Solution 18 - Ios
I was getting same error for
import Firebase
But then noticed that I was not adding pod to the main target section but only adding to Test and TestUI targets in Podfile.
With the command
pod init
for an xcode swift project, the following Podfile is generated
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'MyApp' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for MyApp
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
So, need to make sure that one adds pods to any appropriate placeholder.
Solution 19 - Ios
If you're building for a platform like tvOS, make sure you have an Apple TV (i.e. matching) simulator selected.
Building a tvOS app with an iOS simulator selected gave me exactly this error. Spent the better part of an hour looking for all sorts of build issues... doh.
Solution 20 - Ios
I was getting the same error as i added couple of frameworks using Cocoapods
. If we are using Pods in our project, we should use xcodeworkspace
instead of xcodeproject
.
To run the project through xcodebuild, i added -workspace <workspacename>
parameter in xcodebuild
command and it worked perfectly.
Solution 21 - Ios
In my case the app the IPHONEOS_DEPLOYMENT_TARGET was set to 9.3 whereas in my newly created framework it was set to 10.2
The implicit dependencies resolver ignored my new framework because the requirements of the target platform are higher than the app requirements.
After adjusting the framework iOS Deployment Target to match my application deployment target the framework compiled and linked successfully.
Solution 22 - Ios
Sometimes pod deintegrate
and then pod install
helps me, too.
Solution 23 - Ios
I found that the Import Paths
in the Build Settings
was wrong for a custom (MySQL) module. After pointing that to the right direction the message was gone.
Solution 24 - Ios
TL;DR: Check your Podfile for target-specific shared_pods
After beating my head against the wall and trying literally every single other answer posted here over the last week, I finally found a solution.
I have two separate targets - one for release and one for development. The development target was created long after the release target, which lead me to forget some setup steps for that target.
I was able to get my project to compile properly using my release target, but my development target was having an issue.
After looking at my Podfile for the twentieth time, I noticed that I only had the following, under my shared_pods
definition:
target 'Release' do
shared_pods
end
What I needed to do was add my second target to my Podfile, and that fixed the issue:
target 'Release' do
shared_pods
end
target 'Development' do
shared_pods
end
Hopefully this saves someone a few days of frustration.
Solution 25 - Ios
I fixed this with
Targets -> General -> Linked frameworks and libraries
Add the framework which should be at the top in the Workspace
folder. Pain in the arse.
Solution 26 - Ios
I just deleted my cocoapod. Then, I did a pod install to remove it. Then, I just added it back into my podfile and re-installed it. That made it work. Not sure why.
Solution 27 - Ios
I had already installed pods. Build worked without any problems when I builded application on my device, but archive didn't work. I just run:
pod install
no new pods were installed, just .xcodeproj file got regenerated and archive started working
Solution 28 - Ios
In General => Linked Frameworks and Libraries, I added my ./Pods/Pods.xcodeproj
and it did the trick
Solution 29 - Ios
In Xcode 10.1 the solution for me was to change the build system on Workspace Settings in the File menu. It is by default set to New Build System, changed that to Legacy Build System and that did the trick.
Solution 30 - Ios
I was having a similar issue with xcode 10.3. xCode was unable to recognise files from pods. Here I have solved this way:
- Go to Build Phase
- Link Binary with Libraries
- Add framework from pods (in my case EPSignature.framwork)
- Clean & build the project
Solution 31 - Ios
As for xCode 12 and simulators,
the error might disappear when you navigate to Pods.xcodeproj in project navigator, and in build settings under the 'Excluded Architectures', for every Debug and Release, chose 'Any iOS Simulator SDK' with value arm64.
Solution 32 - Ios
My issue was with multiple targets. I solved it with below links: configure pod file right way and fix build settings
Hope some one will find it helpful.
Solution 33 - Ios
If you are using Carthage, the frameworks in building setting usually stay in
$(PROJECT_DIR)/Carthage/Build/iOS
If you run carthage update --platform ios --no-build
(to save time) the files inside Build folder will not be reacreated, then the modules will no available to XCode.
In my case, I have run carthage update --platform ios
, then my problem was solved.
Solution 34 - Ios
- Check whether you are using latest version of xcode.(If not update to the latest version supported by your device).
- Install cocoapods with
sudo gem install cocoapods
- Run
pod setup
I can confirm that the above steps solved my error :-)
Solution 35 - Ios
Solution 36 - Ios
For what it's worth (I'm new to this using Xcode 7.2/Swift 2), but I noticed that just having the .swift file from the library in the project directory automatically gives you access to it and does not need the using statement.
Example: I'm using SwiftyJSON and just having the SwiftyJSON.swift file in the project was all I needed. The using
statement was actually giving me the 'no such module' error and taking it out resolved it, and it works fine.
Solution 37 - Ios
I just removed the frameworks by removing references and again added them.
Solution 38 - Ios
I had similar problem with loading FacebookSDK, I added ~/Documents/FacebookSDK (search where your frameworks are) to Framework search paths in Build settings and after that I was able to import the FBSDKShareKit module
Solution 39 - Ios
IF you have done everything above and still nothing worked for you then try adding $(inherited)
in Framework search path of your target's build setting.
Solution 40 - Ios
The solution for me was. Inside of the targets -> Build Settings -> Framework Search Paths and adding $(inherited). However if it is a cocoapods your answer probably inside of output in terminal.
Solution 41 - Ios
Just for completing with another possibility, this error might happen when the option "Find Implicit Dependencies" is unchecked. Go to Edit Scheme -> Build.
Then check this options.
Solution 42 - Ios
Sometimes you have to install the Pods.
- Open terminal
- cd project
- pod install
- Open .xcworkspace and
- Build is succesful
Solution 43 - Ios
I had this problem while developing a custom Pod. Found that I just needed to specify the dependency in my Procfile:
Pod::Spec.new do |s|
# ... other declarations
s.dependency 'Alamofire', '~> 4.3'
end
Solution 44 - Ios
I was getting this issue because I set the wrong target in the podfile (the project itself rather than the UITests section).
Solution 45 - Ios
This is what finally worked for me. Its pretty lame that I had to do all this, but this was the only thing I could find that worked.
After ensuring the library was listed under linked framework and libraries
. If its not there you can click the +
and hopefully see your framework/pod listed.
Click on your project in the scheme icon (see image below)
Then you should see your framework of focus listed:
Click Manage Schemes.
Then you should see something like this:
Tick the box
for your framework, click AutoCreate Schemes now
, then close
.
Then try to import your framework/pod again.
It worked for me.
Solution 46 - Ios
In my case, the problem was simply that some of the projects that used the framework had a deployment target iOS version previous to the deployment target iOS version of the framework. Once I changed the framework deployment target iOS version, the error went away.
Solution 47 - Ios
In my case, I try every suggestion above still not working. I just copy the file's content which show the error without the import stuff and paste it to another file with same imports and comment the error file out. Run the project again it worked, then I delete the original error file and create a file with same name and make it's content back again with the same imports. I think in my case I just figure a way to let it be able to link those imports once and it should be fine.
Solution 48 - Ios
Surprised this even worked. My solution was to go to ...
Build Settings -> Framework Search Paths -> highlight debug -> press delete -> it should automatically fill out a path. -> Do the same for release
Solution 49 - Ios
For me this occurred on RxSwift and the issue was I had fixed it to 3.0.0 in the Podfile. Removing the version restriction and update the pods upgraded it to 3.1.0 which fixed it.
Solution 50 - Ios
This error can also be caused by the framework lacking a module map. If the framework you are trying to import is yours, check for compiler warnings on the framework itself. In my case my framework was building and in place, but there was a build warning:
> warning: no umbrella header found for target 'MyFramework', module map will not be generated
By resolving this warning (which related to the framework header not matching the module name), I was able to import the framework.
Solution 51 - Ios
In my case, I just had to reload the project. I had used command-line to clone my project, but it didn't install the submodule correctly. To remedy, I cloned the project through XCode, and everything works. Just make sure you back up any changes first.
Solution 52 - Ios
- In your podfile, remove the pod that creates a problem, and save the file
- Run pod install
- Re-add the pod, save the file
- Re-run pod install
Solution 53 - Ios
In my case with project on swift 4 libraries weren't compiled so it wasn't possible to find them and import. The solution was to set compile version for libraries of cocoapods as swift 3.2
Solution 54 - Ios
I installed the pod Fakery, the pod got added under my Pods file, however when I tried to use it I got the same error. Problem was, I didn't build it, after building it , the swift compiler threw a few errors in the Fakery swift files that some functions have been renamed, it also provided fixes for them too. After resolving all those compiler issues , build succeeded and I was able to use the module. So swift language compatibility was the problem in my case.
Solution 55 - Ios
My problem (this time) was that I used an outdated version of the library in my Podfile.
I used:
pod 'LBTAComponents', '~> 0.1.9'
which didn't work, but when I changed it to:
pod 'LBTAComponents', '~> 1.0.2'
it worked.
Solution 56 - Ios
I win the award for dumbest cause of the "No such module" error. In my case I build the included framework by hand, and copy it into my project directory. My framework search paths were set correctly, and the framework was added to the project correctly.
When I archived the framework I was building, I used "Show in Finder" to take me to the release folder in derived data. But I didn't noticed that the folder contains only an alias to the framework, not the framework itself. The original framework remained in my derived data directory, so later when I cleared derived data the framework was deleted, but my project didn't know that.
Re-archiving the framework, following the alias to the actual framework, and copying that to my project directory worked.
Solution 57 - Ios
If it's just simple project, without cocoapods, like I had, u can try to move your framework inside your project directory and re-link. I had it on a desktop, but linked and "import MyFramework" made an error. After moving it inside project directory and linking it again, it worked.
Solution 58 - Ios
If you have more than one project in workspace, you need to:
-
add new configuration to all of the projects
-
product -> clean
-
delete
derived data
-
pod install
in terminal -
build your project.
Solution 59 - Ios
I actually solved this much more easily by adding to the end of build-debug.xconfig
#include "../Pods/Target Support Files/Pods-IAP/Pods-IAP.debug.xcconfig"
And to the end of build-release.xconfig
#include "../Pods/Target Support Files/Pods-IAP/Pods-IAP.release.xcconfig"
since those files already define PODS_ROOT
and the related build variables.
Solution 60 - Ios
Another possible cause in XCode 10 can be the Supported Platforms
sometimes gets changed to macOS
and the Valid Architectures
gets changed to i386 x86_64
for the Pods Projects. Assuming the project is for iOS, then select the Pods Project and change the Supported Platforms
to iOS
and the Valid Architectures
to arm64 arm64e armv7 armv7s
, You could do each of the Targets, however that takes longer if you have more than one Pod. Also the Swift version
of frameworks in written Swift sometimes gets set to the wrong version.
Solution 61 - Ios
One more suggestion for Xcode 10+ and projects that 1. created with Xcode version <10, 2. Contain a subproject with a framework that the main project depends on. The issue is that Xcode will place the compiled framework in the directory specified in the subproject, which is likely different from the main project build directory.
Check File > Project Settings. Now, click "Advanced..." and select something other than "Legacy" as the build path, for example, "Unique". In that case Xcode will put all builded components into one folder and it should be able to find the "missing" module.
Solution 62 - Ios
For me, I fixed it be replacing any tilde (~) characters in my Custom Paths with $(HOME)
. Custom Paths are located in the Xcode preferences under the Locations tab.
Solution 63 - Ios
For me going to Edit Scheme -> Run, and changing the debug configuration to Debug from Release fix the problem.
Solution 64 - Ios
Most of the other answers are for CocoaPods or Carthage users. If you are NOT using either of these, but just want to drop a framework in your project and link against it, it will need to be in a framework search path.
The system frameworks are already in the search path (namely /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${version}.sdk/System/Library/Frameworks/
). If the ones you are trying to use are not in this path, you need to add their path to FRAMEWORK_SEARCH_PATHS
in your Build Settings.
Why doesn't XCode knows where to find it without this even though the framework on your left panel has a location and full path listed in the Identity and Type in the right panel? That... I don't know.
Solution 65 - Ios
In rare cases this error might be fixed by setting proper platform here [ProjectNavigator]->[Project]->[Target]-> (Architectures) BaseSDK
When creating a framework I've chosen accidentally wrong template (as I was creating macOS framework previously) because it was set to like my previous choice. When adding a target it is easy to miss out configuring platform so double check that.
Solution 66 - Ios
I am still not able to make archive from xcode but fastlane did the work for me
Solution 67 - Ios
After trying all the ideas on this thread, it worked when I updated cocoapods.
$ pod --version
$ 1.0.0 // should have been 1.10.0
You should update cocoapods
gem which cocoapods
Solution 68 - Ios
Solution 69 - Ios
Go to the folder where the project is and delete the plugin causing the error there. For me, I deleted the Google Mobile Ads Sdk folder that caused the error and the problem was fixed. It was enough to include it with pods.
Solution 70 - Ios
Sazzad Hissain Khan's 3. option adding the same "Build Configurations" in the App's framework than in the App solved my "Unknow module" issue.
This post helped me to understand how to add new build configurations, since going to Editor -> Add configuration was greyed out
https://stackoverflow.com/questions/19842746/adding-a-build-configuration-in-xcode
Solution 71 - Ios
For me the answer was to go to the Targets, first check do the target name and the project name match, if they do, then go to General -> Frameworks and add them manually. When I did that, I clean build the app, and everything was working fine. Unfortunately, none of the answers before resolved my issue, so maybe this can help you as well.
Solution 72 - Ios
For me the issue was because the project file was missing this file "coursesX.xcworkspace"
When I added it and re-opened the project everything worked well
Solution 73 - Ios
Resolve issue of Webview of xcode Version 12.3 (12C33)
Simply Do 3 steps:
-
Open project with
.xcodeproj
-
Quit Xcode
-
Reopen project from
.xcworkspace
All Done
Solution 74 - Ios
In my case:
The issue only occurs on Xcode 12.4, but not Xcode 13.
one of the framework of test target gives this error after I rebuild that framework for arm64 simulator support (in XCFramework format). I fixed it by update the path in Framework Search Paths
"$(SRCROOT)/Carthage/Build/WireTesting.xcframework/ios-x86_64-simulator"
to
"$(SRCROOT)/Carthage/Build/WireTesting.xcframework/ios-arm64_x86_64-simulator"
Solution 75 - Ios
This can also happen when the framework does not compile properly.
Open the framework project in Xcode and see if Product → Build
succeeds.
Once you have fixed the build errors in the framework, open the main project and see if you can import the framework.
Solution 76 - Ios
I went through the above solutions but unfortunately, nothing helped me. What I did later
- close the project.
- From the terminal, go the project directory and run below command:
- git reset --hard origin/master (i wanted to change in master branch.)
- git fetch
- git checkout master
- git pull origin master
- Open the project(of course from Xcode)
- Clean build and remove derived data.
- Build the project again.
yes, I know some commands are redundant. But spending 2 days and pulling my hair out is much worse than those steps.