[ios] Getting error "No such module" using Xcode, but the framework is there

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?

Error module

Project

Linkes Frameworks, Libraries

Header bridge

This question is related to ios xcode swift

The answer is


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. enter image description here


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

Error is gone. enter image description here


I was getting this issue because I set the wrong target in the podfile (the project itself rather than the UITests section).


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

Result: enter image description here


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.


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.


In the Target's build settings Set the "Framework Search Paths" to $(inherited) and recursive. [1]


It is compile time error. You can get it in a lot of case:

  • .xcodeproj was opened instead of .xcworkspace

  • module.modulemap

Objective-C, Library/Framework Target.

If you host your own library or framework please make sure that it has module.modulemap file and the headers from it 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. 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 foundabout

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 should point to .swiftmodule

Linked Frameworks and Libraries

consumer -> static framework

Add a Static framework to this section

Find Implicit Dependencies

When you have an implicit dependency but Find Implicit Dependencies was turned off

CocoaPods

pod deintegrate
pod install

UI Test Bundle

for App Target where used additional dependency from CocoaPods. To solve it use inherit![About] in Podfile

[Recursive path]


1 - In your podfile, remove the pod that creates a problem, and save the file 2 - Run pod install 3 - Re-add the pod, save the file 4 - Re-run pod install

Problem should be solved.

HIH


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.


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.


If you have more than one project in workspace, you need to:

1) add new configuration to all of the projects

2) product -> clean

3) delete derived data

4) pod install in terminal

5) build your project.

Hope it helps to someone.


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.

Happy coding :)


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.


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.


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.


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 :)


What worked for me is this 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.


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 enter image description here


Sometimes pod deintegrate and then pod install helps me, too.


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.


I went through the above solutions but unfortunately, nothing helped me. What I did later

  1. close the project.
  2. From the terminal, go the project directory and run below command:
  3. git reset --hard origin/master (i wanted to change in master branch.)
  4. git fetch
  5. git checkout master
  6. git pull origin master
  7. Open the project(of course from Xcode)
  8. Clean build and remove derived data.
  9. 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.


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.


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.


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.


Please compare this screenshot with your build setting. It may this work. Go to the framework search path:

Enter image description here


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.


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.


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.


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.


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:

    • Find Objective-c bridging Header under Swift compiler - Code Generation (If you don't find Swift compiler here, probably add a new Swift file to the project)
    • Drag and drop the library header file from left side to bridging header (see image attached)enter image description here
  • 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.


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.

Configuration setup in "parent" project

Configuration setup in 1st sub project

Configuration setup in 2nd sub project


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.


Sometimes you have to install the Pods.

  1. Open terminal
  2. cd project
  3. pod install
  4. Open .xcworkspace and
  5. Build is succesful

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.

Example showing directory structure of SwiftyJSON.framework

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.


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


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.


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.


In rare cases this error might be fixed by setting proper platform here [ProjectNavigator]->[Project]->[Target]-> (Architectures) BaseSDK

enter image description here

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.

enter image description here


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.


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.


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


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.


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.


There are several potential misconfigurations the issue can arise for,

  1. Please confirm that you have opened the .xcworkspace but not .xcodeproj file. Also make sure you have build Social first before you build TriviaApp.
  2. Make sure that iOS Deployment Target is set same for all modules with main app. For example is TriviaApps deployment target is set to 9.0, Socials deployment target also need to be set to 9.0.
  3. 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 configurations Debug, Release, ReleasePremium. Also make sure that the archive configuration is set same for both TriviaApp and Social. i.e. if your TriviaApps archive scheme is set to ReleasePremium, your Socials archive scheme also need to be set into ReleasePremium.
  4. Please assure that you do not need to import Social in each .swift files when its already added in the Bridging-Header.h.
  5. In case of issue came from Pod files, make sure you have uncommented #use_frameworks! into use_frameworks! from you Podfile. Sometime re installing pod works if Social has any dependency on pods.
  6. If none of the above steps works, delete your derived data folder and try re building.

If all the above methods did not work for you like in mine case. There was no problem in the previous day but in next morning I faced the same error. I just removed the frameworks by removing references and again added them. I know this may sound silly, but voila it worked.


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.


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.


I am still not able to make archive from xcode but fastlane did the work for me


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.


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.


For me going to Edit Scheme -> Run, and changing the debug configuration to Debug from Release fix the problem.


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.


  1. Check whether you are using latest version of xcode.(If not update to the latest version supported by your device).
  2. Install cocoapods with sudo gem install cocoapods
  3. Run pod setup

I can confirm that the above steps solved my error :-)


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.


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.

enter image description here

Click on your project in the scheme icon (see image below)

enter image description here

Then you should see your framework of focus listed:

enter image description here

Click Manage Schemes.

Then you should see something like this:

enter image description here

Tick the box for your framework, click AutoCreate Schemes now, then close.

Then try to import your framework/pod again.

It worked for me.


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.


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

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.


Be sure, that Find implicit Dependencies in Build options in Scheme is on!


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


The following steps worked for me.

  1. Quit xcode
  2. Run "pod update" in terminal
  3. Open .xcworkspace and build again.

In General => Linked Frameworks and Libraries, I added my ./Pods/Pods.xcodeproj and it did the trick


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.

enter image description here


Just for completing with another possibility, this error might happen when the option "Find Implicit Dependencies" is unchecked. Go to Edit Scheme -> Build.

enter image description here

Then check this options.

enter image description here


Make sure your project folder is not in iCloud Drive.

enter image description here

enter image description here


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

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


In case it's Friday afternoon or anytime after 1am:

Opening xcodeproj instead of xcworkspace will cause an error like this...


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?