react-native: [v0.75.2] macOS (Catalyst) builds fail with `hermes.framework: bundle format is ambiguous (could be app or framework)`

Description

Migrating my libraries / app from RN@0.74 to the latest RN@0.75.2. When building for macOS (Catalyst) target my build fails with that error hermes.framework: bundle format is ambiguous (could be app or framework). I first posted the issue to the Hermes repo (https://github.com/facebook/hermes/issues/1492), but I was told there, it must be an issue on RN side, how it packages stuff.

Steps to reproduce

N/A

React Native Version

0.75.2

Affected Platforms

Build - MacOS

Output of npx react-native info

N/A

Stacktrace or Logs

N/A

Reproducer

N/A

Screenshots and Videos

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 41 (36 by maintainers)

Commits related to this issue

Most upvoted comments

nono, you have to download the tarball locally first! 😄

Hello there! I think I fixed the issue in the above PR. Can some of you (@birdofpreyru @hsjoberg) please try it? 🙏

You can download the hermes tarball from this link

And then you can install pods using this command:

HERMES_ENGINE_TARBALL_PATH=<path-to-downloaded-tar> bundle exec pod install

and try to build again.

Looking in the upload-artifacts repo, there are quite a few issues related to symlinks. It looks like that the default behavior for upload-artifacts is to follow symlinks and copy the file/folder the symlink points to. 🤦

I guess we have to add a custom step to revert those changes before creating the archive.

@hsjoberg that’s expected, as the framework format for Catalyst and MacOS is the same

@robertying Thanks for your investigation. That helps a lot.

React Native is responsible to package and distribute Hermes, so that’s actually a React Native issue.

What we changes w.r.t. 0.74 is that we had to move the whole build and release pipeline from CircleCI to GitHub Actions. The upload artifact action has some issues with symlinks, sadly and it has given us headaches already in main as well.

I’ll try to double check and do some extra checks today, but with React Universe coming up I’m not sure whether a fix will arrive soon. It might have to wait for a week or so.

Meanwhile, I’ll reopen the issue.

Well, I’m currently seeing the same symptoms as OP on react-native-macos 0.75.

From what I can tell react-native-macos pulls in iOS Hermes, so I thought this was related to OPs issue: https://github.com/microsoft/react-native-macos/blob/042cd6c36b23c21d20de628bc9756793e01ce282/packages/react-native/sdks/hermes-engine/hermes-utils.rb#L237-L257

Ok I think the symlinks are broken in the 0.75 hermes build.

To fix the symlinks, go to your project root and run:

cd ios/Pods/hermes-engine/destroot/Library/Frameworks/universal/hermes.xcframework/ios-arm64_x86_64-maccatalyst/hermes.framework
rm -r hermes Resources
ln -s Versions/Current/Resources Resources
ln -s Versions/Current/hermes hermes
cd Versions && rm -r Current && ln -s 0 Current # this is important

Verify hermes.framework looks like this:

drwxr-xr-x@ 5 rying  staff  160 Aug  5 06:55 .
drwxr-xr-x@ 3 rying  staff   96 Aug  5 06:55 ..
lrwxr-xr-x@ 1 rying  staff   26 Aug  5 06:55 Resources -> Versions/Current/Resources
drwxr-xr-x@ 4 rying  staff  128 Aug  5 06:55 Versions
lrwxr-xr-x@ 1 rying  staff   23 Aug  5 06:55 hermes -> Versions/Current/hermes

@cipolleschi does RN do the packaging for hermes or is this indeed a hermes issue (that we should forward back to the hermes repo)?

I guess, that stripping step does not take place if you target new Apple Silicon hardware? Btw, although the build fails, it turns out the app bundle it creates before the failure, runs seemingly fine 0.o

QQ: How do I repro it? I create a new app and try to archive for macCatalyst?

Yes, I just verified, a clean app created with @react-native-community/cli, macCatalyst build fails exactly this same way for me.

@sunshinezxq that looks likes an attempt to trick users into downloading a malware, I got it reported to GitHub 😃