Kauna Mohammed
Kauna Mohammed

Reputation: 1137

How to fix cocoapod .modulemap file not found

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 ->

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

Upvotes: 107

Views: 157907

Answers (24)

Michael Mao
Michael Mao

Reputation: 483

For me, I was building on the Apple M2 chip. After several hours of attempts, I found that I could successfully build on a real device, but the build failed on the simulator. When I commented out the following code, the build also succeeded on the simulator.

# https://stackoverflow.com/questions/72344149/how-to-solve-xcode-build-error-undefined-symbols-for-architecture-x86-64
# Comment this line due to a build failure on Apple M2 Pro with an error: "VisionCamera.modulemap not found."
# config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"

close Xcode

rm -rf ~/Library/Developer/Xcode/DerivedData/* && rm -rf ~/Library/Caches/org.swift.swiftpm

start Xcode

Upvotes: 2

Fawaz
Fawaz

Reputation: 3560

I was stuck at this issue while upgrading to latest react native version 0.76.5. The issue was had to delete this settings in Xcode > build settings

Apple Clang - Custom compiler flags > Other C flags

Empty or remove this ^^

Upvotes: 0

Muhammad Ali
Muhammad Ali

Reputation: 1151

Go to Target -> Build Settings -> search for "Preprocessor Macros" --> remove available values for all (adhoc, App Store, release, debug) and add $(inherited)

Upvotes: 1

TheSchnaz
TheSchnaz

Reputation: 31

This issue caused me a lot of frustration. I was able to fix it by wiping my computer, restoring it via migration assistant, installing Rosetta (softwareupdate --install-rosetta), and selecting Rosetta Destinations in Xcode (Product -> Destination -> Destination Architectures -> Show Rosetta Destination).

Upvotes: 1

Z Dong
Z Dong

Reputation: 1

I was able to solve this problem by directly running the xcworkspace file directly

Upvotes: 0

David R. Hedges
David R. Hedges

Reputation: 906

In my case—and I'm not sure how this ever worked—the fastlane-based CI pipeline was producing this error, which I solved by simply adding the cocoapods action to the Fastfile, which "Runs pod install for the project." The default values were fine for me, so literally the change was:

diff --git a/fastlane/Fastfile b/fastlane/Fastfile
index 0ece390..7576964 100644
--- a/fastlane/Fastfile
+++ b/fastlane/Fastfile
@@ -7,6 +7,8 @@ xcodes(
   select_for_current_build_only: true,
 )
 
+cocoapods
+
 platform :ios do
   keychain_name = "job#{ENV["CI_JOB_ID"]}.keychain"
   keychain_was_created = false

Upvotes: 0

Wajid Ali
Wajid Ali

Reputation: 91

I faced this issue on M1 and my Xcode version is 15.1 I resolved it with the following path:

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

Then clean your build folder and then run your project.

Upvotes: 1

Vladimir Sukanica
Vladimir Sukanica

Reputation: 595

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

Upvotes: 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.

Upvotes: 1

Stonz2
Stonz2

Reputation: 6396

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.

Upvotes: 1

ajw
ajw

Reputation: 2702

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.

Upvotes: 0

cucereanum
cucereanum

Reputation: 223

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

Upvotes: 10

ahmnouira
ahmnouira

Reputation: 3441

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

Upvotes: 15

evgenii
evgenii

Reputation: 303

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)

Upvotes: -2

Areej Sadaqa
Areej Sadaqa

Reputation: 1

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

Upvotes: 0

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"

Upvotes: 37

friederbluemle
friederbluemle

Reputation: 37147

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

xcodebuild -workspace ...

instead of just xcodebuild or

xcodebuild -project ...

Upvotes: 2

khaled-hbaieb
khaled-hbaieb

Reputation: 17

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

Upvotes: 0

German
German

Reputation: 300

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

Upvotes: 3

Thermech
Thermech

Reputation: 4451

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

Upvotes: 7

Sirisha
Sirisha

Reputation: 431

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!

Upvotes: 0

Josip B.
Josip B.

Reputation: 2464

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.

Upvotes: 35

Eric Wiener
Eric Wiener

Reputation: 5987

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.

Upvotes: 278

Ton Snoei
Ton Snoei

Reputation: 3195

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!

Upvotes: 72

Related Questions