You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

构建依赖CocoaPods模块的第三方框架时遇“Module not found”错误求助

Fixing "Module 'PureLayout' not found" with CocoaPods, React Native, and a Manual Framework SDK

Hey there, let's work through this tricky issue you're facing! The core problem here is that without use_frameworks!, CocoaPods installs PureLayout as a static library (no module support by default), but the third-party .framework you're manually integrating expects to find a module named PureLayout. Here are the most reliable fixes, ordered from easiest to most involved:

1. Try use_modular_headers! Instead of use_frameworks!

React Native has gotten better at supporting use_modular_headers! (which enables module support for static libraries without using dynamic frameworks). This is probably your best first step:

  • Open your Podfile
  • Replace any commented-out use_frameworks! line (or add this new line) with:
    use_modular_headers!
    
  • Run pod install in your terminal
  • Clean your Xcode project (Cmd + Shift + K) and rebuild

This tells CocoaPods to generate module maps for all your Pods (including PureLayout), so the third-party framework can find the PureLayout module just like it would with dynamic frameworks.

2. Manually Add a Module Map to PureLayout

If use_modular_headers! causes conflicts with React Native, you can manually define a module map for the static PureLayout library:

  • Navigate to your project's Pods/PureLayout directory (via Finder or terminal)
  • Create a new file named module.modulemap and paste this content:
    framework module PureLayout {
        umbrella header "PureLayout.h"
        export *
        module * { export * }
    }
    
  • Open your Xcode project, select your main target, go to Build Settings
  • Search for Import Paths (under Swift Compiler - Search Paths)
  • Add $(SRCROOT)/Pods/PureLayout to this list (enable recursive search if needed)
  • Clean your project and rebuild

This manually creates the module definition the third-party framework is looking for.

3. Adjust the Third-Party Framework's Import Style (If Possible)

If you have access to modify the SDK's code (or can ask the team to adjust it), tweaking how it imports PureLayout might resolve the issue:

  • If the SDK uses #import <PureLayout/PureLayout.h>, replace it with #import "PureLayout.h"
  • In your Xcode target's Build Settings, search for Header Search Paths and add $(SRCROOT)/Pods/PureLayout (set to recursive)
  • This makes the SDK look for PureLayout's headers directly instead of via a module.

4. Switch PureLayout to a Manual Static Library Import

As a last resort, you can ditch CocoaPods for PureLayout and import it manually:

  • Download the PureLayout source code from its repository
  • Either compile it into a static library, or add the .h and .m files directly to your project
  • Link this static library to your target, then ensure the third-party framework can access its headers via Header Search Paths.

Quick Pre-Fix Checks

  • Double-check that the third-party framework is added to both Embedded Binaries and Link Binary With Libraries in your target's Build Phases
  • Confirm you checked "Copy items if needed" when dragging the framework into your project
  • Delete your derived data (Xcode > Preferences > Locations > Derived Data > Delete) to clear any cached errors

内容的提问来源于stack exchange,提问作者39otrebla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:25:44