microsoft / react-native-macos

A framework for building native macOS apps with React.
https://microsoft.github.io/react-native-windows/
MIT License
3.49k stars 135 forks source link

"Fatal error: 'ExpoModulesCore/ExpoModulesCore.h' file not found" in run-macos #2076

Closed emmanuelproulx closed 7 months ago

emmanuelproulx commented 7 months ago

Environment

react-native -v:
react-native-cli: 2.0.1
react-native: 0.73.2

npm ls react-native-macos:
mynewproject@1.0.0 /Users/me/Documents/mynewproject
└── react-native-macos@0.73.16

node -v:
v21.5.0

npm -v:
10.2.4

yarn --version:
1.22.19

xcodebuild -version:
Xcode 15.2
Build version 15C500b

Steps to reproduce the bug

Following the steps in https://microsoft.github.io/react-native-windows/docs/rnm-getting-started

  1. I started from a blank project I just created with Create React Native App using instructions here: https://github.com/expo/create-react-native-app
  2. I installed react-native-macos with npx react-native@latest init --template "react-native@^0.71.0"
  3. I added support for macos to my project by doing cd mynewproject then npx react-native-macos-init. This created the macos directory.
  4. I added support for Windows as well: npx react-native-windows-init --overwrite
  5. I ran the project with: npx react-native run-macos

Expected Behavior

A native Mac app running my blank project.

Actual Behavior

Result: Error

/Users/me/Documents/mynewproject/node_modules/expo/ios/EXAppDefinesLoader.m:5:9: fatal error: 'ExpoModulesCore/ExpoModulesCore.h' file not found

import <ExpoModulesCore/ExpoModulesCore.h>

    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.

Reproducible Demo

No response

Additional context

I tried to fix it using advice found online but all the advice was regarding the iOS platform, not MacOS. So none of it worked. I tried to run pod install from the macos folder, no error.

I also tried to build with XCode with the same error.

Saadnajmi commented 7 months ago

Maybe @tsapeta can comment more here, but React Native macOS (and Expo) doesn't currently support adding macOS to an expo-created iOS app. You would have to run react-native-macos-init on top of an app made with the RN CLI (AKA, redo your step 1)

tsapeta commented 7 months ago

Hey! Yeah, that's correct – we don't support adding macOS to expo-created projects yet. We're working on this though. Could you please open an issue in https://github.com/expo/expo repo? It's definitely not an issue in react-native-macos itself, so I think this one can be closed.

Andriiklymiuk commented 6 months ago

well, maybe someone figured out, how to add macos to expo project somehow?

bpeck81 commented 3 months ago

Bump

Saadnajmi commented 2 months ago

Update (thanks @tsapeta !)

I see that there is this example repo of an expo macOS app: https://github.com/tsapeta/expo-macos-example

And I see this commit: https://github.com/tsapeta/expo-macos-example/commit/6de11dc8d6c024dc0af53e5e82379bc096f75524

Which looks like it links the native code to get that header and fix the above error. Seems like you need to add this line to your pod file:

require File.join(File.dirname(node --print "require.resolve('../../../expo/packages/expo/package.json')"), "scripts/autolinking")