请在您的Podfile文件中指定此目标的平台?

123
我想配置Firebase Firestore。我按照所有步骤进行操作,但在最后一步时,我遇到了下面提到的错误链接。
在执行以下命令后,我得到了下面的错误:pod install

[!] 在目标 testing_gowtham 上自动分配平台 ios 版本为 11.4 ,因为没有指定平台。请在您的Podfile中为此目标指定一个平台。请参阅https://guides.cocoapods.org/syntax/podfile.html#platform

我的Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'testing_gowtham' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!


  # Pods for testing_gowtham

  target 'testing_gowthamTests' do
    inherit! :search_paths
    # Pods for testing
  end

  target 'testing_gowthamUITests' do
    inherit! :search_paths
    # Pods for testing
  end

    pod 'Firebase/Core'
    pod 'Firebase/Firestore'
end

我看到了这个https://guides.cocoapods.org/syntax/podfile.html#platform,但我没有找到需要更改的哪一行。
如何解决这个问题?

4
请看第一行的注释,它说取消第二行的注释以设置平台。 - Sandeep
5
不要删除它,取消注释即可。 - Paul Beusterien
// # 平台:iOS,'9.0' 我像这样取消注释...但仍然出现相同的错误,先生。 - Gowthaman M
3
平台:iOS,'9.0' - Paul Beusterien
我已经删除了#,但是仍然出现相同的错误。 - Prabhakaran P
显示剩余2条评论
18个回答

148

请将您的整个Pod文件的文本替换为以下文本,然后进行检查。

# Uncomment the next line to define a global platform for your project

# platform :ios, '9.0'

target 'testing_gowtham' do

use_frameworks!


pod 'Firebase/Core'
pod 'Firebase/Firestore'
end

(或者)解决方案2

platform: ios,'9.0'可行...我只是去掉了#这个符号


4
谢谢您的快速回复。只是我需要移除这一行代码:**# platform :ios, '9.0'**,我没错吧? - Gowthaman M
2
不,让我改变我的答案。 - aBilal17
谢谢,我会检查,请稍等一下。 - Gowthaman M
aBilal17 先生,问题是什么?还有其他的想法吗? - Gowthaman M
兄弟,我从我的答案中删除了另一行。你能再检查一下吗?或者把你的Pod文件发送到我的电子邮件algaffaru@gmail.com上。 - aBilal17
显示剩余3条评论

17
# Uncomment the next line to define a global platform for your project
 platform :ios, '9.0'

target 'testing_gowtham' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for testing_gowtham
 pod 'Firebase/Core'
 pod 'Firebase/Firestore'

end

在Stack Overflow社区中,提供关于你的代码正在做什么的一些解释和评论是一个很好的做法。请添加一些描述! - undefined

13

在您的Podfile中 -> 取消注释platform并设置ios:10.0

    platform :ios, '10.0'

这将起作用。


1
之后,您必须进入“ios”文件夹并运行“pod repo update”,但是是的,这确实有效。谢谢。 - Andre Pena

8
如果您在安装pod 'PusherSwift'pod 'AlamofireImage'时遇到上述错误,则需要从中删除#符号。
# platform :ios, '9.0'.

接着在你的终端中输入命令 pod install

当你再次运行项目时,会出现关于'pusher swift'的错误提示。你需要点击“解除阻止”选项,这样问题就成功解决了。


太棒了,库鲁帕雷山!你救了我的时间。 - Dhaval Gevariya

6

删除Podfile.lock文件并运行pod install

我因为更改了目标iOS版本并在更多设备上开发应用程序而遇到了这个问题。

对我来说有效,但请注意 - 它将替换所有锁定(缓存)的库版本,您正在使用。 请检查自己是否完全理解Podfile.lock文件在此处的作用-->https://guides.cocoapods.org/using/using-cocoapods.html


5

2022年更新的答案。 这是由于您的最低部署目标小于iOS 10。根据 Firebase iOS设置文档,您的项目必须针对iOS平台版本iOS 10或更高版本:

  1. command $ flutter clean

  2. open the Podfile in the directory ios/Podfile

  3. uncomment the line platform :ios, '9.0' and change 9.0 to 10.0

    # Uncomment this line to define a global platform for your project
      platform :ios, '10.0'
    
  4. save the file

  5. $ flutter run


5

对于Apple Silicon M1芯片

  1. 编辑./ios/Podfile文件 platform :ios, '11.4' 或任何版本
  2. 安装ffi arch -x86_64 sudo gem install ffi
  3. 重新安装pods
flutter clean
cd ios
arch -x86_64 pod install
cd ..
flutter run

在M1的情况下,无需取消注释“platform:ios,~~~”,只需安装“arch -x86_64 pod install”即可解决此问题。谢谢! - alones

3

你不应该删除 Podfile 中的所有内容,只需取消注释以下行:

platform :ios, '9.0'

来自 ios/Podfile


3
在Flutter项目中,我也遇到了这个问题。通过更新Flutter和CocoaPods到最新版本来解决。
解决方法: - flutter clean - rm -Rf ios/Pods - rm -Rf ios/.symlinks - rm -Rf ios/Flutter/Flutter.framework - rm -Rf ios/Flutter/Flutter.podspec - cd ios - pod install - cd .. - flutter build ios

2
最简单的答案就是取消注释 Podfile 的第二行并将 iOS 版本更改为 10,如下所示。请注意,接下来的 Xcode 构建会比通常需要更长一些时间。我不知道为什么...
platform :ios, '10.0'

enter image description here


因为它再次运行了pod install。 - Vinny

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接