41

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
Kauna Mohammed
  • 477
  • 1
  • 5
  • 14
  • The latest version of CocoaPods is 1.6.something and there's a 1.7 beta floating around. I'd update your CocoaPods to the latest release version (1.6.something) and try `pod install` again. Also, you might want to post your `Podfile`, as you could be installing the wrong version of Alamofire. Lastly, are you opening the workspace, not the project? – Adrian Apr 14 '19 at 13:39
  • I have now updated to the latest stable version of cocoapods and done pod install but the problem still persists – Kauna Mohammed Apr 14 '19 at 13:44
  • Did you take a peek at this answer? https://stackoverflow.com/a/30836224/4475605 – Adrian Apr 14 '19 at 13:45
  • Yes I did. The problem still persists unfortunately – Kauna Mohammed Apr 14 '19 at 13:48
  • try adding `use_frameworks!` just below the `platform ` line, as is done in the installation instructions for [CodableFirebase](https://github.com/alickbass/CodableFirebase). – Adrian Apr 14 '19 at 13:52
  • It now says "FirebaseCore/FirebaseCore.h' file not found" and "Could not build Objective-C module 'Firebase' " – Kauna Mohammed Apr 14 '19 at 13:59
  • Ugh! Try commenting out the modular header line. – Adrian Apr 14 '19 at 14:01
  • Still not working. I commented out both #use_modular_headers! and #use_frameworks! but now nothing is being loaded which makes sense. Also tried using them individually, but I get some form of error either way – Kauna Mohammed Apr 14 '19 at 14:08
  • 1
    For some strange reason everything seems to work now. Thanks for the help? – Kauna Mohammed Apr 14 '19 at 14:31
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/191815/discussion-between-adrian-and-kauna-mohammed). – Adrian Apr 14 '19 at 14:38

9 Answers9

129

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.

Eric Wiener
  • 3,659
  • 2
  • 27
  • 34
40

I fixed this problem myself. I can tell you what I did. Not sure which steps did it exactly, but below are all steps:

  1. Copy the contents of your Podfile somewhere safe
  2. Run: pod cache clean --all
  3. Remove "Podfile"-file from the dir.
  4. Xcode: Product > Clean Build Folder
  5. Run: pod init. A new "Podfile"-file is added to the dir
  6. Start adding parts of your original Podfile to this file
  7. Run: pod install
  8. 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!

lewis
  • 2,831
  • 2
  • 36
  • 64
Ton Snoei
  • 2,091
  • 19
  • 22
30

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.

Josip B.
  • 2,304
  • 1
  • 24
  • 30
  • 3
    Thanks. After updating the iOS version in the pod file, target, and project to the same value. It worked fine. – Surya Nov 29 '20 at 12:25
  • 2
    I had the same issue with the newest Stripe pod in React native - I have bumped up the target in the Podfile, installed all the pods, the app worked fine in debug but I couldn't archive it because I didn't update min iOS version in the Project settings. Works fine now! – dusandz May 08 '21 at 16:00
  • I spent 2 days on this. I had indeed iOS 11 in my Podfile but iOS 10 in my project and target. Thank you so much @josip-b – Simon Reggiani Jul 13 '21 at 19:25
  • Thanks for this answer! I had the same issue and just setting the version to the same (11) everywhere fixed it. So it was caused by increasing the required version only in the Podfile but not elsewhere! – Pauli Kettunen Aug 10 '21 at 06:57
  • I ensured deployment target is same across target, project and pod file. But still getting error. Can you please help me in resolving this issue? – Mighty Sep 30 '21 at 11:54
10

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"

chenop
  • 4,186
  • 4
  • 40
  • 56
3

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\"";

Thermech
  • 3,753
  • 1
  • 37
  • 58
2

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

German
  • 231
  • 2
  • 8
0

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!

Sirisha
  • 393
  • 2
  • 11
0

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
0

In case you are building on command line with xcodebuild, make sure you are using

xcodebuild -workspace ...

instead of just xcodebuild or

xcodebuild -project ...
friederbluemle
  • 28,615
  • 14
  • 96
  • 99