ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.25k stars 429 forks source link

Steps to add macos target don't work #182

Closed JosephAustin closed 6 years ago

JosephAustin commented 6 years ago

There are huge conflicts that happen when you try to add a macos target alongside ios/android.

Following steps, I create a project using create-react-native-app and then making a react-native-macos init project.

The native app uses App.js so I got macos app to reach the same code by modifying the xcode project to look for App before building:

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"App" fallbackResource:nil];

Next, as the instructions say, I merge macos app into native app, and put rn-cli.config.js in the root as specified. I also redo npm install so it will grab the macos dependency right.

Then this happens:

error: bundling: UnableToResolveError: Unable to resolve module MaskedViewIOS from <my path here>/node_modules/react-native/Libraries/react-native/react-native-implementation.js: Module does not exist in the module map or in these directories

This might be related to https://github.com/facebook/react-native/issues/4968 To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.

I try those steps, no good. I believe the presence of the regular react-native dependency conflicts, but im not sure.

JosephAustin commented 6 years ago

ios continues to work. Here is the relevant stuff in my package.json:

"devDependencies": { "react-native-scripts": "1.7.0", "jest-expo": "^22.0.0", "react-test-renderer": "16.0.0-beta.5" }, "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js", "scripts": { "start": "react-native-scripts start", "eject": "react-native-scripts eject", "android": "react-native-scripts android", "ios": "react-native-scripts ios", "test": "node node_modules/jest/bin/jest.js --watch" }, "jest": { "preset": "jest-expo" }, "dependencies": { "expo": "^22.0.2", "react": "16.0.0-beta.5", "react-native": "^0.49.5", "react-native-macos": "0.16.0" }

JosephAustin commented 6 years ago

I will close this if "How do I add react-native-macos to an existing React Native project?" is able to solve my issues. I missed it somehow.

JosephAustin commented 6 years ago

closing because im going to comment in the other ticket