expo: iOS build failed after upgrading to sdk 44(x86_64-apple-ios-simulator not found)

Summary

I recently upgraded expo sdk to 44.0.4 (Thanks to @Kudo in #15749 ) And the previous error has gone lovely, however, different error occurred.

The error message is :

/Users/(userName, projectPath)/ios/Pods/Target Support Files/Pods-(projectName)/ExpoModulesProvider.swift:8:8: Could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator, at: /Users/(userName)/Library/Developer/Xcode/DerivedData/(projectName)-fpsfqwuotwecxtbofsfpimvwsbrn/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.framework/Modules/ExpoModulesCore.swiftmodule

I think that the library ExpoModulesCore is only for x86 (intel chip) environment. As might you think, I’m using M1 Mac. Is there any extra work to do if I run Expo 44.0.0 in M1? It works fine when 43.0.0. Thanks in advance.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

bare

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

44.0.4

Environment

Expo CLI 5.0.3 environment info: System: OS: macOS 12.1 Shell: 5.8 - /bin/zsh Binaries: Node: 16.13.1 - /usr/local/bin/node Yarn: 2.4.2 - /usr/local/bin/yarn npm: 8.1.2 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7935034 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild npmPackages: @expo/metro-config: ^0.3.0 => 0.3.0 babel-preset-expo: 9.0.1 => 9.0.1 expo: ^44.0.4 => 44.0.4 react: 17.0.1 => 17.0.1 react-dom: 17.0.1 => 17.0.1 react-native: 0.64.3 => 0.64.3 react-native-web: 0.17.1 => 0.17.1 npmGlobalPackages: expo-cli: 5.0.3 Expo Workflow: bare

Reproducible demo

my pod file is :

# require_relative '../node_modules/react-native/scripts/react_native_pods'
# require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
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")

$RNFirebaseAsStaticFramework = true
$RNFirebaseAnalyticsWithoutAdIdSupport=true
$FirebaseSDKVersion = '8.9.1'

platform :ios, '12.0'
pod 'Firebase/Analytics'

target '(projectName)' do
  # use_unimodules!
  use_expo_modules!
  config = use_native_modules!

  use_react_native!(:path => config[:reactNativePath], :hermes_enabled => false)

  pod 'RNPhotoEditor', :path => '../node_modules/react-native-photo-editor/ios'
  use_frameworks! :linkage => :static

  pod 'iOSPhotoEditor', :git => '(custom repository)', :branch => 'master'
  pod 'TZImagePickerController', :git => '(custom repository)', :branch => 'master'
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly"
  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
#  use_flipper!({ 'Flipper' => '0.74.0' })
  post_install do |installer|
    react_native_post_install(installer)
    installer.pods_project.targets.each do |target|
      if target.name.include?('iOSPhotoEditor')
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5'
        end
      end
      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
#    flipper_post_install(installer)
  end
  
  # Follow [Flipper iOS Setup Guidelines](https://fbflipper.com/docs/getting-started/ios-native)
  # This is required because iOSPhotoEditor is implemented using Swift and we have to use use_frameworks! in Podfile
  $static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly',
    'CocoaAsyncSocket', 'ComponentKit', 'Flipper-DoubleConversion',
    'Flipper-Glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Flipper-Fmt', 'Flipper-Boost-iOSX', 'Yoga', 'YogaKit',
    'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native', 'EXPermissions','UMPermissionsInterface']
  
  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    installer.pod_targets.each do |pod|
        if $static_framework.include?(pod.name)
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
        if pod.name.start_with?('RNFB') || pod.name.start_with?('KakaoSDK')
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
        if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
          def pod.build_type;
            # Uncomment the line corresponding to your CocoaPods version
            Pod::BuildType.static_library # >= 1.9
            # Pod::Target::BuildType.static_library # < 1.9
          end
        end
      end
  end


  # use_flipper!
  # post_install do |installer|
  # flipper_post_install(installer)
  # end

end

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 8
  • Comments: 21 (2 by maintainers)

Most upvoted comments

I finally found the solution. When I added the following codes on Podfile, the error has gone and works charmingly.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
    end
  end
end

On Apple Silicon (M1/M2) I was fighting with Expo builds for days, my final working solution was as follows (using react-native-maps and react-native-firebase):

I could not figure out how to inject the post_install into the Podfile without getting a “duplicate post_install error”. I also didn’t want to persist this in the project since my cloud builds run on Intel.

Adding x86_64 in Build Settings > Architecture fixed the issue for me. No additional setup needed.

"expo": "~48.0.15",
"react-native": "0.71.7",
Screenshot 2023-05-07 at 13 41 13

We are still hitting this even if you wipe out the /ios folder on every run

› Executing BurgerKingdev » Start Packager on http://localhost:8081

❌  (ios/Pods/Target Support Files/Pods-BurgerKingdev/ExpoModulesProvider.swift:8:8)

   6 |  */
   7 | 
>  8 | import ExpoModulesCore
     |        ^ could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: /Users/rbifp004/Library/Developer/Xcode/DerivedData/BurgerKingdev-dbklgwdlrkcoafdqskxieonwmlgs/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.swiftmodule
   9 | import ExpoAdapterBranch
  10 | import ExpoApplePay
  11 | import ExpoCapacitorStorage

› Compiling BurgerKingdev » noop-file.swift

❌  (ios/Pods/Target Support Files/Pods-BurgerKingdev/ExpoModulesProvider.swift:8:8)

   6 |  */
   7 | 
