544

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

18
  • 31
    Not to be too mr. obvious but have you tried a full clean and build?
    – Kalel Wade
    Apr 7, 2015 at 20:01
  • 31
    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
    Apr 7, 2015 at 20:02
  • 3
    Also you might have to use quotations marks for the import: #import "Social/Social.h"
    – Martin R
    Apr 7, 2015 at 20:04
  • 4
    I changed Deployment Target from 11 to 10, but forget it in Podfile platform :ios, '10.0'. That was solution. Oct 15, 2018 at 15:27
  • 1
    A very simple problem can be that: when you drag the framework from say your desktop in to Xcode, it does NOT copy it to the relevant project directory, but just leaves it on the desktop. Ensure you have "copy to location ..." when you drag it in!
    – Fattie
    Jul 26, 2019 at 10:48

87 Answers 87

879

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

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

8
  • 3
    I tried this as a holy grail. Funny. Who knows but exiting then reopening the workspace actually worked as well. Clean, then build.
    – mondousage
    Jun 20, 2016 at 18:33
  • 1
    This happened to me after Xcode crashed and I selected 'reopen' application from the bug report. I will know better next time.
    – user1162328
    Jul 8, 2019 at 8:42
  • Also applies to building on the command line (our problem): xcodebuild -workspace yourproject.workspace.
    – Ben Butzer
    Jun 5, 2020 at 12:46
  • I often used xed folder, and it looks like this reads the xcodeproj file instead of xcworkspace. When I explicitly used open -a finder folder` and clicked xcodeproj, it worked fine. No xcode 'clean' required. Nov 4, 2020 at 20:59
  • 1
    For those who are building from cli using xcodebuild, specifying the workspace i.e., -workspace <>, did the trick.
    – mr5
    May 19, 2022 at 7:06
412

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.

9
  • 9
    Thanks. I had to do this in my project build settings rather than my target build settings Aug 28, 2015 at 10:09
  • 10
    The trick for me was finding a path to the framework to use in the Framework Search Paths. ${TARGET_BUILD_DIR}/YourFrameworkName.framework works well for me. See also stackoverflow.com/questions/32816507/… Sep 28, 2015 at 6:46
  • 1
    That worked, thanks. I didn't need to change the path, just setting to recursive fixed it May 15, 2016 at 21:32
  • 3
    NOTE ON THE FIX: $(SRCROOT) only worked for me when I added it to the Framework Search Path FOR THE PODS PROJECT.
    – addzo
    Dec 1, 2017 at 20:04
  • 1
    $(SRCROOT) , recursive, also for "Header Search Paths" worked for me!
    – Sasho
    Oct 6, 2018 at 6:10
122
+50

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

5
  • 1
    In my case, the subproject had only Debug and Distribution and its parent project was trying to build for Release. Solution was to make a copy of Distribution in the child project and rename that copy Release.
    – olivaresF
    Feb 14, 2018 at 18:47
  • 2
    This led to me finding the issue, but I solved it by adding to the framework search paths in my custom configurations since I didn't want to touch a 3rd party subproject :)
    – DeFrenZ
    Jun 18, 2018 at 9:46
  • This is the correct answer in case you have a subproject (in my case subproject with a framework), because when .framework is built it is located in a different build folder when configurations do not match that's why Xcode can't find framework (module)
    – smartwolf
    Nov 14, 2020 at 21:22
  • I have project with structure like this(not like in answer - AppUI and AppDomain live without nested to App): -App.xcodeproj -AppUI.xcodeproj -AppDomain.xcodeproj So this answer works for me when I did so and added AppUI.framework, AppDomain.framework to App in section Frameworks, Libraries and Embedded content
    – Taras
    Oct 15, 2022 at 5:00
  • Man thank you, one long day of frustration saved!
    – Siempay
    Feb 9 at 19:54
52

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

0
47

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

1
  • 1
    Yeah for me use_frameworks wasn't even in my Podfile so I added it
    – PhoenixB
    Mar 19, 2019 at 5:48
36

The following steps worked for me.

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

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

Enter image description here

3
  • Also mentioned by Chris Prince. Dec 29, 2017 at 5:55
  • 1
    This really helped me thanks. But reminder for other readers: After doing this, delete your Derived folder, and restart Xcode. Sep 28, 2021 at 12:56
  • For me works when I added SnapKit to: 1) Frame Search Paths -> "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit" 2) Header Search Path -> "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit/SnapKit.framework/Headers" 3) Other C Flags -> framework "${PODS_CONFIGURATION_BUILD_DIR}/SnapKit"
    – Taras
    Feb 2, 2023 at 9:27
21

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.

1
  • 1
    Our framework didn't have the AdHoc configuration we used for the project - which meant it didn't build together with the project.
    – Johan
    Jan 30, 2017 at 16:43
21

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.

1
  • 2
    For some reason this isn't shown in xcode 9.1 even when it's present. Right click on your framework > Show In Finder > and make sure your modulemap is there. If you're using a manual framework in a pods project, rebuild your pods if you've just added a new manual framework or updated an existing one. Nov 6, 2017 at 16:35
21

Xcode compile error: No such module

//Swift
import <module_name> //No such module '< module_name >'

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]

3
  • 1. Open ProjectName.xcodeworkspace 2. Product -> Build Dec 18, 2019 at 13:30
  • What solved it for me was opening with .xcworkspace instead of .xcodeproj Aug 8, 2022 at 7:00
  • In my case, I had to add a module to the Link Binary With Libraries. Feb 22 at 11:30
17

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.

3
  • 1
    I just did it as you told me, and it doesn't work :/ Apr 7, 2015 at 20:23
  • 1
    Then you may be facing a different problem that just looked the same as the one I encountered. :-/ Apr 7, 2015 at 20:26
  • I was having the same issue with a Cocoapod and deleting the files in ModuleCache did the trick for me.
    – HolySamosa
    Apr 6, 2017 at 22:03
17

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

1
  • 1
    It's the trick for old projects on m1. Because old Pods uses old architecture, they may not support the m1 on their old versions.
    – Umut ADALI
    May 15, 2022 at 13:19
15

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

1
  • 2
    You saved my plenty of hours. Actually to speed up my code 12, I unchecked Find implicit Dependencies as per some solutions over stackoverflow. But after reopening the project its starting to complain.
    – Amit Kumar
    Sep 23, 2020 at 12:58
15

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.
1
  • 1
    In my case besideds #3 I also had to check that Excluded Architectures matched both modules (TriviaApp and Social in this example). Hope it helps!
    – Alejandro
    Jan 12, 2023 at 5:05
12

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.

9

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.

2
  • For me, removing the following from my podFile fixed it: installer.pods_project.build_configurations.each do |config| config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" end Jan 15, 2023 at 2:53
  • I tried all the solutions above but only this one worked for me. Thanks. Jan 16 at 6:55
8

Resolve issue of Webview of apple iOS xcode Version 12.3 (12C33)

METHOD 1:Simply Do 3 steps:

  1. Open project with .xcodeproj

  2. Quit Xcode

  3. Reopen project from .xcworkspace

Done

METHOD 2: Simply Do 3 steps:

  1. Open podfile -> Add use_frameworks! in podfile -> save pod file

  2. Quit Xcode

  3. run pod install

  4. Reopen project from .xcworkspace

All Done

2
  • does not fix it
    – IulianT
    Nov 22, 2021 at 9:28
  • 1
    This worked for me! But the problem came back again as soon as I did "clean build folder" Dec 7, 2021 at 21:43
7

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.

0
7

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

6

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.

1
  • It worked only once, then when i run goes to the same issue of not finding the module.
    – nycdanie
    Apr 21, 2016 at 0:15
6

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.

5

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.

5

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.

0
5

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.

0
5

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.

0
5

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

5

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.

1
  • shared_pods depreacated
    – famfamfam
    Jun 7, 2021 at 9:23
4

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.

0
3

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.