525

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

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
alexandresecanove
  • 5,725
  • 4
  • 15
  • 14
  • 31
    Not to be too mr. obvious but have you tried a full clean and build? – Kalel Wade Apr 07 '15 at 20:01
  • That was my first reaction :) – alexandresecanove Apr 07 '15 at 20:02
  • 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 07 '15 at 20:02
  • You are right, it was just a "desesperate code", because nothing worked. – alexandresecanove Apr 07 '15 at 20:04
  • 3
    Also you might have to use quotations marks for the import: `#import "Social/Social.h"` – Martin R Apr 07 '15 at 20:04
  • It can't be because Social is a framework so it is with <>, but I tried what you said and it doesn't work at all :/ – alexandresecanove Apr 07 '15 at 20:08
  • 4
    same error with CocoaPods 'no such module error' in xcode. – AsimRazaKhan Sep 15 '16 at 14:53
  • Using Xcode 8.1, I got the same issue. Problem was, the framework was build with Swift 3.0 instead of 3.0.1 ;-) – d4Rk Nov 10 '16 at 13:09
  • I have faced this issue in watch app and resolved it by: http://stackoverflow.com/questions/39944607/apple-watch-no-such-module-alamofire/40738216#40738216 – Shrawan Nov 22 '16 at 09:46
  • Clean and Build – Shree Prakash Jan 07 '17 at 09:34
  • Watch your derive data and check that the framework is being copied into your /Frameworks folder under your project in the iphonesimulator. If it's not, then you're not properly linking it or the binary is not compatible. If it is, then it's a path problem and you need to check your framework search paths. – TheCodingArt Apr 22 '17 at 12:39
  • I still get the error. I can build the project, deploy it to my development devices but when I go to archive the project (to get the ipa file), I get 'No such module 'SQLite'. If i comment out all references to this module, it complains about another module (e.g. IQKeyboardManagerSwift). I've checked the folders (e.g. Debug-iphoneos and Release-iphoneos under the library directory) and they are identical. – Paul Dec 15 '17 at 01:25
  • 4
    I changed Deployment Target from 11 to 10, but forget it in Podfile `platform :ios, '10.0'`. That was solution. – Artur Guseynov Oct 15 '18 at 15:27
  • pod install it worked for me. – Ananta Prasad Apr 17 '19 at 06:52
  • 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 '19 at 10:48
  • I was stuck on this problem with XCode 10.3, I think I've tried all the solutions I found on the internet and in this thread for about 4 days. It could be weird, but I fixed it by changing the project path: I simply placed the project 2 or 3 folder outer than before. It seems that the Swift compiler could not reach that nested folder level. – Milore Aug 22 '19 at 20:18
  • LOL - I had this problem with Xcode 12.4 and SQP AppCenter. I had to close and open the xcworkspace several times. From the third one the import worked... – Freddy Apr 13 '21 at 13:29
  • You can try the top answer of this ask. [link here](https://stackoverflow.com/questions/65978359/xcode-error-building-for-ios-simulator-but-linking-in-dylib-built-for-ios-f) – Bomi Chen May 11 '21 at 08:00
  • https://stackoverflow.com/a/69927210/10632772 – Asfar Hussain Siddiqui Dec 09 '22 at 10:26

82 Answers82

847

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

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

capikaw
  • 12,232
  • 2
  • 43
  • 46
  • 2
    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 '16 at 18:33
  • 5
    9pm using fastlane, specified the gym(project: ---) instead of gym(workspace: ----) Thanks! – RickiG Nov 30 '16 at 20:11
  • 1
    This happened to me after Xcode crashed and I selected 'reopen' application from the bug report. I will know better next time. –  Jul 08 '19 at 08:42
  • I reinstalled XCODE and I was getting this error because I was opening the app via the recently opened projects. Closed the project, File -> Open -> select the xcworkspace file and everything worked. – Dpedrinha Jan 25 '20 at 16:32
  • Also applies to building on the command line (our problem): xcodebuild -workspace yourproject.workspace. – Ben Butzer Jun 05 '20 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. – Ben Butterworth Nov 04 '20 at 20:59
  • 7
    coming from andriod and this amuses me. – hjchin Jan 14 '21 at 14:07
  • 31
    Year 2021 and this answer is still so true. hahaha – androidStud Jan 15 '21 at 05:42
  • Also using Fastlane, docs suggesting using project, but switching to workspace solved for me. – Mike Collins Apr 05 '21 at 19:03
  • insert WTF gif here – coorasse Aug 11 '21 at 08:56
  • please tell me this is a joke, It's Friday and its afternoon, I only got this error afternoon, I guess I'm gonna wait till Monday – Praveen G Dec 24 '21 at 08:20
  • Reading this for 3 hours and still insisting on opening xcodeproj, trying many non working solutions and thinking you have misspelling here. – Taady Jan 03 '22 at 01:23
  • 1
    For those who are building from cli using `xcodebuild`, specifying the workspace i.e., `-workspace <>`, did the trick. – mr5 May 19 '22 at 07:06
  • 2022 oct, this one solved the issue – Elmar Oct 04 '22 at 06:17
  • https://stackoverflow.com/a/69927210/10632772 – Asfar Hussain Siddiqui Dec 09 '22 at 10:26
  • I missed setting Xcode Server's "project or workspace" file selection to the xcworkspace file instead of the default project file. Thank you! – Mostafa ElShazly Dec 23 '22 at 23:11
  • The year 2023 and this answer is still working. :) – Osama Buzdar Jun 12 '23 at 05:32
  • OMG yes! I tried to extract a part of app into a framework, and thought I could get away with adding that project into app project. Nope. Two separate projects (in subfolders), one workspace, open only that one. – Tomáš Kafka Jun 16 '23 at 14:16
  • Many of us are working after 1am and or on Friday afternoon hahaha – ellen Jul 03 '23 at 05:25
