flutter 多个命令产生抖动GoogleUtilities

kninwzqo  于 2023-01-06  发布在  Flutter
关注(0)|答案(4)|浏览(139)

我正在尝试为应用商店构建。使用命令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新目标NotificationService扩展
下面是我的pod文件:

# 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
kgsdhlau

kgsdhlau1#

将“GoogleUtilities”添加到PodFile中的ImageNotification目标和Runner目标。

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

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

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

z31licg0

z31licg02#

注解pod行:

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

didReceiveNotificationRequest中的注解Firebase消息传递导入和扩展帮助程序行

#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

这对我很有效

mlnl4t2r

mlnl4t2r3#

经过尝试的努力,它建立和存档成功。我从来不知道哪些设置是适用的,但几个步骤如下,让检查与您的设置。
播客文件中,

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构建,

flutter build ios --release --verbose

与通过APN集成的FCM相同,
遵循步骤1至4。
在Xcode项目中,目标〉运行程序〉构建阶段〉移动序列

  • "嵌入应用程序扩展",然后
  • '[CP]嵌入Pod框架,然后
  • '[CP]复制Pod资源'

和标记选中()"仅在安装时复制"在"嵌入应用程序扩展"
就这样现在尝试存档,
选择"Runner"〉任何iOS设备
还有
产品〉档案
成交!
别忘了遵循FCM的Notification Payload请求,

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

一切顺利。👍

6qftjkof

6qftjkof4#

刚删除'使用模块化标题!'从podfile

相关问题