Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Swift compiler error: "non-modular header inside framework module"

Migrating an ObjC framework to Swift with a non-modular header inside framework module error.

Quick Answer: To fix the error, you need to make your header file modular by moving its contents into a separate Swift file. This will allow you to use the protocol without including the non-modular header directly in your classes.

The 'non-modular header inside framework module' error in Swift occurs when a non-modular header file is included within a framework module. This issue arises from the fact that frameworks are designed to be modular, and non-modular headers can disrupt this modularity.

🛠️ Step-by-Step Verified Fixes

Method 1: Modularize the Header File

  1. Step 1: Move the protocol definition to a separate Swift file.

Method 2: Update Framework Module Configuration

  1. Step 1: Open the framework's `Package.swift` file and update the `frameworks` section to include a modular header.

Method 3: Use a Bridging Header

  1. Step 1: Create a bridging header file that imports the non-modular header.

✨ Wrapping Up

To resolve the 'non-modular header inside framework module' error, you can either modularize the header file, update the framework module configuration, or use a bridging header. By following these steps, you should be able to successfully migrate your ObjC framework to Swift.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions