SDK 43 Upgrade error: 'Cannot load underlying module for 'ExpoModulesCore' in ExpoModulesProvider

Please provide the following:

  1. SDK Version: 43
  2. Platforms(Android/iOS/web/all): iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

I’m updating from an older version of expo using unimodules to Expo SDK 43 using the bare workflow.

My app has two versions- a regular version which is working fine in the new SDK, and a ‘demo’ version which mocks API calls that is giving me trouble.

The demo app is built to have a separate scheme, but it shares a Podfile with the regular app.

I’m receiving the following error in the demo app

mobile/member/ios/Pods/Target Support Files/Pods-MemberDemo/ExpoModulesProvider.swift:8:8: error: cannot load underlying module for 'ExpoModulesCore'
import ExpoModulesCore
       ^

I have tried the following:

  • Busting and clearing caches with npm cache clean --force && rm -rf && rm -rf ~/Library/Caches/CocoaPods && rm -rf ~/Library/Developer/Xcode/DerivedData/* && cd member/ios && pod deintegrate && rm -rf Pods && pod install && cd ../.. && npm install && npm start --reset-cache
  • Explicitly declaring ExpoModulesCore as a pod (no luck)
  • Declaring use_frameworks! (gives other errors, breaks other things, too high of a lift)
  • Installing “expo-modules-core” explicitly as a dependency in package.json (no change)

Here’s the Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'

require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

# Post Install processing for Flipper
def flipper_post_install(installer)
  file_name = Dir.glob("*.xcodeproj")[0]
  app_project = Xcodeproj::Project.open(file_name)
  app_project.native_targets.each do |target|
    target.build_configurations.each do |config|
      cflags = config.build_settings['OTHER_CFLAGS'] || '$(inherited) '
      unless cflags.include? '-DFB_SONARKIT_ENABLED=1'
        puts 'Adding -DFB_SONARKIT_ENABLED=1 in OTHER_CFLAGS...'
        cflags << '-DFB_SONARKIT_ENABLED=1'
      end
      config.build_settings['OTHER_CFLAGS'] = cflags
    end
    app_project.save
  end
  installer.pods_project.save
end


["Member", "MemberDemo"].each do |name|
    target name do
        pod 'AFNetworking', '1.3.4'
        pod 'AMPopTip', '0.7.2'
        pod 'Analytics', '3.6.9'
        pod 'BugshotKit', :git => /redacted/
        pod 'CocoaLumberjack', '2.3.0'
        pod 'DTCoreText', '1.6.23'
        pod 'FirebaseAnalytics', '7.0.0'
        pod 'FirebaseCrashlytics', '7.0.0'
        pod 'kingpin', '0.1.4'
        pod 'LMGeocoder', '1.0.4'
        pod 'OHHTTPStubs', '4.8.0'
        pod 'RBBAnimation', '0.3.0'
        pod 'Reachability', '3.1.1'
        pod 'SDCAlertView', '2.5.3'
        pod 'TransitionKit', '1.1.1'     # Misfit connection manager state machine
        pod 'UIColor+Hex', '1.0.1'

        permissions_path = '../../node_modules/react-native-permissions/ios'
        pod 'Permission-Camera', :path => "#{permissions_path}/Camera.podspec"
        pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone.podspec"

        use_expo_modules!
        config = use_native_modules!

        use_react_native!(
          :path => config[:reactNativePath],
          # to enable hermes on iOS, change `false` to `true` and then install pods
          :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'  # false
        )

        # Enables Flipper.
        #
        # Note that if you have use_frameworks! enabled, Flipper will not work and
        # you should disable the next line.
        use_flipper!({ 'Flipper' => '0.91.2', 'Flipper-Folly' => '~> 2.6'})
    end
end

target "MemberTests" do
    pod 'OHHTTPStubs', '4.8.0'
end

post_install do |installer|
  flipper_post_install(installer)
  react_native_post_install(installer)
    # Fix for XCode 13.1
    find_and_replace(
      "../../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
      "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules",
      "_initializeModules:(NSArray<Class> *)modules"
    )
    find_and_replace(
      "../../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
      "RCTBridgeModuleNameForClass(strongModule))",
      "RCTBridgeModuleNameForClass(Class(strongModule)))"
    )
end

def find_and_replace(dir, findstr, replacestr)
  Dir[dir].each do |name|
      text = File.read(name)
      replace = text.gsub(findstr,replacestr)
      if text != replace
          puts "Fix: " + name
          File.open(name, "w") { |file| file.puts replace }
          STDOUT.flush
      end
  end
  Dir[dir + '*/'].each(&method(:find_and_replace))
end

Package.json

