原始React:在项目目录中未找到“Podfile”

u91tlkcl  于 2023-03-24  发布在  React
关注(0)|答案(1)|浏览(154)

我正在处理一个现有的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文件夹中运行“podinstall”

然后我得到了以下错误:

[!] 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时,我得到以下错误。
error在null. lock中找不到“Podfile.lock”。您是否在iOS目录中运行了“pod install”?
我该如何解决这个问题?

lkaoscv7

lkaoscv71#

溶液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

相关问题