microsoft/react-native-test-app

react-native-macos@0.72 cannot be added because it does not exist or is unsupported

jparismorgan opened this issue · 3 comments

What happened?

I am getting react-native-macos@0.72 cannot be added because it does not exist or is unsupported when I try to just install for Mac OS.

Version

2.5.14

What platforms are you seeing this issue on?

  • Android
  • iOS
  • macOS
  • Windows

System Information

~/repo/foo/apps/osx$ npx react-native info                                                           
info Fetching system and libraries information...
System:
  OS: macOS 13.3
  CPU: (12) arm64 Apple M2 Pro
  Memory: 2.28 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: ~/.nvm/versions/node/v18.16.0/bin/node
  Yarn:
    version: 1.22.19
    path: ~/.nvm/versions/node/v18.16.0/bin/yarn
  npm:
    version: 9.5.1
    path: ~/.nvm/versions/node/v18.16.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Steps to Reproduce

Create a package.json:

{
  "name": "osx",
  "private": true,
  "scripts": {
    "init-test-app": "init-test-app"
  },
  "devDependencies": {
    "mkdirp": "^1.0.0",
    "react-native-test-app": "^2.5.14"
  },
  "dependencies": {}
}

then run this:

~/repo/foo/apps/osx$ ls
package.json
~/repo/foo/apps/osx$ pnpm i
Scope: all 9 workspace projects
 WARN  deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
../..                                    | Progress: resolved 1261, reused 1184, downloaded 0, added 0, done

devDependencies:
+ mkdirp 1.0.4 (3.0.1 is available)
+ react-native-test-app 2.5.14

Done in 5.2s
~/repo/foo/apps/osx$ pnpm run init-test-app

> osx@ init-test-app /Users/parismorgan/repo/foo/apps/osx
> init-test-app

✔ What is the name of your app? … Foo
✔ Which platforms do you need test apps for? › macOS
✔ Where should we create the new project? … /Users/parismorgan/repo/foo/apps/osx
[!] react-native-macos@0.72 cannot be added because it does not exist or is unsupported

Code of Conduct

  • I agree to follow this project's Code of Conduct
tido64 commented

Hi @jparismorgan, the latest version of react-native-macos is currently 0.71.29. The 0.72 series has not been released yet. For available versions, see: https://www.npmjs.com/package/react-native-macos?activeTab=versions

Isn't this a bug in react-native-test-app ^2.5.14 then? I didn't specify which version of react-native-macos to use, I just wanted to initialize a project. Shouldn't react-native-test-app just pick a valid version for me to use?

As a side note, I switched to ^2.5.9 and was able to create the project. But I'm still not able to build - it seems that the macos/ folder is missing and the podfile has an error:

~/repo/foo/apps/app$ pnpm i                                                                                                                                                                                                                          
Scope: all 10 workspace projects
../osx                                   |  WARN  deprecated source-map-resolve@0.5.3
../osx                                   |  WARN  deprecated uglify-es@3.3.9
../osx                                   |  WARN  deprecated source-map-url@0.4.1
../osx                                   |  WARN  deprecated resolve-url@0.2.1
../osx                                   |  WARN  deprecated urix@0.1.0
../..                                    |   +1   -1 +-
../..                                    | Progress: resolved 1459, reused 1384, downloaded 0, added 0, done

dependencies:
+ react 18.2.0
+ react-native 0.71.12 (0.72.3 is available)
+ react-native-macos 0.71.26 (0.71.29 is available)

devDependencies:
+ @babel/core 7.22.9
+ @babel/preset-env 7.22.9
+ @babel/runtime 7.22.6
+ @react-native-community/eslint-config 3.2.0
+ @tsconfig/react-native 2.0.2 (3.0.2 is available)
+ @types/jest 29.2.1 (29.5.3 is available)
+ @types/react 18.2.18
+ @types/react-test-renderer 18.0.0
+ babel-jest 29.2.1 (29.6.2 is available)
+ eslint 8.46.0
+ jest 29.2.1 (29.6.2 is available)
+ metro-react-native-babel-preset 0.73.10 (0.77.0 is available)
+ prettier 2.4.1 (3.0.1 is available)
+ react-test-renderer 18.2.0
+ typescript 4.8.4 (5.1.6 is available)

Done in 5.9s
~/repo/foo/apps/app$ pnpm run macos                                                                                                                                                                                                                  

> Foo@0.0.1 macos /Users/parismorgan/repo/foo/apps/app
> react-native run-macos --scheme Foo

error macOS project folder not found. Are you sure this is a React Native project?.
info Run CLI with --verbose flag for more details.
 ELIFECYCLE  Command failed with exit code 1.
~/repo/foo/apps/app$ ls                                                                                                                                                                                                                         
App.tsx                Podfile                app.json               babel.config.js        index.js               metro.config.js        node_modules           package.json           react-native.config.js
~/repo/foo/apps/app$ pod install                                                                                                                                                                                                                     

[!] Invalid `Podfile` file: Cannot find module '@react-native-community/cli-platform-ios'.

 #  from /Users/parismorgan/repo/foo/apps/app/Podfile:5
 #  -------------------------------------------
 #  
 >  use_test_app!
 #  -------------------------------------------
tido64 commented

Sorry for closing this issue too early.

You're right in that we should probably not pick 0.72 if it's unavailable. If you don't provide --version, we currently look at the react-native version that is being used in the monorepo, and if that doesn't exist, use the latest version of react-native to determine what's currently available. This does assume that if a minor version is available for react-native, it's available for all other platforms as well. It's a bit simplified, and it obviously fails in this scenario. As a quick workaround, you can explicitly specify --version to get around this.

To fully address this, I think we need to add logic to determine the greatest common version, and make sure the user understands that we may not be able to use the latest version.