facebook / react-native

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

React Native build works on iPhone Simulator but fails on a real device #36580

Closed nareshbhatia closed 1 year ago

nareshbhatia commented 1 year ago

Description

My React Native build works on an "iPhone 11 Pro" Simulator but fails on a real "iPhone 11 Pro" with a "unable to attach DB" error:

> npx react-native run-ios --device
warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". You can learn more about it here: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
info Found Xcode workspace "MovieMagic.xcworkspace"
info Found booted Kunal’s iPhone, iPhone 11 Pro
info Building (using "xcodebuild -workspace MovieMagic.xcworkspace -configuration Debug -scheme MovieMagic -destination id=00008030-001245CA3A02802E")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening MovieMagic.xcworkspace.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace MovieMagic.xcworkspace -configuration Debug -scheme MovieMagic -destination id=00008030-001245CA3A02802E

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Prepare packages

Computing target dependency graph and provisioning inputs

Create build description
Build description signature: 3ecfc7c39566fa70c09c9f500a168ade
Build description path: /Users/nareshbhatia/Library/Developer/Xcode/DerivedData/MovieMagic-eyukdevunxkksvclqodiaeztayqs/Build/Intermediates.noindex/XCBuildData/3ecfc7c39566fa70c09c9f500a168ade-desc.xcbuild

note: Building targets in dependency order
error: unable to attach DB: error: accessing build database "/Users/nareshbhatia/Library/Developer/Xcode/DerivedData/MovieMagic-eyukdevunxkksvclqodiaeztayqs/Build/Intermediates.noindex/XCBuildData/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location.
warning: Run script build phase 'Bundle React Native code and images' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MovieMagic' from project 'MovieMagic')
warning: Run script build phase 'Start Packager' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'MovieMagic' from project 'MovieMagic')

** BUILD FAILED **

React Native Version

0.71.4

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: macOS 13.2.1
    CPU: (4) x64 Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
    Memory: 2.26 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    Yarn: 1.22.19 - ~/.yarn/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
    Watchman: 2022.11.14.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/nareshbhatia/.rvm/gems/ruby-2.7.6/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.4 => 0.71.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Cannot reproduce with unmodified app created using the following command:

npx react-native init ReactNativeDemo --template react-native-template-typescript

Can only reproduce using my app which was created using the above command and additional dependencies were added. No existing dependencies were modified, e.g.

{
  "dependencies": {
    "react": "18.2.0",
    "react-native": "0.71.4"
  },
  "devDependencies": {
    "metro-react-native-babel-preset": "0.73.8",
    "typescript": "4.8.4"
  }
}

Steps to reproduce:

  1. Clone https://github.com/nareshbhatia/movie-magic-2-react-native
  2. yarn
  3. yarn pod-install
  4. npx react-native run-ios - this runs successfully on the simulator
  5. npx react-native run-ios --device - this fails with "unable to attach DB" error, app is never installed on the attached device

Snack, code example, screenshot, or link to a repository

https://github.com/nareshbhatia/movie-magic-2-react-native

anishmr commented 1 year ago

When I tried all the above steps through the terminal, I also got the same error message like DB blocked, but when I tried the following steps app installed on my device

  1. Clone https://github.com/nareshbhatia/movie-magic-2-react-native
  2. yarn
  3. yarn pod-install
  4. open the workspace in xcode and try to run
  5. terminal popup and try ios, the application installed on my device.

XCODE Version: 14.2 iOS Version: 16.2 MacOS Version: 12.6.2 (21G320)

nareshbhatia commented 1 year ago

I have identified the issue to be with the next version of nativewind (see https://github.com/marklawlor/nativewind/issues/363). The build never finishes and hence metro gets blocked. Closing this issue.