iOS Swift Troubleshooting: Cannot Load Underlying Module For

alamofire import error

Symptom

You see an awesome cocoapod you want to include in your project. So you add a code to your podfile telling it to import the cocoapod, you run “pod install” on your terminal to begin the import process, and voila, the cocoapod now inserted to your project. But when you add the namespace “import framework” on top of your Swift file, Xcode said “Cannot Load Underlying Module For <Framework>”.

Solution

The easiest explanation is that because you just import the cocoapod, it still hasn’t been built yet, while the other cocoapods in your project have. Therefore, Xcode sometimes overlooks that there is one or two cocoapods that are new.

  1. Optional: If there’s any, comment out any “import <framework>” statement
    In this abnormal state, this statement may gets processed first before Xcode process whether there are any unbuilt pods or not.
  2. Optional: Clean up the build folder.
    This will force Xcode to rebuild everything from scratch, and not playing favorite.
  3. Optional: Completely quit Xcode, and reopen it, then reopen the project again.
    Sometimes the issue is that the Xcode editor can’t let go of the mistakes in the past.
  4. Rebuild the project.
  5. Optional: Uncomment all the “import <framework>” earlier.
  6. Run the project.

So actually the solution to this is just do rebuild first, not run. The optional steps are there if you have run the solution without the optional steps and it’s still not working. For me, I had to clean build folder and close the Xcode, but I didn’t have to comment out the “import <framework” statement. But some people did have to.

Sources / Read More

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s