Fix: No Such Module Social Error in Xcode Swift Projects

Fix: No Such Module Social Error in Xcode Swift Projects

Written by

in

Quick answer: The No such module error usually means Xcode cannot find the framework on disk, not that it is missing from the project. Set the Framework Search Paths build setting to the folder containing the framework (e.g. $(SRCROOT) recursive), and make sure you opened the .xcworkspace file rather than the .xcodeproj when CocoaPods is in use.

Why this happens

No such module 'Social' is a Swift compiler error, not a linker error. It fires during the compile phase, before your code ever gets linked against the framework binary. That distinction matters: adding the framework to Linked Frameworks and Libraries and Embedded Binaries only affects linking and packaging. The Swift compiler resolves import Social by searching the directories listed in the Framework Search Paths build setting. If that setting is empty or points somewhere the framework is not, the compiler reports the module as missing even though the framework is visibly sitting in your project navigator.

A second, very common cause: opening the wrong project file. If your project uses CocoaPods or any other tool that generates a workspace, you must open the .xcworkspace file. Opening the bare .xcodeproj compiles the project without the workspace-level search paths and framework references, and the compiler cannot find modules that the workspace would have provided.

A third cause specific to Objective-C frameworks consumed from Swift: the framework must be built and indexed before Swift can import it. A stale or corrupted build cache, or a scheme that builds targets in the wrong order, can leave the compiler looking for a module image that does not exist yet.

How to fix it

1. Set Framework Search Paths

This is the most reliable fix when the framework lives inside your project directory:

  1. Select your project in the navigator, then select the target.
  2. Open Build Settings and search for framework search paths.
  3. Double-click the setting and add the path to the folder containing the framework. If the framework sits in your project root, use $(SRCROOT).
  4. Change the dropdown from non-recursive to recursive so subfolders are searched too.
  5. Clean and rebuild (Shift+Cmd+K, then Cmd+B).
FRAMEWORK_SEARCH_PATHS = $(SRCROOT) recursive

If the framework lives in a subfolder such as Frameworks/, point the search path at that folder directly — recursive search from $(SRCROOT) also works but scans more directories than necessary.

2. Open the .xcworkspace, not the .xcodeproj

If you use CocoaPods (or Carthage with workspace integration), the workspace file is the real entry point:

  1. Close Xcode completely.
  2. In Finder, double-click YourProject.xcworkspace — not YourProject.xcodeproj.
  3. Rebuild.

The two files look nearly identical in Finder, which is why this bites people constantly. If the workspace file does not exist, run pod install from the project directory to generate it.

3. Clean the build cache and DerivedData

Stale module caches can survive a normal clean:

  1. Product → Clean Build Folder (Shift+Cmd+K).
  2. Quit Xcode.
  3. Delete the DerivedData folder for the project:
rm -rf ~/Library/Developer/Xcode/DerivedData/YourProject-*
  1. Reopen the project and rebuild.

This forces Xcode to re-index and rebuild the module map for the framework.

4. Verify the framework is actually in the build

For an Objective-C framework imported from Swift, confirm the wiring is complete:

  • The framework appears under General → Frameworks, Libraries, and Embedded Content with Embed & Sign (for a dynamic framework) or Do Not Embed (for a static one that is only linked).
  • Your bridging header exists and the target’s Objective-C Bridging Header build setting points to it, e.g. $(SRCROOT)/YourProject/YourProject-Bridging-Header.h.
  • The bridging header imports the framework’s umbrella header, not the module:
#import <Social/Social.h>

Note that with a proper bridging header you often do not need import Social in Swift at all — the bridging header makes the Objective-C types visible project-wide. If the bridging header is doing its job, you can delete the import line and the error disappears with it.

5. Check the scheme build order

If the framework is built by a target in the same workspace (common for in-house frameworks), make sure your app target depends on it:

  1. Open Product → Scheme → Edit Scheme.
  2. Select Build and confirm the framework target is checked and listed before the app target.

If the framework target is missing from the scheme, add it via the + button. Without an explicit dependency, the compiler can run before the framework’s module image exists.

How to prevent it

  • Always open the .xcworkspace when CocoaPods is present; consider adding a note to your README so teammates do not open the .xcodeproj.
  • Keep third-party frameworks in a Frameworks/ folder and set one recursive search path at $(SRCROOT) so new frameworks are found automatically.
  • Prefer Swift Package Manager or CocoaPods over manually dragged-in frameworks — both manage search paths for you.
  • After updating Xcode or switching branches, clean DerivedData before assuming a project is broken.

FAQ

Why does the error mention a module if the framework is only Objective-C?

Xcode generates a module map for any framework built with the modern build system, so Swift can import it like a Swift module. If that generated module image is not on disk yet — because of build order or search paths — Swift reports No such module.

Does adding the framework to Embedded Binaries fix this error?

No. Embedding affects what gets packaged into the app bundle at build time; it does not tell the Swift compiler where to find the framework during compilation. Framework Search Paths is the setting the compiler actually reads.

Should I use recursive or non-recursive search paths?

Recursive is safer for manual framework management because it finds frameworks in subfolders, but it can slow builds slightly and occasionally pick up the wrong copy of a framework with a duplicate name. If you know the exact folder, a non-recursive path to that folder is the cleaner choice.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.