407

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.

LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
terhechte
  • 4,142
  • 1
  • 12
  • 3
  • 8
    Thanks. I had to do this in my project build settings rather than my target build settings – Binary Pulsar Aug 28 '15 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 http://stackoverflow.com/questions/32816507/how-do-i-create-a-development-framework-in-ios-including-swift – Chris Prince Sep 28 '15 at 06:46
  • @malhal 1. Make 'Embedded Content Contains Swift Code' - Yes Under Build Settings 2. Set the framework search path to $(SRCROOT) [Note: only include path don't include xxx.framework] – iosLearner Jan 27 '16 at 10:28
  • 1
    That worked, thanks. I didn't need to change the path, just setting to recursive fixed it – Ben Sullivan May 15 '16 at 21:32
  • So I'm including my framework as a sub-project, then I have it built as a dependency, my solution was to use ../../build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to find the correct framework – malhal Jun 06 '16 at 21:42
  • 13
    Had to do this in `Project Build Settings` instead of `Target Build Settings`. – Maksim Jul 05 '16 at 13:09
  • If like me you tried installing a prebuilt framework with the Swift package manager, then it sounds like you're gonna have a bad time: http://stackoverflow.com/questions/41013538/swift-error-failed-to-get-module-my-app-from-ast-context – joel.d Jan 29 '17 at 21:39
  • (The easy fix is to use Cocoapods or Carthage to install the framework instead, since those build the framework locally. – joel.d Jan 29 '17 at 21:39
  • 1
    @joel.d Adding a dependency to your project's workflow is never a solution, it's an introduction to more problems. That's never a good answer. – TheCodingArt Apr 22 '17 at 12:40
  • I am running into similar issue. Adding the framework search path to match a working sample app that includes a prebuilt framework does not work. Adding the SRCROOT and even $(SRCROOT)/FW_PATH/ make no difference. When using a framework containing module definitions, a prebuilt lib and header files, what other settings should be checked? So far I am not seeing the difference between working sample app and new app I am including the framework into. – bduhbya Jun 15 '17 at 20:46
  • 829
    I fixed this by going to the bathroom. When I got back it was working. I'm pretty sure I tried everything in this thread, dunno exactly what did the job. I also prayed at some point. – nmdias Oct 30 '17 at 10:35
  • 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 01 '17 at 20:04
  • 1
    Did not work for me. My project builds and deploys to devices fine. However, when I try to archive my project, I get this error. Please help. – Paul Dec 15 '17 at 02:01
  • Try this: comment out the `import` line, build (lots of errors), uncomment the `import` line and build. This seems to "kickstart" the compiler into seeing what's in front of it's nose. – David James Jul 19 '18 at 10:17
  • This doesn't work for me. https://forums.swift.org/t/whats-happening-that-i-receive-always-no-such-module-module-name/14752 – Francis Rodrigues Jul 25 '18 at 20:08
  • 1
    $(SRCROOT) , recursive, also for "*Header Search Paths*" worked for me! – Sasho Oct 06 '18 at 06:10
  • No such module appear in 1 of my Pod Project Targets. How to set their framework search path to the ROOT project? $(SRCROOT) seem didn't work – Đức Bùi Mar 17 '20 at 10:18
  • 3
    I have tried everything... literally everything. Even going to the bathroom as @nmdias suggested :D ... No solutions till now... :( – Subrata Mondal Apr 16 '20 at 06:53
  • 1
    Lol.. For me too. I had done everything. But I was opening the xproj instead of the workspace: Make sure you opened the .xcworkspace file in Xcode and not just the .xcodeproj file. – Daniel Tome Apr 22 '20 at 06:01
  • OMG! **The real fix (for me at least) was: 1. Firstly,** reset App's `FRAMEWORK_SEARCH_PATHS` to be just `$(inherited)` and nothing custom. **2. Secondly,** Add to Framework both `SUPPORTS_MACCATALYST = YES;` and `DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;` (i.e. click it's project, then *Editor* menu's *Add Build Setting > Add User-Defined Setting* option). **3. Lastly,** we needed to change `LD_DYLIB_INSTALL_NAME` (i.e. *Dynamic Library Install Name*) setting to `$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)` value. **Note:** skip second step if not using `Catalyst` – Top-Master May 18 '21 at 12:34
112

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

Groot
  • 13,943
  • 6
  • 61
  • 72
  • 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 '18 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 '18 at 09:46
  • Thank you! I've had 3 configurations in my main project. So, I've done the same for framework and it helped. – daxh Jun 19 '19 at 13:50
  • Any clues about how to make Xcode build specific config of nested subproject? Don't wanna rename subprojects configs, as it becomes too connected of adding new configs to main project – Dren Oct 30 '19 at 12:03
  • This worked for me as my project had 3 configurations, which were renamed from the default "Debug" and "Release" configurations. I updated my framework to have the same 3 configurations, built the framework, and everything worked as expected. – Yuri Nov 06 '19 at 22:30
  • 4
    Didn't even read the whole answer, but as soon as I seen the focus on the Configurations it clicked for me. Images worth more than 1,000 words. +10 – Maciek Czarnik Feb 20 '20 at 10:18
  • I have literally wasted 3 days on this topic. Wow what an answer – Avinash B Jun 03 '20 at 18:51
  • 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 '20 at 21:22
  • I keep coming back to this answer over the years and too bad I can't upvote more than once. – Genki Aug 17 '21 at 19:20
  • 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 '22 at 05:00
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

LinusGeffarth
  • 27,197
  • 29
  • 120
  • 174
Mike K
  • 961
  • 8
  • 15
46

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

nburk
  • 22,409
  • 18
  • 87
  • 132
35

The following steps worked for me.

  1. Quit xcode
  2. Run "pod update" in terminal
  3. Open .xcworkspace and build again.
Alien
  • 15,141
  • 6
  • 37
  • 57
john raja
  • 509
  • 4
  • 8
  • 1
    These steps worked for me ... Thanks... I ran "Pod install" but was not getting "Module XXX not found away.. " but upon quitting XCode and then reopening Workspace helped me .. – Ash Aug 14 '18 at 17:34
  • 1
    My problem is after add new build configuration and scheme I got "Module not found..." Quit Xcode doesn't work, after `pod install` it works. – William Hu Nov 01 '18 at 09:09
  • This worked for me. Any explanation as to why this fixes the problem? –  Mar 05 '19 at 21:19
  • 1
    It worked for me. After reopening projectname.xcworkspace, need to clean and rebuild again to make it work. – Prashant Aug 30 '19 at 09:16
  • https://stackoverflow.com/a/69927210/10632772 – Asfar Hussain Siddiqui Dec 09 '22 at 10:26
27

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

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Krutarth Patel
  • 3,407
  • 6
  • 27
  • 54
  • Also mentioned by [Chris Prince](https://stackoverflow.com/questions/29500227/getting-error-no-such-module-using-xcode-but-the-framework-is-there#comment53470207_31077255). – Franklin Yu Dec 29 '17 at 05:55
  • 1
    This really helped me thanks. But reminder for other readers: After doing this, delete your Derived folder, and restart Xcode. – Eray Alparslan Sep 28 '21 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 02 '23 at 09:27
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.

mcsheffrey
  • 508
  • 4
  • 16
  • 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. – Christopher Larsen Nov 06 '17 at 16:35
  • 1
    Thanks! I did create the file myself and it worked: framework module NAME { umbrella header "NAME.h" export * module * { export * } } – Sjoerd Perfors Mar 02 '18 at 16:11
  • This turned out to be my problem. In the framework, I found "Defines Module" was set to NO; changing that to YES created the ModuleMap file and folder as above. – Aaron Vegh Jan 14 '21 at 15:55
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.

mikepj
  • 1,256
  • 11
  • 11
  • This worked for me. I set my main project Build Config back to Release (from Distribution) and so now it matches the sub project. All working. Thank you! – Charlie S Oct 19 '16 at 14:15
  • 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 '17 at 16:43
19

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]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
  • 1. Open ProjectName.xcodeworkspace 2. Product -> Build – Kuvonchbek Yakubov Dec 18 '19 at 13:30
  • @yoAlex5 Can you please elaborate the swift static library part. I am getting the same no module error for a custom static library I created and when tried to implement in test project, couldn't import it. I have copied the "library search paths" value to "import paths". – Sushree Swagatika May 09 '20 at 22:13
  • 1
    For me the case was `.xcodeproj was opened instead of .xcworkspace`, quick search saved some crucial development minutes. Thanks @yoAlex5. – Sauvik Dolui Oct 26 '21 at 08:31
  • What solved it for me was opening with `.xcworkspace instead of .xcodeproj` – Doilio Matsinhe Aug 08 '22 at 07:00
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.

Brad Brighton
  • 2,179
  • 1
  • 13
  • 15
15

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

Nike Kov
  • 12,630
  • 8
  • 75
  • 122
  • 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 '20 at 12:58
15

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

boa_in_samoa
  • 587
  • 7
  • 16
  • 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 '22 at 13:19
14

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.
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
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.

cenkarioz
  • 569
  • 7
  • 7
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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
  • 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 – Mostafa ElShazly Jan 15 '23 at 02:53
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vikram jeet singh
  • 3,416
  • 2
  • 21
  • 22
  • This answer helped. When trying to set it up for MBProgress, I ended up following the directions at http://ios-support.blogspot.com/2017/04/how-to-use-mbprogresshud-progress-in.html, which was very similar. – Vette Jun 06 '19 at 14:50
7

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

joliejuly
  • 2,127
  • 1
  • 21
  • 24
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.

harshitpthk
  • 4,058
  • 2
  • 24
  • 32
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.

zeeawan
  • 6,667
  • 2
  • 50
  • 56
6

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

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.

Jordan Smith
  • 10,310
  • 7
  • 68
  • 114
  • 1
    Same applies if you choose "My Mac" when building an iOS project. I don't know why Xcode even allows this ... – Klaas Apr 26 '17 at 10:03
  • Thank you! So obvious now, but the error was making me look for more complicated solutions! – Dan Messing Mar 16 '19 at 00:16
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.

Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
pawan singh
  • 79
  • 1
  • 1
  • If you have a NEW question, please ask it by clicking the [Ask Question](//stackoverflow.com/questions/ask) button. If you have sufficient reputation, [you may upvote](//stackoverflow.com/privileges/vote-up) the question. Alternatively, "star" it as a favorite and you will be notified of any new answers. – Alessandro Cuttin Aug 16 '17 at 15:28
  • @pawan singh you saved several hours for me, thank you! – Dmitry Senkovich Aug 28 '19 at 07:16
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.

berbie
  • 978
  • 10
  • 13
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

viki donald
  • 96
  • 1
  • 7
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.

avgrammer
  • 409
  • 5
  • 13
  • shared_pods depreacated – famfamfam Jun 07 '21 at 09:23
  • exactly what I've met. Bravo. Interestingly that before cleaning module cache it was compilable and runnable, for some reason, and did brake only week after I've added new target – iago849 Dec 19 '22 at 10:43
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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
qwerty_so
  • 35,448
  • 8
  • 62
  • 86
4

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.

Magoo
  • 2,552
  • 1
  • 23
  • 43
3

I just removed the frameworks by removing references and again added them.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Soham Ray
  • 215
  • 2
  • 4
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.

Daniel Jones
  • 1,032
  • 10
  • 18
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

Vojta
  • 810
  • 10
  • 16
3

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

michel
  • 83
  • 1
  • 7
3

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

MFA
  • 537
  • 2
  • 6
  • 16
3

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

2

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.

ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
2

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.

maddy
  • 4,001
  • 8
  • 42
  • 65
2

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.

Ronaldo Albertini
  • 1,329
  • 20
  • 24
2

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.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Vlad Pulichev
  • 3,162
  • 2
  • 20
  • 34
2

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

EsmaGo
  • 141
  • 1
  • 7
2

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.

agirault
  • 2,509
  • 20
  • 24
2
  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 :-)

Gathua Kiragu
  • 131
  • 1
  • 4
2

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

Ammar Mujeeb
  • 1,222
  • 18
  • 21
2

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.

enter image description here

Dakata
  • 1,227
  • 2
  • 14
  • 33
2

The only thing that worked for me using M1 machine was to run Xcode using Rosetta.
Without that, I was able to run the app only on real device, but not on the iOS simulator.
Building the app can be a little slower but it resolves the issue definitely.
If you dont know how to turn the Rosetta on, here are the steps:

  • Quit Xcode
  • Find Xcode in Applications folder, right click on it and press Get Info
  • Tick the Open using Rosetta as it is shown on the image below
  • Open Xcode again and run your app

Not sure if deleting derived data and cleaning the project is necessary, but you can also do it.

1

stackich
  • 3,607
  • 3
  • 17
  • 41
1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
markiyanm
  • 348
  • 1
  • 5
  • 18
1

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

kalafun
  • 3,512
  • 6
  • 35
  • 49
1

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.

iHulk
  • 4,869
  • 2
  • 30
  • 39
1

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.

Yigit Alp Ciray
  • 163
  • 1
  • 7
1

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

1

Sometimes you have to install the Pods.

  1. Open terminal
  2. cd project
  3. pod install
  4. Open .xcworkspace and
  5. Build is succesful
Umit Kaya
  • 5,771
  • 3
  • 38
  • 52
1

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
iljn
  • 889
  • 9
  • 7
1

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

Charlie S
  • 4,366
  • 6
  • 59
  • 97
1

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

Chuck Krutsinger
  • 2,830
  • 4
  • 28
  • 50
1

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.

instanceof
  • 1,404
  • 23
  • 30
1

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.

andrew54068
  • 1,326
  • 14
  • 29
1

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

Radek
  • 581
  • 4
  • 12
1

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.

John
  • 964
  • 8
  • 21
1

I find the solution for my case some minutes ago. The project was an objective c project with cocos2d framework. None of the previews solution works.

Just I delete the VALID_ARCH row at User-Defined at Build Settings and the project start to build on simulator.

0

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.

Jensie
  • 611
  • 5
  • 9
0

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.

Community
  • 1
  • 1
Adam Preble
  • 2,162
  • 17
  • 28
0

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.

JFed-9
  • 297
  • 3
  • 17
0
  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
Nimantha
  • 6,405
  • 6
  • 28
  • 69
0

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

user3007870
  • 31
  • 1
  • 4
0

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.

Coder95
  • 159
  • 2
  • 13
0

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.

SafeFastExpressive
  • 3,637
  • 2
  • 32
  • 39
0

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.

Zaporozhchenko Oleksandr
  • 4,660
  • 3
  • 26
  • 48
0

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.

rolling_codes
  • 15,174
  • 22
  • 76
  • 112
0

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.

Mark Dail
  • 501
  • 4
  • 10
0

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.

Anton
  • 1,655
  • 15
  • 16
0

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.

Nate Whittaker
  • 1,866
  • 15
  • 14
0

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

barola_mes
  • 1,532
  • 2
  • 13
  • 16
0

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
Broski
  • 257
  • 4
  • 7
0

Make sure your project folder is not in iCloud Drive.

enter image description here

enter image description here

Lev Martens
  • 190
  • 7
0

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.

Mahmut K.
  • 707
  • 1
  • 8
  • 20
0

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.

enter image description here

This post helped me to understand how to add new build configurations, since going to Editor -> Add configuration was greyed out

Adding a build configuration in Xcode

0

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

RyadPasha
  • 333
  • 3
  • 9
0

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" 
Bill Chan
  • 3,199
  • 36
  • 32
0

If you use CocoaPods, try to comment out (#) the new pod, run pod install, bring it back and pod install again. Sometimes somewhy pod script does not produce correct dependencies (or is in conflict with running xCode?) so it -sometimes- does help

iago849
  • 1,818
  • 1
  • 13
  • 9
0

You added the dependency (module) to your pod, but without a version (either specific or range). Please define the version, run pod install, and open the .xcworkspace file not .xcodeproj file

ItSNeverLate
  • 533
  • 7
  • 8
0

For those who have multiple targets, check if framework was added on the right target. (in Frameworks, Libraries, and Embedded Content).

nsinvocation
  • 7,559
  • 3
  • 41
  • 46
0

For me what resolved the problem was selecting the pods module (from the left of where you choose a target device) and run build on it. Once the building was done, I switched back to my own module, build it and there was no error anymore.

Rados
  • 481
  • 4
  • 17
-3

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.

elk_cloner
  • 2,049
  • 1
  • 12
  • 13