簡體   English   中英

npx react-native run-ios 不適用於反應原生新項目

[英]npx react-native run-ios not working for react native fresh project

描述

根據此處提供的入門指南https://reactnative.dev/docs/environment-setup ,我正在嘗試使用 react native cli 構建一個構建項目。 我按照文章中提供的確切步驟進行操作,該項目針對 android 而不是針對 ios。 我得到的錯誤是

2022-05-09 19:52:26.204 xcodebuild[27325:198569] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
2022-05-09 19:52:26.208 xcodebuild[27325:198569] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore

和這個

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 AwesomeProject.xcworkspace

The following build commands failed:
    CompileC /Users/jaydave5/Library/Developer/Xcode/DerivedData/AwesomeProject-gypcnmvewcvovdgwbdrhxjrrxutt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/SysUio.o /Users/jaydave5/Documents/native\ projects/bare\ react\ native/AwesomeProject/ios/Pods/RCT-Folly/folly/portability/SysUio.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods')
(1 failure)

在做一些研究時,我看到了一個 stackoverflow 帖子,上面說嘗試在 ios 文件夾中打開 xcode 工作區並嘗試從那里構建,我附上了我在那里收到的錯誤的屏幕截圖

在此處輸入圖像描述

版本

0.68.2

npx react-native info輸出

System:
    OS: macOS 12.2.1
    CPU: (8) x64 Apple M1
    Memory: 43.58 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    Yarn: 1.22.18 - ~/.nvm/versions/node/v14.17.1/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8193401
    Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.15 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.2 => 0.68.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

重現步驟

步驟 1 npx react-native init AwesomeProject

步驟 2 npx react-native start

步驟 3 npx react-native run-ios

后來我嘗試用expo創建一個應用程序並將其彈出這是我得到的錯誤

(warning truncated)
› Compiling react-native Pods/RCT-Folly » NetOps.cpp

❌  (ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17)

  50 | #define CLOCK_THREAD_CPUTIME_ID 3
  51 | 
> 52 | typedef uint8_t clockid_t;
     |                 ^ typedef redefinition with different types vs 'enum clockid_t')
  53 | extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
  54 | extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
  55 | #endif

› Compiling react-native Pods/RCT-Folly » Format.cpp

⚠️  (/Users/jaydave5/Library/Developer/Xcode/DerivedData/AwesomeProject-fepzfupsfexonsdubhfcgescuowt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/Format.dia:1:1)

CompileC /Users/jaydave5/Library/Developer/Xcode/DerivedData/AwesomeProject-fepzfupsfexonsdubhfcgescuowt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/Fi...
^ Could not read serialized diagnostics file: error(in target 'RCT-Folly' from project 'Pods')
(warning truncated)

❌  (ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17)

  50 | #define CLOCK_THREAD_CPUTIME_ID 3
  51 | 
> 52 | typedef uint8_t clockid_t;
     |                 ^ typedef redefinition with different types vs 'enum clockid_t')
  53 | extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
  54 | extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
  55 | #endif


⚠️  (/Users/jaydave5/Library/Developer/Xcode/DerivedData/AwesomeProject-fepzfupsfexonsdubhfcgescuowt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/x86_64/FileUtil.dia:1:1)

warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the AwesomeProject editor. (in tar...
^ Could not read serialized diagnostics file: error(in target 'RCT-Folly' from project 'Pods')
(warning truncated)

› 3 error(s), and 3 warning(s)

Failed to build iOS project. "xcodebuild" exited with error code 65.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

如果您沒有安裝可可豆莢,您需要sudo gem install cocoapods

  1. 運行cd ios
  2. 運行pod install
  3. cd .. 然后刪除build folder
  4. 運行react-native run-ios

如果錯誤仍然存​​在,

  1. 再次刪除構建文件夾

  2. 在 Xcode 中打開/ios文件夾

  3. 導航文件 -> 項目設置 -> 構建系統 -> 更改(共享工作區設置和每用戶工作區設置):構建系統 -> 舊版構建系統`

我希望這有幫助

由於我在正常運行pod install時使用的是基於 M1 的 mac 書,因此它不起作用,但是當我運行arch-x86_64 pod install 時,它起作用了。 我想在這里指出,我在運行pod install時沒有收到任何錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM