"No such module 'Alamofire'" Xcode won't recognize Alamofire framework - ios

I realize that the same error was asked in other questions (like here), but their solutions are not working for me.
I keep getting a build failure in my app: "No such module 'Alamofire'". I followed the cocoadocs installation instructions (here) for installing Alamofire and it still is not working. I made sure everything has the same deployment target.
Embedded Binaries and Frameworks
Here's my podfile text.
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, ‘9.2’
use_frameworks!
target 'MyApp' do
pod 'Alamofire', '~> 3.0'
end
target 'MyAppTests' do
end
target 'MyAppUITests' do
end
Also, I tried "$ pod install" again in Terminal and got this message:
[!] The `App [Debug]` target overrides the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting defined in `Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
After following Sohil's suggestions, XCode now recognizes the Alamofire module, but 22 new issues have arisen.
Update #2: So I'm now on Xcode 7.3 and Swift 2.2, but I'm receiving a new error with the workspace Link: "ld: framework not found Alamofire. clang: error: linker command failed with exit code 1 (use -v to see invocation)."

Do the following things and you can import any swift file from "Pods"
1) Clean your project
2) Make sure that all your "Pods" > "Build Settings" > "Build Active
Architecture Only" is set to "NO".
3) Don't run, just build your project.
4) Now, import any file from "Pods" to any swift file
E.g.: import Alamofire
5) Again, build project and it will work as expected. Finally, you can
access it properties
Update:
For the updated question, I hope you are using Xcode 7.3 so please update the Alamofire to Swift 2.2
Hope this helps!

Please check this screenshot
and compare to your build setting
may this is helpful to you

For me the solution was to open the "App".xcworkspace as pointed by the cocoapods documentation
The steps was:
Close project
Close xcode
Go to terminal
type "open |App|.xcworkspace"
When I opened Xcode it was still pointing the error then I built the project (cmd+b) and everything is fine now.

The target overrides the OTHER_LDFLAGS build setting.
Use the $(inherited) flag in TARGENTS -> Build Settings -> Framework Search Paths

in my case, i couldn't run archive after change bundle name. I've cleaned build folder and run pod install then everything worked fine.

Related

Adding Pods to Xcode project brakes build

Forgive me, I am new to IOS Development. I have debugged this for a while now and tried all available solutions I could find. I added Pods to my Xcode project and the build now fails. I verified that after running "pod deintegrate; pod clean" the build works again. When I run "pod install" again and open the .workspace (not the .xcodeproj) - the build fails. I have tried every solution I could find.
I have already tried:
Deleting derived data (many times)
Restarting computer/xcode (many times)
verifying that I am opening the workspace, not the project
cleaning the project and re-building (many many times)
Deleting the Pod-.framework from the Frameworks folder and reading it to the Linked Frameworks and Libraries
Editing the build scheme to include Pod-.framework
Adding the pod frameworks to the Linked Frameworks and Libraries
Adding the pod frameworks to the Embedded Libraries
Editing the Framework Search Path in Build Settings
Building to an actual device and simulator
Heres my Podfile:
#platform :ios, '12.0'
target 'Burnt' do
use_frameworks!
pod 'MaterialComponents'
end
Versions:
MacOS version: 10.13.6
Xcode version: 10.1
Swift version: 4.2
CocoaPods version: 1.6.2
The Error:
ld: framework not found MaterialComponents
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Helpful Screenshots:
File Structure
General Settings
The Evil Error
please check MaterialComponents github version you are using right one or not
or try with
pod try MaterialComponents --> on github page
Try changing your swift version to 5 and compile and then you can change it back to 4.2 ..seems like some xcode linking glitch..
Can you compare your Project version(swift_version) and installed pod version are same?
i think this OS issue update your macOS and also update cocoapods.
Try new project to install pods.

Cocoapods causing "library not found" and header "file not found" errors for Xcode Simulator but not device

I'm using Cocoapods with my Xcode project, but it seems to be causing both "library not found" and header "file not found" errors when building with the Simulator but not when I have a device connected nor when using "Generic iOS Device".
My Podfile is simple. I have only one pod in there, for Microsoft's ADAL SDK, needed for single sign-on. When I use use_frameworks! in the Podfile I get:
fatal error: 'ADAL/ADAL.h' file not found
for the line
#import <ADAL/ADAL.h>
but if I use use_modular_headers! instead of use_frameworks! I get:
ld: warning: directory not found for option '-L/Users/memyself/Documents/iOS_Projects/ASSIST-main/ASSIST-main/DerivedData/MyApp/Build/Products/Debug-iphonesimulator/ADAL'
ld: library not found for -lADAL
Even if I disable both of those it builds fine for the device and for "Generic iOS Device", but fails with 'ADAL/ADAL.h' file not found error.
Yes, there are plenty of SO questions and answers for those kinds of errors (such as here) but no success trying them. To be specific, I'm using $(inherited) in the recommended search paths, setting enable bitcode to NO, making sure I'm opening the xcworkspace not the xcodeproj file, and have tried
$ pod deintegrate
$ pod clean
$ rm Podfile
Also, my app uses AWS and Firebase and I was getting the same problem with them, but was able to fix them by manually adding the necessary frameworks. However, I don't have a framework for ADAL, and frankly I need to fix this so I can use Cocoapods to install and manage my AWS and Firebase dependencies. It is very suspicious that it only fails when building for the Simulator, what project settings could cause this?
Update the deployment target and the Podfile 'platform' target. Update both from 9.0 to 11.0. Change this line in your Podfile
platform :ios, '11.0'
and this in both your Target and Project:
Try changing build active architecture only in build settings.

Failed to emit precompiled header for bridging header

I downloaded a project from GitHub, then pod the following files, some of which are written by OBJ-C and I used a bridge header.
pod ‘SnapKit’
pod ‘MJRefresh’
pod ‘Alamofire’
pod ‘Kingfisher’
pod ‘MBProgressHUD’
pod ‘pop’
pod ‘EVReflection’
pod ‘StreamingKit’
pod ‘iCarousel’
pod ‘ReflectionView’
When I run the project with Xcode 9.0 beta 2, but unfortunately the error log as follows :
error: failed to emit precompiled header
'/var/folders/kd/4gh0_kxx3jx4thjb_sssmmcw0000gn/T/EvoRadio-Bridging-Header-97bd5f.pch'
for bridging header
'/Users/ringo/Downloads/EvoRadio-master/EvoRadio/Resources/EvoRadio-Bridging-Header.h'
I have googled, but no such issue.The error means it needs a PCH file?
This is my .pch header configuration:
It can't solve it.
How to make it?
I have tried all of the above steps mentioned in the answers but nothing worked for me, the problem was basically with the deployment target version for the project and in the podfile.
In my project deployment target was 10.0 while in my podfile it was 11.0.
Note this can also happen if your bridging header imports Objective-C code that itself imports your app's Swift module via myproject-Swift.h. The solution is to use forward declarations for your Swift types and import the project Swift module in the .m file.
#class MySwiftClass or...
typedef NS_ENUM(NSInteger, MySwiftEnumType)
MySwiftEnumType is the lowest level name even for classes. So Swift enum MyClass.MySwiftEnumType becomes just MySwiftEnumType
Make sure you're opening the proper project workspace, otherwise, the Podfile may not have all the resources it needs to compile.
I saw this same error on a project that had been working fine previously.
I discovered that I had accidentally opened the ProjectName.xcodeproj file rather than the ProjectName.xcworkspace file. Opened the xcworkspace file and presto, project was working again!
I also got exact same issue (Xcode9 beta 6) after I added cocoa pods for Encrypted Core Data.
This is my PodFile:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
pod 'EncryptedCoreData', :git => 'https://github.com/project-imas/encrypted-core-data.git'
target 'Root' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Root
target 'RootTests' do
inherit! :search_paths
# Pods for testing
end
target 'RootUITests' do
inherit! :search_paths
# Pods for testing
end
end
Solution:
1 I added $(inherited) non-recursive to Search Path -> Header Search Paths
2 Then added ${PODS_ROOT} recursive to Search Path -> User Header Search Paths
Both the above in my projects' target build settings.
Please have a look at these SO answers:
1 Inherit Header Search Paths
2 Inherit User Search Paths
For me, this problem occurred when I added new build configuration and scheme to the existing project.
The solution was to run pod install on newly created scheme. After that, project was built successfully.
I had this issue just when compiling for a simulator not for a hardware device. There were two compile error like:
error: failed to emit precompiled header 'Bridging-Header-97bd5f.pch' for bridging header 'Bridging-Header.h'
Could not find ActionSheetPicker_3_0/ActionSheetPicker.h in Bridging Header (but it was declared there)
After hours of research and try and errors it turned out, that there was no valid architecture set in the project to compile for simulators.
At Project -> Build Settings -> User-Defined -> VALID_ARCHS add the architecture x86_64 to enable compilation for simulators.
XCode can build seccessful in the some target, but the other target can not.
Finally, I found that Header Search Paths is not the same. (Path: Target > Build Settings > Search Paths > Header Search Paths > add item)
I copied & pasted the path from the successful target. I made it. Bravo.
You can try this solution. I have solved the same problem by this way.
Product > Scheme > Edit Scheme > Select "Build" on Left Menu > Find implicit dependencies
Under the build tab, check 'Find implicit dependencies':
Then make a clean and build again.
In my case I had the same compiler error with additional errors like "Unknown type" in one of my project files, So I just added this to the problematic file, and it solved it instantly.
#import <UIKit/UIKit.h>
My experience with this is that Xcode is unable to find header files for pods/frameworks imported in the project.
My Project experience with this:
Updating Xcode9.2 - 9.3 where many cocoapods had to be updated due to implicit definitions now unavailable or being outdated.
I had changed the Podfile to now include 'use_frameworks!'. Following this and after dealing with other compile issues I found the error you are experiencing. I believe adding 'use_frameworks! was preventing some pods with support prior to iOS 8 from compiling correctly. Steps I took to correct this issue:
I tried deleting the Pods/ directory using cocoa pod deintegrate
I then open project with Xcode and cleaned the build folder and the project. (delete content within derived data folder)
I then pod install again but the issue persisted.
Ultimately I removed the use_frameworks line in Podfile and then repeated steps 1-3 and the project was now able to find the missing header files and the issue never presented it self again.
In my case;
Under Target/Build Settings/
Product_Name section was different than $(TARGET_NAME)
When I changed it $(TARGET_NAME), it was resolved.
In my case, I found that it was because I did not config the Framework Search Paths in Release Tab. Here is the screenshot:
After adding this path, it works.
For my case I had a typo in folder name "Supporing FIles" instead of "Supporting Files".
I also suffered from this after I updated new Xcode. After several hours of investigation, i found that if you have multiple targets, you now have to add more targets in pod file in Xcode 10. So your code should be like this:
platform :ios, '9.0'
target 'EvoRadio' do
pod ‘SnapKit’
pod ‘MJRefresh’
pod ‘Alamofire’
pod ‘Kingfisher’
pod ‘MBProgressHUD’
pod ‘pop’
pod ‘EVReflection’
pod ‘StreamingKit’
pod ‘iCarousel’
pod ‘ReflectionView’
target 'EvoRadio2ndtarget' # add your second target
end
I found that in Xcode 9 you don't need to add, but in Xcode 10 you need to add this. Hope this helps.
Deleting Podfile.lock and re-running pod install fixed this for me.
There are so many reasons and things can do, like:
Restart Xcode, Clean, Build
Remove Pods directory and pod install
Check the missing file is added to your pod file
Check the missing file is added to you bridging header
Change the header settings like here iOS - Build fails with CocoaPods cannot find header files
The only one works for me is the accepted answer in Xcode 9 - failed to emit precompiled header.
platform :ios, '11.0' in podfile should match the target in the project
I had same scenario, make sure for the file A that you have included in YourProjectName-Bridging-Header.h
if it uses some other class(s), then those other classes are also included before that File A
In my case, I was building with the wrong scheme (Top-Left menu).
For Xcode 11 I had an issue with the "Security.framework". I removed this dependency, then re added it. Ultimately fixed the other problems
I got this error after renaming the existing Xcode project configuration in which I had another Xcode project imported.
To fix it, you have to rename the same configuration in the imported project as well.
Since I have been stuck in this issue for 2 working days , I would like to share my issue for you because may be future searchers are facing my problem
I was getting the mentioned error when running with command line , and I found that the command I was writing was for running .xcodeproj ,, but to run a .xcworkspace you have to write the following command
xcodebuild -workspace PROJECTNAME.xcworkspace clean archive
-archivePath build/PROJECTNAME -scheme SCHEMENAME
In my case, all was good. I had just forgotten to add '.h' in import added to the bridging header file
Was
import 'Test'
Required
import 'Test.h'
Had this error in a bit different situation. Added SWIFT file in one project from another one. Checked names of bridging headers, routes - nothing helped. The reason of the error was that I did not import some of my custom classes in the bridging header. Imported - and it worked!

Framework not found GoogleToolboxForMac

After I update my Firebase via "pod update", I got error like this :
ld: warning: directory not found for option '-F/Users/bennysantoso/Library/Developer/Xcode/DerivedData/FCM-atfcxuircoryufazlomgwfgmvaqm/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac'
ld: framework not found GoogleToolboxForMac
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here my Podfile :
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
target 'BB' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for BB
target 'BBTests' do
inherit! :search_paths
# Pods for testing
end
target 'BBUITests' do
inherit! :search_paths
# Pods for testing
end
end
Does anybody know about this error?
I seek out relationships GoogleToolboxForMac and Firebase, but I just get a little bit of information.
FYI, I use Swift 2.3 and Firebase 3.8.0.
I will be grateful for any help you can provide. Thanks!
I had the same error. Once you install the pods, you'll see the following message.
[!] Please close any current Xcode sessions and use MyApp.xcworkspace
for this project from now on.
I didn't notice this for the first time and was trying to build the project using the regular xcodeproj file. After I saw this message, I opened the right project and it worked fine.
Once you open this project you'll notice that you have two subprojects. One would be your project, and another would be the Pods project.
Framework Not Found
When using Pods, we usually face this issue.
There are two main reasons for this
When we open the .xcodeproj file instead of .xcworkspace as mentioned by izaaz-yunus in this Answer
When Build Active Architecture Only is set to Yes in Build Settings
This applies to the projects target and also to all the targets in the pod project
Main Project Screenshot
Pod Project Screenshot
Select Build Settings (of main project, pod project both)
Select each Target one by one
Set Build Active Architectures to No for each target
Finally clean and rebuild your project.
In my case all integration are well-done and also did try so many time to remove and reinstall pod but did not get success.
Finally try with below step
Projetc->Manage Schemes -> Select check box "Pods-MyProjectName"
And get success.
GoogleToolboxForMac is a dependency of Firebase/Messaging. Details in the podspec. When doing "pod update", Cocoapods should set up your workspace to build and link GoogleToolboxForMac.
It sounds like something about your workspace is in a bad state. Does Product -> Clean help? What about deleting Derived Data and the ModuleCache (Xcode -> Preferences -> Locations -> Derived Data)?
It shouldn't be necessary, but you could also try explicitly adding pod 'GoogleToolboxForMac/Logger' to your Podfile.
its work's
1. select your project in directories
2. select General
3. Add "GoogleToolboxForMac.framework" to the Linked "frameworks and Libraries"
This was fixed by adding $(inherited) in the Build Settings -> Search for LIBRARY_SEARCH_PATHS.
This is understandable, since when updating your pod file for the latest versions of libraries which your project depends on, the debug output tells you where you need to add all the $(inherited) flags:
LIBRARY_SEARCH_PATHS
OTHER_LD_FLAGS
GCC_PREPROCESSOR_DEFINITIONS
Go to : target -> Build Settings -> Other Linker Flags -> remove framework "GoogleToolboxforMAC" and build the project.
I had the same issue when I tried to run it on my device. On the simulator it was working fine. I tried some of the above but it didn't work for me. I checked that I was working on .xcworkspace instead of .xcodeproj file, so I tried this one. Follow these steps to:
Open Xcode project (cocoapods project) using .xc... file.
Select Pods project in the project navigator (blue icon on left).
Under Targets, ensure Pods-ProjectName (blue icon) is selected.
Navigate to Build Settings and set the iOS Deployment Target on which iOS version you are going to run project.
Note:It is same as what you set in Project->Targets->Deployment info->Deployment Target.
Maybe someone get benefitted from this.
If you're facing the same error, in your XCode, go to:
Your Project > your target > Scroll down to Linked Framework and Libraries and check if the Library entry is dimmed:
If so, remove and add it again. In my case, I had duplicated entries and one of them was dimmed (when XCode can't find them on disk).
Closed the project that I was trying to build after I did pod install then opened the .workspace and then everything builds perfectly.
Open the your-project.xcworkspace in your project destination.
1)Open terminal -> 2) $cd /project_destination -> 3) $open your-project.xcworkspace
or just open the file in finder
Make sure your "Build Active Architecture settings" for both your project target and the pod are same. Setting NO in both these cases fixed my issue.
My issue was that I had a /bin/sh script that copied specific Pods which didn't exist. This was one of them. Removing the script resolved the build issue.
-I search in harddrive for the GoogleToolboxForMac files, found in :
/Users/Marco/Documents/iosapps/BomRetiro/Bom Retiro/Pods/Target Support Files
And then i copied the files to this folder :
/Users/YourHomeFolder/Library/Developer/Xcode/DerivedData/Bom_Retiro-bsfjbazzzuwmuidqurdmjvdtnnsb/Build/Products
And then for me is resolved opening the project usinf .xcworkspace file.
For those still having issues after all this.
I am working on a cordova project and the issue suddenly appeared after upgrading to XCode 11.5.
Finally I was able to solve it by opening the pods.json file in the project root and remove the entry in "libraries" which belongs to "FirebaseMessaging".
We were not using that and I dont know how it got there.
Additionally I have changed the "Build Setting" -> "Build Active Architecture Only" to "No" everywhere.
Afterwards I opened the .xcworkspace file again and the build ran through.
Worked solution is
Search GoogleToolboxForMa in xcodeproj
Remove all references from the build configurations
Swift 5 Simple Answer
Shift+Alt+Cmd+K //Clean the project and Run again!
//if not work restart Xcode and again clean it
//Its will work happy coding
Friends, you must be confused with the exact result, as i was. So, i feel to share the
screenshot that might be helpful. We all had to be careful that we need to change the flag for property **"Build Active architecture Only"** for **pod target** to **NO** And build, it would not show the linking error.
See the attached screenshot.
Screen Shot 1, Screen Shot 2, Screen Shot 3
[Select Pods][1]
[Select Targets in the pod][2]
[Change flag to No][3]
[1]: https://i.stack.imgur.com/E7mjX.png
[2]: https://i.stack.imgur.com/wCwET.png
[3]: https://i.stack.imgur.com/KVGKM.png

Cocoapods ld: library not found for -lPods-Projectname

I've installed cocoa pods library and some frameworks through it. Now when I compile project the build fails.
Error:
ld: library not found for -lPods-Project
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here part of text:
Ld /Users/polzovatel/Library/Developer/Xcode/DerivedData/Project-bybevfqrgvqqldbzsgewqafpmylj/Build/Products/Debug-iphonesimulator/Project app/Project normal i386
cd /Users/polzovatel/Projects/iOS-master/Project_iPhone
export IPHONEOS_DEPLOYMENT_TARGET=6.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
What I need to do to fix this problem?
Fixed it by deleting the -lPods-Projectname.a in Link Binary (for newer versions, delete the -lPods-Projectname.a under the Frameworks group).
Whenever I execute "pod install" it leads me to spend several hours fixing build errors. So, I deleted CocoaPods stuff and do not have problems any more! Now I am lucky and happy man.
Start using Swift Package Manager (SPM). If your 3rd party lib still do not support SPM I encourage you to take action on adding SPM support on your own. Here is instructions.
Or create an issue for the 3rd party lib about adding support for SPM.
The exact location that you should remove your libs is at:
Remove -lyourlibname.a in "Link Binary With Libraries" on "Build Phases" of your target.
You can try "Build Active Architecture Only" = YES . it may be solving problem.
Ensure that Build Active Architectures Only settings for both of your project and the Pods project were equal for debug and release configuration! That's was a problem in my case.
Make sure Build Active Architectures Only in your Project/Target and in your Pod/Target and Pod are the same.
We often set the debug yes and set the release no.
I realized the xcproject file was opened instead of the updated workspace. This fixed my error. Hope this information will help others too.
If none of the other answers help you, try this:
Deintegrate cocoa pods using pod deintegrate. Check this link https://github.com/kylef/cocoapods-deintegrate.
Search on the build settings for target and project file for "pod". Anything that looks like it belonged to cocoa pods, remove.
Finally, run pod install once again.
Go to Product > Scheme > Edit Scheme... > Build > + > Add the Pods-Projectname.a and drag it to the top > Clean & Build your project.
I had a very different experience. I tried removed the library from build settings to no avail. And honestly, I couldn't see the logic behind it.
What I did was try a new pod install. And so it gave me this error
[!] The ProjectName [Debug] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
[!] The ProjectName [Release] target overrides the LIBRARY_SEARCH_PATHS build setting defined in Pods/Target Support Files/Pods-/Pods-.debug.xcconfig. This can lead to problems with the CocoaPods installation
- Use the $(inherited) flag, or
- Remove the build settings from the target.
So I did what it told me to, I added the $(inherited) flag to build settings. And all worked well
In my case I found that a mis-match of deployment target of the Project (iOS 11.4) versus the Target (iOS 10.3). Updating the target to iOS 11.4 fixed the issue.
Project > Info > Deployment Target > iOS Deployment Target
Project > Target > General > Deployment Target > Target
Podfile:
platform :ios, '11.4'
I had this problem when I accidentally opened project instead of workspace so Cocoapods where missing....
Check your Project -> Targets -> Build Phases -> Link Binary With Libraries
Point to your Pods project, set the BaseSDK to iOS SDK since 'pod install' process clear it.
Also set Build Valid Architecture Only to NO
That should work.
I experienced a similar error which affected one of my computers but not the other when compiling the same project.
I reinstalled cocoapods, all gems, rebuilt the project and none of it worked. I finally got it to compile but required me to completely remove Xcode and related data (iPhone simulator, DerivedData) then reinstall Xcode.
I've had this error after adding a new build configuration.
pod install helped, because it adds separate settings for each build configuration.
i also had the same sort of issue. So Check your pod file's platform :ios . and check Deployment info target versions. and please make sure version of both files are same. if both are not same the issue will be executed. i also had the issue after library updating my react native project
(Target info = select your project, then select target, In general section Deployment info is available.)

Resources