Swift. Could not build objective-c module 'Alamofire'

SwiftAlamofire

Swift Problem Overview


Fresh vanilla submodule install of Alamofire, using XCode6 and following directions to a T. Something here just isn't fitting right. The error i'm getting is "Could not build objective-c module "alamofire" on import alamofire. Here is a screen shot of the error i'm getting:

![enter image description here][1] [1]: http://i.stack.imgur.com/hs2TF.png

And my configuration:

enter image description here

Swift Solutions


Solution 1 - Swift

When this happens, just build the frameworks separately first. In your case:

  • Change the scheme to Alamofire
  • Build (⌘B)
  • Change back to your scheme
  • Run

Solution 2 - Swift

Go into Developer/Xcode/DerivedData and delete the folder for your framework. (Or just delete DerivedData itself)

If you have a build of you app in a running simulator you'll need to delete the app there.

Then Clean & Build

Solution 3 - Swift

This always works for me:

  1. Quit Xcode
  2. Delete ~/Library/Developer/Xcode/DerivedData
  3. Change to your framework’s scheme and build ⌘B
  4. Change to your app’s scheme and build ⌘B

Solution 4 - Swift

Deleting the DerivedData folder and cleaning and building the project solved this issue for me.

Solution 5 - Swift

Try the following in this order and one of the steps should work.

  1. Cmd+B - Builds the workspace and should possibly build the target or module we want.

  2. Cmd+K and then Cmd+B - Clean and then Build

  3. Cmd+Shift+Option+K and Cmd+B - Clean Build Folder

  4. Quit Xcode, Delete Derived Data, launch Xcode and Cmd+Shift+Option+K then Cmd+B

This happens to be the cleanest possible way to clean the derived data and other caches from Xcode.

Solution 6 - Swift

If you're getting this error trying to import a dynamic framework, make sure the framework is included in the target's Target Dependencies.

Project > "Target" > Build Phases > Target Dependencies

Solution 7 - Swift

Build clean worked for me.

  1. Build clean for Alamo
  2. Build clean for HTTPDemo

Solution 8 - Swift

Comment out the import and all code using it, build, run, then uncomment. It worked for me...

Solution 9 - Swift

Any pod failed to build may cause this error as well. (in my case an old pod using obsolete syntax failed to build).

You may try pod update to update your pods to latest version and see how thing goes.

Solution 10 - Swift

I resolved this issue in one of my Objective-C/Swift hybrid projects.

In your Objective-C bridging file, add the following line:

#import <Alamofire/Alamofire.h>

Solution 11 - Swift

Crazy fix for this issue - Only working solution for me

Create new scheme and add the framework that is showing error. In this case 'Alamofire'. Run all those schemes.

Once you compile all the schemes your project target will also works fine.

It may seem like a crazy fix but only working solution for me.

Solution 12 - Swift

If valid architectures of the Alamofire project do not contain the valid architectures of your project, it occurs "Could not build objective-c module .." error.

Add these architectures i386 x86_64 arm64 arm64e armv7 armv7s armv6 armv64 to the Alamofire project's 'Valid Architectures' on the 'Build Settings'.

Build the same target device for both of the projects. For example, at first, build the Alamofire project for iPhone 8(13.2), then build your project for the same simulator.

If the Alamofire project build takes very short that means about 0.5 seconds, it means the Alamofire project occurs error because the architecture of the selected simulator is not on the Valid Architectures.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionstopshinalView Question on Stackoverflow
Solution 1 - SwiftDaniel LarssonView Answer on Stackoverflow
Solution 2 - SwiftSean HowellView Answer on Stackoverflow
Solution 3 - SwiftSam SoffesView Answer on Stackoverflow
Solution 4 - SwiftIsuruView Answer on Stackoverflow
Solution 5 - SwiftravisekahrpView Answer on Stackoverflow
Solution 6 - SwiftDavid JamesView Answer on Stackoverflow
Solution 7 - SwiftNick MitchellView Answer on Stackoverflow
Solution 8 - SwiftxytorView Answer on Stackoverflow
Solution 9 - SwiftGang FangView Answer on Stackoverflow
Solution 10 - SwiftEddie LauView Answer on Stackoverflow
Solution 11 - SwiftSaranjithView Answer on Stackoverflow
Solution 12 - SwiftYusufView Answer on Stackoverflow