问题
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:


回答1:
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
回答2:
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
回答3:
This always works for me:
- Quit Xcode
- Delete
~/Library/Developer/Xcode/DerivedData
- Change to your framework’s scheme and build ⌘B
- Change to your app’s scheme and build ⌘B
回答4:
Deleting the DerivedData folder and cleaning and building the project solved this issue for me.
回答5:
Try the following in this order and one of the steps should work.
Cmd+B - Builds the workspace and should possibly build the target or module we want.
Cmd+K and then Cmd+B - Clean and then Build
Cmd+Shift+Option+K and Cmd+B - Clean Build Folder
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.
回答6:
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
回答7:
Build clean worked for me.
- Build clean for Alamo
- Build clean for HTTPDemo
回答8:
Comment out the import and all code using it, build, run, then uncomment. It worked for me...
回答9:
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>
回答10:
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.
回答11:
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.
来源:https://stackoverflow.com/questions/26834293/swift-could-not-build-objective-c-module-alamofire