How to fix cocoapod .modulemap file not found - swift

When I try to build my project, I get a compile time error saying that a "Module map file" for my pod cannot be found and that I am missing a "SwiftShimes" module.
This is weird because all my modulemap files are where they should be when I install my pods.
I am using Xcode 10.2 and Cocoapods 1.6.1.
I have tried the following ->
deintegrating cocoapods from my project
cleaning the project
deleted ModuleCache and DerivedData
restarting my computer
This is the type of error I am getting ->
Module map file '/Users/kaunamohammed/Library/Developer/Xcode/DerivedData/OutNow-gxdxvzwmnijmrlajtbtyclkhrgqs/Build/Products/Debug-iphoneos/CodableFirebase/CodableFirebase.modulemap' not found
I expect my project to build properly but this is not the case and I am not sure what else to do.
This is what my Podfile looks like
platform :ios, '10.0'
workspace 'OutNow'
target 'OutNow' do
use_modular_headers!
#Pods for OutNow
pod 'Instabug'
pod 'SwiftMessages'
pod 'CodableFirebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'MarqueeLabel/Swift'
pod 'RxSwift', '4.4.2'
pod 'RxCocoa', '4.4.2'
pod 'Kingfisher', '5.3.1'
pod 'InstantSearchClient', '6.0'
pod 'CoordinatorLibrary', '1.0.5'
pod 'UIScrollView-InfiniteScroll', '1.1.0'
target 'OutNowTests' do
inherit! :search_paths
# Pods for testing
end
end

In case it helps anyone else, I was able to solve this issue a different way. I was accidentally opening up my .xcproject instead of my .xcworkspace. When I opened the correct file, the error went away.

I fixed this problem myself. I can tell you what I did. Not sure which steps did it exactly, but below are all steps:
Copy the contents of your Podfile somewhere safe
Run: pod cache clean --all
Remove "Podfile"-file from the dir.
Xcode: Product > Clean Build Folder
Run: pod init. A new "Podfile"-file is added to the dir
Start adding parts of your original Podfile to this file
Run: pod install
Try to build your project again
In my case, I think the row use_frameworks! in the "Podfile" did the trick.
Hope this help you guys out!

I had this issue only when I wanted to make an archive. On the other hand, debug worked fine. After a while I noticed that min iOS version was different between my Target, Project and Podfile min iOS version. After syncing them all to same value (iOS 11) Xcode offered me Validate Project Settings - Update to recommended settings option which I accepted and I was able to archive my project.

I spent a whole day trying to figure out how to solve this issue. I was facing issue in my project on M1 machine.
I enabled "Open using Rosetta" option in Xcode and worked for me.
Here is how you do that:
Open Finder --> Applications --> Right click "Xcode" --> Get Info --> check "Open using Rosetta"

I solve this issue by removing OTHER_SWIFT_FLAGS custom flag in Swift Compiler - Custom Flags
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/modulePath/moduleName.modulemap\"";

I faced this same issue but with Fastlane using gym build_app.
I ensured that min iOS version was synched between my Target, Project, and Podfile as mentioned by Josip B. This allowed me to archive my app using XCode but it still failed using Fastlane.
After lots of searching, it was able to resolve my issue by ensuring the IPHONEOS_DEPLOYMENT_TARGET version for each of my installed Pods inherited the version from my Podfile using this Podfile post-install script:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Reference this post: https://stackoverflow.com/a/63489366/10211406

In case you are building on command line with xcodebuild, make sure you are using
xcodebuild -workspace ...
instead of just xcodebuild or
xcodebuild -project ...

I had this issue too, I'm not very familiar with XCode, but I opened the .xcodeworkspace file and then clicked build, which was successful!

It´ s a bit of a hack but try adding this in your podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end

make sure you add it to your bridge file, and Try to add this at the end of your podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end

Related

xcode: no such module 'Kingfisher'

I want run my app on emulator
But I get this error:
no such module 'Kingfisher'
pod update, pod install, delete DerivedData folder, restart xcode, use xcworkspace, use xcodeproj and ... not solved my problem!
OS: 11.4
xcode: 12.4
My pod:
platform :ios, '11.0'
use_frameworks!
target 'Name' do
pod 'QuickBlox'
pod 'Quickblox-WebRTC'
pod 'Alamofire'
pod 'Kingfisher'
pod 'NVActivityIndicatorView/Extended'
pod 'PulsingHalo'
pod 'ImageScrollView'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
end
please use these commands in order in the project directory
1- pod deintegrate
2- rm podfile.lock
3- pod install
then clean project and build it should work
It happens to me sometimes.
first, clean build and then rebuild the project.
if there is no success try pod install, otherwise restart your device.
In my case Kingfisher worked with iOS and not with macOS. I used Xcodes package installer and not pod install. In order to fix my "no such module 'Kingfisher'" error for macOS:
I had to go to my TARGETS. (on the left side of General/Signing/etc)
Click on your macOS target.
Click "Build Phases" (2nd to last on the top row)
Go down to 'Link Binary with libraries.'
Click the '+' button and add the Kingfisher library.
If you have the error in your iOS version then add the library to that target instead. This won't fix everyone's issue, but no other solution I could find online worked and finally after clicking around I found this library was missing and it fixed my error, so I hope it helps someone.
Adding this to podfile helps me
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end

Flutter: Cocoapods The 'Pods-Runner' target has transitive dependencies that include static binaries: Flutter.framework

