73

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
  • 797
  • 1
  • 6
  • 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

15 Answers15

195

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
  • 4,929
  • 4
  • 31
  • 40
57

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,936
  • 2
  • 37
  • 72
Ton Snoei
  • 2,637
  • 22
  • 23
35

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,434
  • 1
  • 25
  • 30
  • 4
    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
  • 1
    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? – ThinkAndCode Sep 30 '21 at 11:54
34

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,743
  • 4
  • 41
  • 65
  • 10
    Is this still the only solution in mid-2022, Xcode should work with native architecture, isn't it? Sad to run it in Rosseta, feels like I cannot take the full advantage of my machine. – Divyanshu Negi Jul 02 '22 at 04:56
  • 1
    omg i was tryin to work it for months. thanks it worked – Ateş Danış Oct 06 '22 at 18:12
  • 1
    Running Xcode in Rosseta, I'm able to compile and run the app. But it occasionally crash the system (reboot). It seems not very stable. – Bagusflyer Nov 02 '22 at 14:15
  • 1
    I had to select a different scheme and build config. I was then able to build for Rosetta. The 'Build for Rosetta' popup shows up within xcode when we start the build process – sushrut619 Apr 17 '23 at 23:58
8

Just check that you opened the .xcworkspace file and not the .xcproject file with Xcode.

HangarRash
  • 7,314
  • 5
  • 5
  • 32
ahmnouira
  • 1,607
  • 13
  • 8
  • This has already been mentioned in other answers, such as [this one](https://stackoverflow.com/a/59696931/2227743). – Eric Aya Mar 01 '23 at 09:33
6

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
  • 4,371
  • 2
  • 39
  • 60
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
  • 270
  • 2
  • 9
2

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
  • 33,549
  • 14
  • 108
  • 109
1

If anyone still has this issue with Xcode 14.3, I resolved it with the following:

In Xcode choose Product -> Destination -> Destination Architectures -> Show Rosetta Destination

Then clean your build folder and try again, for me it worked fine

cucereanum
  • 43
  • 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
  • 423
  • 4
  • 12
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

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
Alain Stulz
  • 715
  • 6
  • 19
  • Tried this on Mac m1, gives a different error --- Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/FirebaseCoreInternal.build/Objects-normal/arm64/FirebaseCoreInternal.swiftinterface:5:19: error: underlying Objective-C module 'FirebaseCoreInternal' not found @_exported import FirebaseCoreInternal ^ --- – Raisa A May 01 '23 at 08:36
0

The same error comes with Xcode 14 when archiving a build if you have the scheme name with spaces (Example: AppName Dev). Remove spaces and the build will archive successfully.

ajw
  • 2,568
  • 23
  • 27
0

I was experiencing this issue after switching branches in git, because the build configuration for the scheme I had selected was one that did not exist on the current branch. Switching the build configuration for the Run scheme cleared the issues immediately.

Click on your target in the top bar
Edit Scheme
Choose an appropriate build config.

I've had this issue in the past and it was resolved by following the steps in Ton Snoei's answer (specifically, steps 2, 4, and 7), but recently experienced it again and no manipulation of the podfile or removal/addition of pods was solving it until I changed the build config.

Stonz2
  • 6,306
  • 4
  • 44
  • 64
-1

What helped for me in similar situation is to use different Node version (to match RN recommendation). Downgraded it from 16 to 12 (RN 63.x)

evgenii
  • 285
  • 2
  • 7