【问题标题】:ReactNative: No `Podfile' found in the project directoryReactNative:在项目目录中找不到“Podfile”
【发布时间】:2021-08-26 10:53:00
【问题描述】:

我正在开发一个现有的 ReactNative 项目以向 IOS 应用程序添加新功能。但我尝试使用“react-native run-ios”命令构建和运行 IOS 应用程序,但出现以下错误。

在 null.lock 处找不到“Podfile.lock”。你在 iOS 目录下运行过“pod install”吗?

为了解决这个问题,我首先在项目的 ios 文件夹中运行以下命令。

pod install

当我这样做时,我在控制台中收到以下错误。

[!] 在项目目录中找不到“Podfile”。

为了解决这个错误,我尝试了以下操作:

  • 我运行“sudo gem install cocoapods”
  • 然后在 ios 文件夹中运行“pod init”
  • 然后我在 ios 文件夹中运行“pod install”

然后我得到以下错误:

[!] The target `xxxxxx xxxTests` is declared multiple times.

我删除了 Podfile 中的重复项并尝试再次运行 pod install。这次它运行但我收到以下警告。

[!] The Podfile does not contain any dependencies.

[!] Automatically assigning platform `iOS` with version `12.0` on target `Inventory Smart` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

[!] Automatically assigning platform `tvOS` with version `12.0` on target `Inventory Smart-tvOS` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

当我运行 react-native run-ios 时,出现以下错误。

错误在 null.lock 处找不到“Podfile.lock”。你在 iOS 目录下运行过“pod install”吗?

我该如何解决这个问题?

【问题讨论】:

    标签: ios react-native cocoapods


    【解决方案1】:

    解决方案 1:目标 xxxxxx xxxTests 被声明多次。

    很明显,您的Podfile 多次包含目标xxxxxx-xxxTests。您只需进入Podfile 内部,并删除重复的有问题的目标xxxxxx-xxxTests 代码。

    • 它看起来像这样,您只需从Podfile 中删除两个声明的代码之一
    target 'xxxxxx-xxxTests' do
      inherit! :search_paths
      # Pods for testing 
    end 
    

    您现在可以运行该应用程序,您只需在完成上述修复后执行以下命令即可。

    pod install
    cd ..
    npm run ios
    

    更新答案

    解决方案2:自动分配平台iOS和版本12.0

    Podfile 的顶部,通过从引用的代码中删除 # 来取消注释 # podfile :ios, 'x.0',这里 x 是默认情况下存在的版本号,所以不要混淆。 或者只需在全球范围内提及此行,podfile :ios, '10.0'。理想情况下,这应该可以解决您的问题。

    然后运行以下命令:

    cd ios && rm -rf Pods
    pod install
    cd ..
    react-native run-ios
    

    【讨论】:

    • 您好,我更新了问题,请看一下。
    • 您好@WaiYanHein,请参阅更新答案部分以了解您的解决方案,如果这对您有用,请告诉我
    • 你好。感谢您的快速回复。不幸的是,它没有用。 XCode 抱怨找不到 boost/operators.hpp 文件。
    • @WaiYanHein 如果您已经完成了上述操作,那么只需执行cd ios && rm -rf Pods && pod install,然后执行cd .. && react-native run-ios。看看这是否适合你。问题可能仅来自 Pods。因此,我们正在尝试清理项目,然后运行应用程序。
    • 现在,它正在抱怨无法从 Xcode 获取模拟器列表。请打开 Xcode 并尝试直接从那里运行项目以解决剩余的问题。以前一切正常。模拟器在那里打开。我在运行“react-native run-ios”时得到它。
    猜你喜欢
    • 2021-01-09
    • 2023-01-19
    • 2016-08-22
    • 2019-07-02
    • 1970-01-01
    • 1970-01-01
    • 2022-07-19
    • 2019-06-25
    • 1970-01-01
    相关资源
    最近更新 更多