413
votes

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

30
Not to be too mr. obvious but have you tried a full clean and build?Kalel Wade
If the framework header is already included in the bridging header file then you don't have to import it in the Swift source file.Martin R
Also you might have to use quotations marks for the import: #import "Social/Social.h"Martin R
same error with CocoaPods 'no such module error' in xcode.AsimRazaKhan
I changed Deployment Target from 11 to 10, but forget it in Podfile platform :ios, '10.0'. That was solution.Artur Guseynov

30 Answers

368
votes

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.

664
votes

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

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

73
votes

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

47
votes

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

40
votes

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

24
votes

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

Enter image description here

23
votes

The following steps worked for me.

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

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.

18
votes

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.

13
votes

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.

11
votes

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.

10
votes

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

9
votes

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.
7
votes

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.

7
votes

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 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(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

[Recursive path]

6
votes

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.

6
votes

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.

6
votes

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

5
votes

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.

5
votes

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.

4
votes

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.

4
votes

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.

4
votes

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

4
votes

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.

3
votes

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.

3
votes

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.

3
votes

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

3
votes

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

3
votes

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

3
votes

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