多个命令产生了Flutter GoogleUtilities

11
我正试图构建应用商店版本。使用命令flutter build ipa,并获得以下错误。尽管在调试模式下(从Android Studio运行时)可以构建,也能接收到推送通知。
warning: Multiple targets match implicit dependency for linker flags '-framework GoogleUtilities'. Consider adding an explicit dependency on the intended target to
resolve this ambiguity. (in target 'Runner' from project 'Runner')

warning: Multiple targets match implicit dependency for linker flags '-framework GoogleUtilities'.Consider adding an explicit dependency on the intended target to
resolve this ambiguity. (in target 'ImageNotification' from project 'Runner')
error: Multiple commands produce

'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework':
1) Target 'GoogleUtilities-00567490' has create directory command with output
'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
2) Target 'GoogleUtilities-54e75ca4' has create directory command with output
'/Users/manu/Library/Developer/Xcode/DerivedData/Runner-csuwafuzvneucvdjlkobmosdwxae/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuild
FilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

我添加了一个名为 ImageNotification 的新目标通知服务扩展,用于在推送通知中推送图像。

以下是我的Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '14.3'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), _FILE_)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(_FILE_))
end

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

target 'ImageNotification' do
  use_frameworks!
  pod 'Firebase/Messaging'
end
4个回答

31

在 PodFile 的 ImageNotification 目标和 Runner 目标中添加 "pod 'GoogleUtilities'"。

target 'ImageNotification' do
  ...
  pod 'GoogleUtilities'
end

target 'Runner' do
  ...
  pod 'GoogleUtilities'
end

删除PodFile.lock,然后运行flutter clean,然后运行flutter pub get,然后运行flutter build ios。之后在Xcode中打开ios模块并构建存档。就可以了。


很遗憾对我没有起作用,但它给了我一个进一步搜索的想法 --> 在Podfile中。 - Christian X
也没有对我有帮助。 - Just A Question
非常好用!谢谢。 - Fares Benhamouda
不要忘记在代码中指定平台:ios至少为10.0或更高版本才能正常工作。 - Karem Mohamed
参考链接:https://github.com/firebase/flutterfire/issues/4583 - abegehr
最后。。。非常感谢你,你太棒了 - Faruk

1
注释掉 pod 行:
target 'ImageNotification' do
  use_frameworks!
  #pod 'Firebase/Messaging'
end

在 didReceiveNotificationRequest 中注释掉 FirebaseMessaging 的导入和扩展助手行。
#import "NotificationService.h"
//#import "FirebaseMessaging.h"
@interface NotificationService ()

@property (nonatomic, strong) void (^contentHandler)(UNNotificationContent *contentToDeliver);
@property (nonatomic, strong) UNMutableNotificationContent *bestAttemptContent;

@end

@implementation NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
    self.contentHandler = contentHandler;
    self.bestAttemptContent = [request.content mutableCopy];
    
//    [[FIRMessaging extensionHelper] populateNotificationContent:self.bestAttemptContent withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
    // Called just before the extension will be terminated by the system.
    // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
    self.contentHandler(self.bestAttemptContent);
}

@end

这对我有用!!


1
所以你基本上只是在你的项目中禁用了Firebase/Messaging?这正是我试图安装的东西。 - Mo W.

0

经过多次尝试,它成功地构建和存档了。我从不知道哪些设置是适用的,但以下是一些步骤,请检查您的设置。

Podfile中,

target 'Runner' do
 pod 'GoogleUtilities'
 use_frameworks!
 #use_modular_headers!
 
 flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
 #pod 'Firebase/Messaging'
end

target 'ImageNotification' do
  use_frameworks!
  pod 'GoogleUtilities'
  pod 'Firebase/Messaging'
end

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

运行flutter build命令,

flutter build ios --release --verbose

按照FCM通过APNs集成所述,

请按照步骤1至4进行操作。

在Xcode项目中,

Targets > Runner > Build Phases > Move Sequence

  • 首先是“嵌入应用扩展”,然后是
  • “[CP] 嵌入Pods框架”,最后是
  • “[CP] 复制Pods资源”

并在“嵌入应用扩展”中标记为已选中(✅)“仅在安装时复制”

现在可以尝试存档了,

选择“Runner”>任何iOS设备

然后

Product > Archive

完成!!

别忘了遵循通知负载请求以进行FCM设置,

  apns: {
    payload: {
      aps: {
        'mutable-content': 1
      }
    },
    fcm_options: {
      image: 'https://foo.bar.pizza-monster.png'
    }
  },

祝一切顺利。


0

只需从Podfile中删除'use modular headers!'即可。


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