microsoft / react-native-macos

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

Testing release 0.74.1: multiple errors when creating a new project #2164

Open morukutsu opened 4 weeks ago

morukutsu commented 4 weeks ago

Environment

react-native -v: 0.74.1
npm ls react-native-macos: 0.74.1
node -v: v22.6.0
npm -v: 10.8.2
yarn --version: 1.22.22
xcodebuild -version: Xcode 15.4 Build version 15F31d

Steps to reproduce the bug

Hello. I am testing the new release 0.74.1 with a clean project.

Test sequence:

# Install RN
npx react-native@latest init test_project --version 0.74.1
npx react-native-macos-init --version 0.74.1

The second command will fail with the same error as https://github.com/microsoft/react-native-macos/issues/2152. Afaik, this one should have been fixed with a fix to react-native-macos-init. Should be the package be updated on NPM as well? (see https://www.npmjs.com/package/react-native-macos-init?activeTab=versions)

# Previous command failed, to workaround:
yarn add "react-native-macos@0.74.1"

# And rerun to proceed
npx react-native-macos-init --version 0.74.1

Then it fails with another error:

Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: Invalid `Podfile` file: uninitialized constant Pod::Podfile::FlipperConfiguration.

 #  from /Users/moru/Documents/Work/test_project/macos/Podfile:18
 #  -------------------------------------------
 #      # Flipper is not compatible w/ macOS
 >      :flipper_configuration => FlipperConfiguration.disabled,
 #      # An absolute path to your application root.
 #  -------------------------------------------

Commenting the line ":flipper_configuration => FlipperConfiguration.disabled" in the podfile will allow the build to proceed. However, on my end running npx react-native run-macos then does not open the app. It seems there's at least an issue with the podfile, but atm I don't have a good enough understanding of the system to debug it.

Thank you!

Expected Behavior

No response

Actual Behavior

No response

Reproducible Demo

No response

Additional context

No response

Saadnajmi commented 4 weeks ago

Indeed, :flipper_configuration was removed, so I think if that's still showing up in our template project, we need to remove it.

morukutsu commented 3 weeks ago

I had a look at https://github.com/microsoft/react-native-macos/blob/main/packages/rn-tester/Podfile to fix the Podfile, as it has been updated fairly recently.

However, even after removing :flipper_configuration and getting a successful build, when running npx react-native run-macos, nothing happens.

test_project % npx react-native run-macos

  WARNING: You should run npx react-native@latest to ensure you're always using the most current version of the CLI. NPX has cached version (0.74.1) != current release (0.75.1)

warn Argument --configuration has been deprecated and will be removed in a future release, please use --mode instead.
info Found Xcode workspace "test_project.xcworkspace"
info Building (using "xcodebuild -workspace test_project.xcworkspace -configuration Debug -scheme test_project-macOS")
(node:82100) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
........................................
2024-08-17 14:41:34.864 xcodebuild[82150:2765339]  DVTPlugInQuery: Requested but did not find extension point with identifier 'Xcode.InterfaceBuilderBuildSupport.PlatformDefinition'. This is programmer error; code should only request extension points that are defined by itself or its dependencies.
info Launching app "org.reactjs.native.test-project" from "/Users/moru/Library/Developer/Xcode/DerivedData/test_project-gxmjruklmbhydfapvfduwvvevpsy/Build/Products/Debug/test_project.app"
success Successfully launched the app

image

The app opens, there is a toolbar but no window. The previous version does work, with similar steps.

Thank you!

hsjoberg commented 3 weeks ago

@morukutsu I think the problem is that bundleURL func is not defined in AppDelegate.mm.

Taken from https://react-native-community.github.io/upgrade-helper/?from=0.73.9&to=0.74.5#RnDiffApp-ios-RnDiffApp-AppDelegate.mm:

- (NSURL *)bundleURL
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}

Here's the error I got from Xcode.

An uncaught exception was raised
Subclasses must implement a valid getBundleURL method
(
    0   CoreFoundation                      0x000000018e82f2ec __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018e316788 objc_exception_throw + 60
    2   CoreFoundation                      0x000000018e82f1dc +[NSException exceptionWithName:reason:userInfo:] + 0
    3   rnmacos74                           0x000000010343477c -[RCTAppDelegate bundleURL] + 52
    [...]