Flutter IOS构建错误 - “在签名和功能编辑器中选择开发团队。”

32
尝试在IOS设备上构建时,会显示以下错误:
如下图所示,Xcode中的签名设置已经完成。
你能告诉我造成这种情况的原因和解决方法吗?
Could not build the precompiled application for the device.
Error (Xcode): Signing for "GoogleSignIn-GoogleSignIn" requires a development team. Select a development team in the Signing & Capabilities editor.
/Users/home_1/StudioProjects/Example%20Project/app/ios/Pods/Pods.xcodeproj


Error (Xcode): Signing for "DKPhotoGallery-DKPhotoGallery" requires a development team. Select a development team in the Signing & Capabilities editor.
/Users/home_1/StudioProjects/Example%20Project/app/ios/Pods/Pods.xcodeproj


Error (Xcode): Signing for "DKImagePickerController-DKImagePickerController" requires a development team. Select a development team in the Signing & Capabilities editor.
/Users/home_1/StudioProjects/Example%20Project/app/ios/Pods/Pods.xcodeproj


Error (Xcode): Signing for "gRPC-C++-gRPCCertificates-Cpp" requires a development team. Select a development team in the Signing & Capabilities editor.
/Users/home_1/StudioProjects/Example%20Project/app/ios/Pods/Pods.xcodeproj

enter image description here


请查看以下链接以解决此问题, POD Install - Mahendran K
我遇到了同样的问题,不幸的是,pod install 对我没有起作用。 - Suat Özkaya
1
我使用了 Xcode 14 版本,发现很多人都遇到了同样的问题。因此,我尝试回退到之前的版本后再次尝试,最终成功了。 - Kevin Yang
这是来自Flutter SDK的消息,Flutter SDK与最新版本的xCode不兼容。 - BIS Tech
面对相同的问题,我需要提交构建并降级Xcode版本,这样就可以解决问题了。 - Parul Garg
嘿,不需要降级Xcode,请先检查我的答案,可能会解决问题。 - Vahagn Gevorgyan
12个回答

55

今天我在切换到Xcode 14后遇到了这个问题。尝试将以下内容添加到你的podfile中。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.build_settings['WRAPPER_EXTENSION'] == 'bundle'
        config.build_settings['DEVELOPMENT_TEAM'] = 'YOUR_DEVELOPMENT_TEAM_ID'
      end
    end
  end
end

不要忘记替换YOUR_DEVELOPMENT_TEAM_ID为你在developer.apple.com中找到的实际开发团队ID。

这将永久解决问题。

如果您不想使用团队ID,可以尝试以下方法:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end
end

如果您有其他的post_install步骤,比如flutter_additional_ios_build_settings(target),请确保保留它们。


1
这对我有用,但我必须保留这行代码: flutter_additional_ios_build_settings(target) - Jackson Welch
1
我也会检查这些问题: [问题1](https://github.com/flutter/flutter/issues/111475) [问题2](https://github.com/CocoaPods/CocoaPods/issues/11402) - Liel van der Hoeven
这解决了问题。是什么导致了这个问题?这个修复是否是针对Flutter SDK或Xcode的问题的一种解决方法? - Justin
@Justin 不是Flutter问题,而是与Xcode相关。我自己是一名本地(Swift)开发人员,也遇到了同样的问题。 - Vahagn Gevorgyan
1
我更喜欢这个解决方案,因为它克服了苹果审核员的问题,他们会拒绝那些使用“CODE_SIGNING_ALLOWED = NO”跳过其pods代码签名的应用程序。 - Chen Li Yong

14

我在想苹果何时会发布一个不会破坏以前版本的新的xCode版本!

撇开抱怨,这是我根据之前的答案修复我的Flutter项目的方法:

打开你的awesome_flutter_project/ios/Podfile文件:

并替换以下行:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

循环结构:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end
end

我的代码只有使用了你的答案才能正常工作!区别在于:flutter_additional_ios_build_settings(target)。谢谢! - Leonardo
它运行得很好。 - Sithu

9

针对那些认为被接受的解决方案是一种hack的人,你们是正确的。这是flutter框架中已知的一个bug,它已经在flutter 3.3.3版本中得到修复。

所以我建议如果你能够/有权限这样做的话,升级到这个版本。

如果你不能升级到3.3.3,那么被接受的解决方案是最好的选择;)


1
在升级到3.3.3版本后,对我很有效。 - Sp4Rx

5

这是一个Flutter框架的问题。

Flutter版本更新为3.3.3


4

我在升级XCode到14版本后也遇到了这个错误。

请在 ios > podfile 中添加以下内容:

enter image description here

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      if config.build_settings['WRAPPER_EXTENSION'] == 'bundle'
        config.build_settings['DEVELOPMENT_TEAM'] = 'YOUR_DEVELOPMENT_TEAM_ID'
      end
    end
  end
end

获取YOUR_DEVELOPMENT_TEAM_ID的方式如下:https://developer.apple.com/account/#!/membership/ 这将永久解决此问题。
如果您不想使用团队ID,则可以选择执行以下操作:
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
        target.build_configurations.each do |config|
            config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end
end

1
我通过以下步骤解决了问题:
  1. 在xCode中打开项目
  2. 打开Pods并找到 "GoogleSignIn-GoogleSignIn" 和其他三个在 Pods > Target
  3. Signing & Capabilities中选择Team

4
每次执行 pod install 之后都需要执行这个步骤。 - Vahagn Gevorgyan

1

我正在使用CodeMagic.io(CI/CD),遇到了同样的问题,我发现问题在于Xcode版本:14

我通过以下步骤在CodeMagic.io上解决了这个问题:

  1. 进入工作流编辑器
  2. 进入“构建”
  3. 更改Xcode版本:13.4.1

如果您使用另一个CI/CD,请尝试使用Xcode版本:13.4.1

有人提到解决此问题也可以将Flutter版本更新为3.3.3,但如果像我一样无法进行此操作,请尝试使用Xcode版本13.4.1


1
添加以下代码可以解决在Xcode 14和flutter版本2.8中的问题。
        config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'

1

Xcode 中打开你的 flutter 项目

Pods -> Targets -> Signing & Capabilities -> 选择团队

每个 Target 选择 团队

enter image description here


我只是尝试在Xcode中运行应用程序,然后为每个库选择了开发团队。 - Stefan Galler
它可以在本地构建时工作,当您不修改配置时,但是使用CI/CD(如fastlane)时它无法工作。 - Vladislav Zaynchkovsky

0
当我将建议的更改放入 pod 文件并运行 flutter build ipa 命令时,我遇到了不同的错误

错误:

 In file included from /Volumes/Data/FlutterSDK/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.9.3/ios/Classes/FWFUIViewHostApi.m:5:
/Volumes/Data/FlutterSDK/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.9.3/ios/Classes/FWFUIViewHostApi.h:5:9: fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>

我也是,你解决了吗? - Mina Ayad

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