How to fix cocoapod .modulemap file not found
Asked Answered
S

17

94

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
Society answered 14/4, 2019 at 13:15 Comment(11)
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?Afford
I have now updated to the latest stable version of cocoapods and done pod install but the problem still persistsSociety
Did you take a peek at this answer? https://mcmap.net/q/225221/-can-39-t-find-pods-modulemap-looking-in-wrong-directoryAfford
Yes I did. The problem still persists unfortunatelySociety
try adding use_frameworks! just below the platform <blah blah> line, as is done in the installation instructions for CodableFirebase.Afford
It now says "FirebaseCore/FirebaseCore.h' file not found" and "Could not build Objective-C module 'Firebase' "Society
Ugh! Try commenting out the modular header line.Afford
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 waySociety
For some strange reason everything seems to work now. Thanks for the help?Society
Let us continue this discussion in chat.Afford
yeah, I opened the wrong file and I have worked on react-native for 8 years, lolDisobedience
H
241

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.

Heliotrope answered 11/1, 2020 at 17:33 Comment(5)
Once of reason need to check: https://mcmap.net/q/225222/-yogakit-modulemap-not-found-after-running-the-ios-simulatorGauntry
Thank you, this was the solution for me. Also, I had to restart Xcode.Cointreau
Dude, I was about to go insane and you just saved me. Than you!Popp
Thank you! I was stuck on this for so longJonahjonas
I ended up for the second time here and once again this saved me. Thanks * 2.Popp
S
65

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!

Smew answered 11/9, 2019 at 11:45 Comment(2)
I just did steps 2, 4 & 7 and it worked for me. Thanks!Journalistic
Thanks a lot saved my day. I think @Journalistic has a point, 2, 4 & 7 also seem to do the trick.Osier
E
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.

Expediential answered 15/5, 2020 at 11:2 Comment(5)
Thanks. After updating the iOS version in the pod file, target, and project to the same value. It worked fine.Crosstie
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!Siouan
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 🙏Batangas
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!Mirellamirelle
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?Marmara
S
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"

Semblance answered 19/8, 2021 at 17:41 Comment(4)
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.Palsgrave
omg i was tryin to work it for months. thanks it workedPu
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.Perithecium
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 processMayne
B
13

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

Bogusz answered 1/3, 2023 at 7:34 Comment(1)
This has already been mentioned in other answers, such as this one.Concentre
E
7

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

Exequies answered 10/12, 2020 at 12:48 Comment(1)
Unfortunately, I tried it but not workedPolyethylene
C
5

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

Cindycine answered 20/6, 2023 at 8:26 Comment(2)
Worked! how is this solving the problem?Fawcett
Worked ! any further explanation why?Intuitionism
H
3

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://mcmap.net/q/92400/-the-ios-simulator-deployment-targets-is-set-to-7-0-but-the-range-of-supported-deployment-target-version-for-this-platform-is-8-0-to-12-1

Harvison answered 14/6, 2021 at 23:15 Comment(0)
P
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 ...
Palliative answered 17/2, 2022 at 2:58 Comment(0)
C
1

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.

Carney answered 16/8, 2023 at 12:47 Comment(0)
P
1

I faced the same problem. If you are using a Mac on M1/M2, try to open Xcode through Rosetta.

Right click on Xcode in applications folder -> Get Info -> turn on "Open with Rosetta" check box.

Polliwog answered 8/11, 2023 at 14:1 Comment(0)
A
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!

Alethaalethea answered 19/11, 2020 at 6:18 Comment(0)
E
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
Epistyle answered 7/1, 2022 at 8:43 Comment(0)
B
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
Bickford answered 18/9, 2022 at 12:20 Comment(1)
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 ^ ---Hawaii
V
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.

Vinyl answered 21/7, 2023 at 5:17 Comment(0)
C
0

You can try this solution:

  1. Terminal: pod cache clean --all
  2. Xcode: Product > Clean Build Folder
  3. Terminal: pod install

Try to build your project again

Chenab answered 25/3 at 10:20 Comment(0)
M
-2

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)

Methane answered 22/2, 2023 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.