others-how to solve Could not build module 'nanopb' built with cocoapods in iOS app

Problem

When we develop iOS app with Google Firebase/Analytics integrated, when build it with cocoapods , sometimes, we got this problem:

Could not build module 'nanopb'
....

Environment

  • iOS programming
  • XCode 11.3
  • Swift 5

And the cocoapod pod file is:

# Uncomment the next line to define a global platform for your project
platform :ios, '13.2'

target 'testapp' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # add the Firebase pod for Google Analytics
  pod 'Firebase/Analytics'
  # add pods for any other desired Firebase products
  # https://firebase.google.com/docs/ios/setup#available-pods

end

Reason

You are using old version of cocoapods, please upgrade to the latest version

Solution

  • You can upgrade the cocoapods as follows:

    • To update CocoaPods you simply install the gem again
      • $ [sudo] gem install cocoapods
    • Or for a pre-release version
      • $ [sudo] gem install cocoapods –pre
  • pod install –repo-update , according to this from Scriptable:

    • pod repo update updates the spec repos located at ~/.cocoapods/repos in your home folder.

      Updates the local clone of the spec-repo NAME. If NAME is omitted this will update all spec-repos in ~/.cocoapods/repos.

      The repo is basically a list of all pods and versions available. I have just encountered an error in our CI builds because the repo did not include a spec for a library I have just added. By running pod repo update it now knows of this newer version and can continue to install it.

      Running pod repo update in your documents folder will not do anything in that folder. It will update its pod spec references in your ~/.cocoapods/repos folder only.