{
  "name": "app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
< redacted >
  },
  "dependencies": {
    "@ applications-developer/react-native-transformable-image": "0.1.1",
    "@ babel/cli": "7.7.7",
    "@ babel/core": "7.12.9",
    "@ react-native-async-storage/async-storage": "1.14.1",
    "@ react-native-community/geolocation": "2.0.2",
    "@ react-native-community/masked-view": "0.1.11",
    "@ react-native-community/viewpager": "4.2.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-plugin-react-intl": "5.1.14",
    "babel-preset-expo": "9.0.2",
    "buffer": "5.6.0",
    "contentful": "6.1.1",
    "deepmerge": "1.5.0",
    "expo": "43.0.0",
    "expo-local-authentication": "12.0.1",
    "expo-secure-store": "11.0.3",
    "final-form": "4.18.6",
    "final-form-arrays": "3.0.2",
    "final-form-calculate": "1.3.1",
    "intl": "1.2.5",
    "lodash": "4.17.11",
    "mathjs": "5.2.1",
    "mocha": "5.0.4",
    "mock-socket": "9.0.3",
    "moment": "2.13.0",
    "object-hash": "2.0.3",
    "opentok-react-native": "0.18.0",
    "phoneformat-react-native": "1.0.3",
    "pluralize": "7.0.0",
    "raygun4reactnative": "1.2.2",
    "react": "17.0.1",
    "react-devtools-core": "4.13.0",
    "react-dom": "17.0.1",
    "react-final-form": "6.3.3",
    "react-final-form-arrays": "3.1.1",
    "react-final-form-html5-validation": "1.0.3",
    "react-intl": "2.6.0",
    "react-native": "0.64.3",
    "react-native-collapsible": "0.10.0",
    "react-native-communications": "2.0.0",
    "react-native-gesture-handler": "1.8.0",
    "react-native-hyperlink": "0.0.12",
    "react-native-idle-timer": "2.1.6",
    "react-native-image-picker": "3.6.0",
    "react-native-inappbrowser-reborn": "3.4.0",
    "react-native-keychain": "6.1.1",
    "react-native-linear-gradient": "2.5.4",
    "react-native-maps": "0.26.1",
    "react-native-markdown-display": "6.0.1",
    "react-native-permissions": "2.1.3",
    "react-native-reanimated": "1.13.3",
    "react-native-render-html": "4.1.2",
    "react-native-restart": "0.0.24",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "2.18.1",
    "react-native-scrollable-mixin": "1.0.1",
    "react-native-scrollable-tab-view": "1.0.0",
    "react-native-snap-carousel": "3.7.5",
    "react-native-startup-time": "2.0.0",
    "react-native-svg": "12.1.0",
    "react-native-swipeout": "2.3.3",
    "react-native-webview": "11.13.0",
    "react-navigation": "4.4.4",
    "react-navigation-redux-helpers": "3.0.0",
    "react-navigation-stack": "2.10.4",
    "react-navigation-tabs": "2.11.1",
    "react-query": "3.8.3",
    "react-redux": "5.0.5",
    "redux": "3.5.2",
    "redux-batched-actions": "0.4.1",
    "redux-devtools-extension": "2.13.2",
    "redux-form": "7.4.2",
    "redux-mock-store": "1.3.0",
    "redux-thunk": "2.1.0",
    "urijs": "1.18.10",
    "url": "0.11.0",
    "uuid": "3.2.1"
  },
  "engines": {
    "node": "=12.22.10",
    "npm": "=6.14.16"
  },
  "expo": {
    "#": "see https://docs.expo.dev/bare/installing-expo-modules/#expo-modules-included-in-the--expo",
    "autolinking": {
      "exclude": [
        "expo-application",
        "expo-asset",
        "expo-constants",
        "expo-file-system",
        "expo-font",
        "expo-keep-awake"
      ]
    }
  },
  "devDependencies": {
    "@ testing-library/jest-native": "4.0.1",
    "@ testing-library/react-hooks": "2.0.3",
    "@ testing-library/react-native": "9.1.0",
    "@ wojtekmaj/enzyme-adapter-react-17": "0.6.7",
    "babel-jest": "25.1.0",
    "browser-resolve": "2.0.0",
    "enzyme": "3.10.0",
    "enzyme-to-json": "3.4.0",
    "graceful-fs": "4.2.0",
    "jest": "25.1.0",
    "jest-phabricator": "25.1.0",
    "mockdate": "2.0.5",
    "patch-package": "5.1.1",
    "react-test-renderer": "17.0.1",
    "solidarity": "2.1.0"
  }
}

We basically only use expo-local-authentication, which works fine in the regular app.

Here’s the output of expo doctor - nothing I think should result in this error

Tai-Klein:mobile etai$ expo doctor
Some dependencies are incompatible with the installed expo package version:
 - @ react-native-async-storage/async-storage - expected version: ~1.15.0 - actual version installed: 1.14.1
 - @ react-native-community/viewpager - expected version: 5.0.11 - actual version installed: 4.2.0
 - react-native-gesture-handler - expected version: ~1.10.2 - actual version installed: 1.8.0
 - react-native-maps - expected version: 0.28.1 - actual version installed: 0.26.1
 - react-native-reanimated - expected version: ~2.2.0 - actual version installed: 1.13.3
 - react-native-safe-area-context - expected version: 3.3.2 - actual version installed: 3.2.0
 - react-native-screens - expected version: ~3.8.0 - actual version installed: 2.18.1
 - react-native-svg - expected version: 12.1.1 - actual version installed: 12.1.0
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name ...]

Any ideas what to try?

Ah I got it working! I needed to add $(inherited) to OTHER_SWIFT_FLAGS for my demo scheme.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.