iOS 部署 ReactNative 项目时遇到的问题

问题描述 投票:0回答:1

我正在开发一个全新的 iOS/Android 应用程序,我想使用单个代码,所以我决定使用 ReactNative 来实现我的功能,并且我想自己构建可执行文件,而不是使用 Expo 之类的东西进行远程构建,所以我买了一台 MacMini,在其中连接了我的 Android 和 iOS 物理设备(我将在其中运行我的项目)。

我使用 VisualStudioCode 作为 IDE,并完成了安装 ReactNative (v0.73.5) 的所有段落,一切都很顺利,我的基础项目可以完美运行

npm start

并且在我的设备上运行这两个版本都没有问题。

当我尝试在项目中添加 navigation-container 时,问题就出现了;我按照指南(https://reactnavigation.org/docs/getting-started/)并安装了本机堆栈导航器库(https://reactnavigation.org/docs/hello-react-navigation)并编写一个简单的代码,自动从项目启动 (App.tsx) 切换到启动页面,如下所示:

import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';

import SplashScreen from './screens/SplashScreen';

const Stack = createNativeStackNavigator();

function App() {
  return (
    <NavigationContainer>
      <Stack.Navigator>
        <Stack.Screen name="Splash" component={SplashScreen} />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;

并使用 npx react-native run-iosnpx react-native run-android运行它。

在 Android 上,一切运行良好,并且我按照预期进入了启动屏幕,但在 iOS 上,我什至无法构建和运行任何内容:使用 npx 我收到此错误

** BUILD FAILED **


The following build commands failed:
        Ld /Users/******/Library/Developer/Xcode/DerivedData/ETMHOMECROSS-avqdpcaltzlgykcghamktxvqeiyk/Build/Products/Debug-iphoneos/RNScreens/RNScreens.framework/RNScreens normal (in target 'RNScreens' from project 'Pods')
(1 failure)

使用 npm start 并输入 i 时,构建在编译时没有错误

info Opening app on iOS...
info A dev server is already running for this project on port 8081.
info Found Xcode workspace "ETMHOMECROSS.xcworkspace"
info Found booted iPhone 14 Development , iPad
info Building (using "xcodebuild -workspace ETMHOMECROSS.xcworkspace -configuration Debug -scheme ETMHOMECROSS -destination id=00008110-000255322130A01E")

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 

Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace ETMHOMECROSS.xcworkspace -configuration Debug -scheme ETMHOMECROSS -destination id=00008110-000255322130A01E

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

Prepare packages

ComputeTargetDependencyGraph
note: Building targets in dependency order
note: Target dependency graph (61 targets)
    Target 'ETMHOMECROSS' in project 'ETMHOMECROSS'
        ➜ Implicit dependency on target 'Pods-ETMHOMECROSS' in project 'Pods' via file 'Pods_ETMHOMECROSS.framework' in build phase 'Link Binary'
        ➜ Implicit dependency on target 'CocoaAsyncSocket' in project 'Pods' via options '-framework CocoaAsyncSocket' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-CoreModules' in project 'Pods' via options '-framework CoreModules' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'DoubleConversion' in project 'Pods' via options '-framework DoubleConversion' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTAnimation' in project 'Pods' via options '-framework RCTAnimation' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTBlob' in project 'Pods' via options '-framework RCTBlob' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTFabric' in project 'Pods' via options '-framework RCTFabric' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTImage' in project 'Pods' via options '-framework RCTImage' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTLinking' in project 'Pods' via options '-framework RCTLinking' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTNetwork' in project 'Pods' via options '-framework RCTNetwork' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTSettings' in project 'Pods' via options '-framework RCTSettings' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTText' in project 'Pods' via options '-framework RCTText' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RCTTypeSafety' in project 'Pods' via options '-framework RCTTypeSafety' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTVibration' in project 'Pods' via options '-framework RCTVibration' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RNCMaskedView' in project 'Pods' via options '-framework RNCMaskedView' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RNGestureHandler' in project 'Pods' via options '-framework RNGestureHandler' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RNReanimated' in project 'Pods' via options '-framework RNReanimated' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RNScreens' in project 'Pods' via options '-framework RNScreens' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-Core' in project 'Pods' via options '-framework React' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'ReactCommon' in project 'Pods' via options '-framework ReactCommon' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-Codegen' in project 'Pods' via options '-framework React_Codegen' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-Fabric' in project 'Pods' via options '-framework React_Fabric' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-FabricImage' in project 'Pods' via options '-framework React_FabricImage' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-ImageManager' in project 'Pods' via options '-framework React_ImageManager' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-Mapbuffer' in project 'Pods' via options '-framework React_Mapbuffer' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-NativeModulesApple' in project 'Pods' via options '-framework React_NativeModulesApple' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-RCTAppDelegate' in project 'Pods' via options '-framework React_RCTAppDelegate' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-debug' in project 'Pods' via options '-framework React_debug' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-graphics' in project 'Pods' via options '-framework React_graphics' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-jserrorhandler' in project 'Pods' via options '-framework React_jserrorhandler' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-nativeconfig' in project 'Pods' via options '-framework React_nativeconfig' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-rendererdebug' in project 'Pods' via options '-framework React_rendererdebug' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-runtimescheduler' in project 'Pods' via options '-framework React_runtimescheduler' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-utils' in project 'Pods' via options '-framework React_utils' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'SocketRocket' in project 'Pods' via options '-framework SocketRocket' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-cxxreact' in project 'Pods' via options '-framework cxxreact' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'fmt' in project 'Pods' via options '-framework fmt' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'RCT-Folly' in project 'Pods' via options '-framework folly' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'glog' in project 'Pods' via options '-framework glog' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-jsi' in project 'Pods' via options '-framework jsi' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-jsinspector' in project 'Pods' via options '-framework jsinspector' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-jsiexecutor' in project 'Pods' via options '-framework jsireact' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'libevent' in project 'Pods' via options '-framework libevent' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-logger' in project 'Pods' via options '-framework logger' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'react-native-change-icon' in project 'Pods' via options '-framework react_native_change_icon' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'react-native-safe-area-context' in project 'Pods' via options '-framework react_native_safe_area_context' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-hermes' in project 'Pods' via options '-framework reacthermes' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'React-perflogger' in project 'Pods' via options '-framework reactperflogger' in build setting 'OTHER_LDFLAGS'
        ➜ Implicit dependency on target 'Yoga' in project 'Pods' via

我认为我在 Pod 上遇到了一些冲突,但我无法获得有关解决内容和如何解决的任何信息。

欢迎任何帮助,以及有关以正确方式安装依赖项的过程!

提前致谢

ios react-native cocoapods react-navigation npm-start
1个回答
0
投票

该错误表明您的 Podfile 中缺少 RNScreens 库,但您可能缺少两个安装包:react-native-screens 和 react-native-safe-area-context。 用途:

npm install react-native-screens react-native-safe-area-context

或者如果您使用yarn,请将 npm install 替换为yarn add 我还建议,如果仍然失败,请删除您的 node_modules 文件夹和锁定文件,例如 package-lock.jsonyarn.lock 并再次进行安装,不要忘记输入您的 ios (

cd ios
) 文件夹并使用
pod install

© www.soinside.com 2019 - 2024. All rights reserved.