I am getting this error while running pod install
[!] The 'Pods-Runner' target has transitive dependencies that include static binaries: (/Users/me/Documents/flutter/flutter/bin/cache/artifacts/engine/ios/Flutter.framework)
After doing bit of a research it says use frameworks! in my Podfile is causing the issue. If I comment out use frameworks! I get this error. Any idea on what the issue is? I have been stuck here for the past three days.
ld: framework not found Flutter
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Also according to whats written here. Adding the following to Podfile also didn't work for me. This is how my Podfile looks.
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
def parse_KV_file(file,seperator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=seperator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname,:path=>podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end
target 'Runner' do
# Flutter Pods
#use_frameworks!
pod 'EstimoteSDK'
pod 'SwiftKeychainWrapper'
pod 'Alamofire'
generated_xcode_build_settings = parse_KV_file("./Flutter/Generated.xcconfig")
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter build or flutter run is executed once first."
end
generated_xcode_build_settings.map{ |p|
if p[:name]=='FLUTTER_FRAMEWORK_DIR'
pod 'Flutter', :path => p[:path]
end
}
# Plugin Pods
plugin_pods = parse_KV_file("../.flutter-plugins")
plugin_pods.map{ |p|
pod p[:name], :path => File.expand_path("ios",p[:path])
}
end
pre_install do |installer|
# workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end
For me, I deleted the ios/Flutter/Flutter.framework folder and install pods pod install again then it worked.
Delete ios/Flutter/Flutter.framework folder.
Install pods again then it worked. It will regenerate the deleted folder
pod install
In my case I don't have Flutter.framework, so the following solution worked for me
Inside the Podfile use_frameworks! :linkage => :static
This process solve it for me :
Delete ios/Flutter/Flutter.framework folder.
Delete ios/PodFile
Delete ios/PodFile.lock
Go to the project root and re-save the file pubspec.yaml (on VSCode, this will automatically runs the following command : flutter get pub)
Run the project again
Let me know if it works for you too
A complete reinstallation of flutter works for me.
Delete ios/Flutter/Flutter.framework folder.
Install pods again then it worked. It will regenerate the deleted folder
pod install
In your podfile where You see
target 'Runner' do
use_frameworks!
comment user_frameworks!
target 'Runner' do
comment below line
use_frameworks!
and go to path /ios of the project
run
pod install
what worked for me is
deleted the ios/Flutter/Flutter.framework folder
ran flutter create -i swift --org com.orgname .
I was able to run the app without pod install (after this procedure)
Please check the ios/project.pbxproj. I was moved project to another folder and I forgot to replace the FLUTTER_TARGET and FLUTTER_APPLICATION_PATH with the newest one in the ios/project.pbxproj.
Commenting out use_frameworks! in the podfile, worked in my case.

Linker Issue Xcode Cocoapods

Installed three pods but for some reason can't get it to work
I tried reinstalling, updating, deintegrating but nothing does it.
I get the following errors. Tried creating the folders manually but the Linker Error remains always
Podfile:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Clima' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Clima
pod 'SwiftyJSON'
pod 'Alamofire'
pod 'SVProgressHUD'
end
The frameworks aren't being built. Just open {Yourproject}.xcworkspace generated after adding cocoapods instead of {Yourproject}.xcodeproj - that should help.

CocoaPods Bridging Header file not found

New developer here, and I'm currently building an app in swift. We are using cocoapods, but after running pod install, we get an error in the objective-c bridging header saying that the file cannot be found, but for any and every file in our bridging header. For example, we use DateTools. We pod install it, in the bridging header we put:
#import <DateTools/DateTools.h>
but then, upon running, it errors, saying that 'Datetools/Datetools.h' file not found. I've already looked through a lot of other similar posts (like this, this, or this), but none have solved the issue. Any help would be greatly appreciated!
When using the use_frameworks! instruction in Cocoapods, the bridging header is not required for importing Objective-C pods in Swift.
Simply set your desired pods into your podfile:
#Uncomment this line to define a global platform for your project
platform :ios, '9.0'
#Uncomment this line if you're using Swift
use_frameworks!
target 'YourProject' do
#Swift Pods
pod 'Alamofire'
pod 'ActiveLabel'
#ObjC Pods
pod 'IDMPhotoBrowser'
pod 'Firebase'
#This stuff is to set the SWIFT_VERSION
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '2.3'
end
end
end
end
Run pod install. Run pod update (should not be necessary, but for some reason I'm getting updates almost every time, even after clean install). Close Xcode and reopen using the white xcworkspace file.
import Alamofire
import ActiveLabel
import IDMPhotoBrowser
import Firebase
Done.

Cocoapods pod file install not working "Unable to find a specification for `RealmSwift (~> 0.97)`" swift

I'm attempting to install Realm for swift, expect terminal keeps giving me this error: Unable to find a specification for RealmSwift (~> 0.97). My pod file has been laid out exactly as they recommend. This is my pod file:
target 'AppName' do
use_frameworks!
pod 'RealmSwift', '~> 0.97'
end
target 'AppName Tests' do
use_frameworks!
pod 'RealmSwift', '~> 0.97'
end
target 'AppName UITests' do
end
target 'AppName Keyboatd' do
end
target 'AppName Keyboard' do
end
I just tried it with Realm Objective-C and it worked fine for me. That's strange.
It's possible that since the version is actually called '0.97.0', maybe it's necessary to include that extra '.0'.
Alternatively, is it completely necessary to include the version specifier in there? You can just leave it off, and you'll still get the latest version of Realm (0.97.1 was released a few days ago!)