facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.24k stars 24.34k forks source link

Fresh install - build fails on M1 Mac #31438

Closed setharell closed 3 years ago

setharell commented 3 years ago

Description

If I try build a fresh RN app for iOS, I get linking errors.

ld: warning: Could not find or use auto-linked library 'swiftFoundation' ld: warning: Could not find or use auto-linked library 'swiftDarwin' ld: warning: Could not find or use auto-linked library 'swiftUIKit' ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation' ld: warning: Could not find or use auto-linked library 'swiftQuartzCore' ld: warning: Could not find or use auto-linked library 'swiftCore' ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics' ld: warning: Could not find or use auto-linked library 'swiftObjectiveC' ld: warning: Could not find or use auto-linked library 'swiftDispatch' ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport' ld: warning: Could not find or use auto-linked library 'swiftCoreImage' ld: warning: Could not find or use auto-linked library 'swiftMetal'

There are also about 23 errors, all related to not being able to find these libraries

Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral

React Native version:

System: OS: macOS 11.2.3 CPU: (8) arm64 Apple M1 Memory: 578.42 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.0.0 - /usr/local/bin/node Yarn: Not Found npm: 7.10.0 - /opt/homebrew/bin/npm Watchman: 4.9.0 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. npx react-native init TestProject
  2. create a .swift file in the project root, and add the bridging header
  3. clean the build folder
  4. npx react-native run-ios

Expected Results

The app should build and run on the iOS emulator

VishalMahesh commented 3 years ago

Did you find any solution ? Facing same issue.

rampellisrinu commented 3 years ago

Having same issue after updating macOS (11.3 (20E232)) on M1. My project was working fine before update and now am seeing lots of these error while building app for iOS and not able to run it.

The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.5.99. (in target 'Flipper-Glog' from project 'Pods').

Have tried all solutions like these https://github.com/CocoaPods/CocoaPods/issues/9884 but no luck.

setharell commented 3 years ago

I ended up getting my app to build by using Rosetta2 for everything. I opened the terminal using Rosetta2, deleted the node_modules directory, deleted Pods directory, deleted podfile.lock. Then ran npm install and pod install using the Rosetta2 terminal. Once I did that, npx react-native run-ios builds successfully. I should mention that when I tried to build using Flipper, the build failed. When I remove use_flipper!() from my Podfile, that's when my build succeeded.

I guess that software packages still haven't caught up to be compatible with M1 chips, so for now Rosetta2 is the solution.

rampellisrinu commented 3 years ago

Thank you so much for the help, I have managed to run the app with above steps. I have tried the same steps before but the order was a bit different. Steps I followed to fix the problem.

it worked.

VadimDyliko commented 3 years ago

Yeah, facing the same issue. Commenting use_flipper!() solved that issue, but it's not a solution. I like to use flipper :)

Helyios commented 3 years ago

Facing the same issue, I hope it get resolved soon because don't really want to do without flipper...

JosePBrotons commented 3 years ago

Description

If I try build a fresh RN app for iOS, I get linking errors.

ld: warning: Could not find or use auto-linked library 'swiftFoundation' ld: warning: Could not find or use auto-linked library 'swiftDarwin' ld: warning: Could not find or use auto-linked library 'swiftUIKit' ld: warning: Could not find or use auto-linked library 'swiftCoreFoundation' ld: warning: Could not find or use auto-linked library 'swiftQuartzCore' ld: warning: Could not find or use auto-linked library 'swiftCore' ld: warning: Could not find or use auto-linked library 'swiftCoreGraphics' ld: warning: Could not find or use auto-linked library 'swiftObjectiveC' ld: warning: Could not find or use auto-linked library 'swiftDispatch' ld: warning: Could not find or use auto-linked library 'swiftSwiftOnoneSupport' ld: warning: Could not find or use auto-linked library 'swiftCoreImage' ld: warning: Could not find or use auto-linked library 'swiftMetal'

There are also about 23 errors, all related to not being able to find these libraries

Undefined symbol: protocol descriptor for Swift.ExpressibleByFloatLiteral

React Native version:

System: OS: macOS 11.2.3 CPU: (8) arm64 Apple M1 Memory: 578.42 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 16.0.0 - /usr/local/bin/node Yarn: Not Found npm: 7.10.0 - /opt/homebrew/bin/npm Watchman: 4.9.0 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. npx react-native init TestProject
  2. create a .swift file in the project root, and add the bridging header
  3. clean the build folder
  4. npx react-native run-ios

Expected Results

The app should build and run on the iOS emulator

I was able to run the project by commenting the use_flipper line in the Podfile and also by removing the Library Search Paths in the project, I don't know how It could impact deleting those properties but for now the project is running without any issues and the linking warnings are completely gone.

tintheanh commented 3 years ago

^ Facing the same issue (already commented use_flipper()), My guess is maybe it's because of XCode 12.5

JosePBrotons commented 3 years ago

@tintheanh Try removing the LIBRARY_SEARCH_PATHS from the Xcode project. After that I will run in M1 Macs.

handipriyono commented 3 years ago

I also experienced same issue before. But, Now i can compile and build react native run-ios sucessfully. I already resume and create guide article on how to run react native iOS Macbook with M1 Chip.

Quick step:

full guide in this article: https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

tintheanh commented 3 years ago

Running XCode in Rosetta now solves the issue for me

joeyfigaro commented 3 years ago

~@tintheanh How did you manage to do this? I've seen this suggested in a few different spots, but the option for rosetta never shows up for me in the info for XCode.~

Nope, turns out I was looking at the info for a random xcodeproj 🤦🏻 – been a long day.

deerLoves commented 3 years ago

I also experienced same issue before. But, Now i can compile and build react native run-ios sucessfully. I already resume and create guide article on how to run react native iOS Macbook with M1 Chip.

Quick step:

  • set terminal to use Rosetta
  • set XCode to use Rosetta
  • small adjust on podFile if you have problem with react native flipper. image?url=%2Fstatic%2Fimages%2Fterminal-mac-os-rosetta png w=200 q=75

full guide in this article: https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon

https://handi.dev/blog/how-run-react-native-on-macbook-m1-apple-silicon This article solved my all issues that occurred in my macbook uses m1 chip, thanks a lot

kelset commented 3 years ago

hey folks, I don't have an M1 machine so I can't really help with this, but I found in another issue this guide by @aiba linked https://github.com/aiba/react-native-m1, and I was wondering if anyone could test those steps and let the rest of us know if they work

kelset commented 3 years ago

hey folks, following up on this; we've created a troubleshooting guide with what we think is the best approach to solve the build issue for M1 -> https://github.com/facebook/react-native/issues/31941

please check it out and let us know if it works for you

iSamuelBarney commented 2 years ago

try sudo xcode-select --switch /Applications/Xcode.app