>  8 | import ExpoModulesCore
     |        ^ could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: /Users/rbifp004/Library/Developer/Xcode/DerivedData/BurgerKingdev-dbklgwdlrkcoafdqskxieonwmlgs/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.swiftmodule
   9 | import ExpoAdapterBranch
  10 | import ExpoApplePay
  11 | import ExpoCapacitorStorage

› Compiling BurgerKingdev » ExpoModulesProvider.swift

❌  (ios/Pods/Target Support Files/Pods-BurgerKingdev/ExpoModulesProvider.swift:8:8)

   6 |  */
   7 | 
>  8 | import ExpoModulesCore
     |        ^ could not find module 'ExpoModulesCore' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at: /Users/rbifp004/Library/Developer/Xcode/DerivedData/BurgerKingdev-dbklgwdlrkcoafdqskxieonwmlgs/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.swiftmodule
   9 | import ExpoAdapterBranch
  10 | import ExpoApplePay
  11 | import ExpoCapacitorStorage


❌  error: emit-module command failed with exit code 1 (use -v to see invocation)



› 4 error(s), and 0 warning(s)

Failed to build iOS project. "xcodebuild" exited with error code 65.

Did anyone achieve a solution?

@lliamscholtz your notes helped a lot to find a solution. I have made an additional plugin to make it work with Expo 48

const fs = require("fs");
const path = require("path");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");
const configPlugins = require("expo/config-plugins");

const code = `    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
      end
    end`;

module.exports = (expoConfig) => {
    return configPlugins.withDangerousMod(expoConfig, [
        "ios",
        async (config) => {
            const filePath = path.join(
                config.modRequest.platformProjectRoot,
                "Podfile"
            );
            const contents = fs.readFileSync(filePath, "utf-8");

            const addCode = generateCode.mergeContents({
                tag: "withReactAppleIosSimulatorNotFoundFix",
                src: contents,
                newSrc: code,
                anchor: /\s*__apply_Xcode_12_5_M1_post_install_workaround\(installer\)/i,
                offset: 1,
                comment: "#",
            });

            if (!addCode.didMerge) {
                console.error(
                    "ERROR: Cannot add withReactAppleIosSimulatorNotFoundFix to the project's ios/Podfile because it's malformed."
                );
                return config;
            }

            fs.writeFileSync(filePath, addCode.contents);

            return config;
        },
    ]);
};

I finally found the solution. When I added the following codes on Podfile, the error has gone and works charmingly.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
    end
  end
end

It worked for me, thank bro!

I ran into this same issue so I first removed the DerivedDate folder which just ended up giving me a different error, found that for whatever reason in Xcode arm64 was set under excluded architectures. Removing that fixed it for me and app was able to finally build CleanShot 2022-09-07 at 15 55 17@2x

I finally found the solution. When I added the following codes on Podfile, the error has gone and works charmingly.

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
    end
  end
end

If I use this solution, the app builds correclty, but the DocumentPicker don’t work in the simulator.

There is an error in this code:

https://github.com/expo/expo/blob/62732c47261012540bdcc9685ee1716f29a53279/packages/expo-document-picker/ios/EXDocumentPicker/EXDocumentPickerModule.m#L16-L36

In some research, I found something related to [UTType typeWithMIMEType] in M1: https://developer.apple.com/forums/thread/685968

Has anyone ever experienced this?

hey @Kudo I’m now experiencing this too. Should we re-open and discuss here or would you like a new issue?

In case useful for anyone running into a similar error, we were having this same build error (could not find module ‘ExpoModulesCore’ for target…) against Expo 49.0.x when building on Mac M1/M2s.

8 | import ExpoModulesCore | ^ could not find module ‘ExpoModulesCore’ for target ‘x86_64-apple-ios-simulator’; found: arm64-apple-ios-simulator, at: /Users/juliandiggle/Library/Developer/Xcode/DerivedData/expo49ExampleNov23-cldqpnagjaopmvfkrvltqhnisjyh/Build/Products/Debug-iphonesimulator/ExpoModulesCore/ExpoModulesCore.framework/Modules/ExpoModulesCore.swiftmodule 9 | import EXConstants

We found that modifying the Podfile to include setting ONLY_ACTIVE_ARCH to NO for all Pods targets as mentioned above by @douglasjunior would help.

But we finally tracked down the cause of the issue to be related to the version of the Google Cast SDK that one of the dependencies of our project was using.

We use expo-build-properties to add an additional dependency on a custom native iOS Framework via the extraPods setting in our app.json. That framework depends on the native Google Cast library, but was declaring the dependency in its podspec as:

s.dependency 'google-cast-sdk-no-bluetooth'

When we update this to the following we can now build on M1/M2 machines

s.dependency 'google-cast-sdk-dynamic-xcframework-no-bluetooth'

So if you are depending any native iOS libraries be sure that you are correctly specifying a version which supports compilation on M1/M2s

Adding x86_64 in Build Settings > Architecture fixed the issue for me. No additional setup needed.

"expo": "~48.0.15",
"react-native": "0.71.7",
Screenshot 2023-05-07 at 13 41 13

This didn’t work for me, I lots of errors

Adding x86_64 in Build Settings > Architecture fixed the issue for me. No additional setup needed.

"expo": "~48.0.15",
"react-native": "0.71.7",
Screenshot 2023-05-07 at 13 41 13

It works for me. Thanks.

Oh my god I tried everything but as @danjenkins said, remove pods before yarn ios

Actually, after clearing out my Pods directory it did succeed. So yes adding the relevant part of the post_install to what you’ve already got does work. Does make me wonder why that’s needed at all though @Kudo

@iKoru i’m glad you found a solution. let me close this. if you encounter other problems, please open new issue. thank you!