You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在iOS项目中添加自定义Framework的引用而非副本

Hey there, let's tackle that "No such module" error you're hitting when referencing your custom Framework without copying it into the project. I've run into this exact issue before, so here are the actionable steps to fix it:

Troubleshooting "No such module" for Uncopied Custom Framework
  • Fix Framework Search Paths
    Open your project's Build Settings, search for Framework Search Paths, and add the path to your frameworks folder. Using $(SRCROOT) (which points to your project's root directory) makes this reliable—try adding $(SRCROOT)/frameworks and set the path type to recursive (if your framework is nested) or non-recursive. This tells Xcode exactly where to look for your module.

  • Match Build Configurations
    If your project is running in Debug mode but your Framework was built for Release (or vice versa), Xcode might fail to locate the module. Check your scheme's configuration (Product > Scheme > Edit Scheme > Run > Info) and ensure it matches the build configuration used for your Framework. For flexibility, you can configure your Framework to build for both Debug and Release in its own Build Settings.

  • Validate Framework Structure
    Right-click your Framework and select "Show in Finder" to check for a Modules folder containing a module.modulemap file. This file is critical for Swift/Clang to recognize the module—if it's missing or malformed, you'll get the "No such module" error. Recompile your Framework if this structure is incomplete.

  • Check Embed Settings
    Head to your project's General tab, under Frameworks, Libraries, and Embedded Content. Make sure your Framework is listed here, and set its embed status to Do Not Embed (since you don't want to copy it into the project). If it wasn't added correctly, remove it and re-add it, double-checking that "Copy items if needed" remains unchecked.

  • Clear Xcode Caches & Restart
    Xcode's cached build data can cause weird issues like this. Run Command + Shift + K to clean the project, then Command + Option + Shift + K to wipe the build folder. Restart Xcode entirely before recompiling—this often resolves hidden cache conflicts.

  • Verify Folder Permissions
    Ensure your project has read/write access to the frameworks folder. If you moved the Framework into your project's root directory, confirm the folder's permissions are set to allow your user account to access its contents.

内容的提问来源于stack exchange,提问作者George Vardikos

火山引擎 最新活动