我正在尝试为应用程序商店构建。使用命令
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
新的目标通知服务扩展
这是我的 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
将 pod '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 模块并构建存档。 它会起作用的。
经过多次尝试,它成功构建并存档。我不知道哪些设置适用,但以下几个步骤,让我们检查一下您的设置。
在 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
按照步骤 1 至 4 进行操作。
在 Xcode 项目中, 目标 > 跑步者 > 构建阶段 > 移动序列
并在“嵌入应用程序扩展”中标记选中(✅)“仅在安装时复制”
就是这样,现在尝试存档,
选择“跑步者”> 任何 iOS 设备
还有
产品 > 存档
完成!!
不要忘记遵循 FCM 的通知负载请求,
apns: {
payload: {
aps: {
'mutable-content': 1
}
},
fcm_options: {
image: 'https://foo.bar.pizza-monster.png'
}
},
祝一切顺利。👍
评论 Pod 行:
target 'ImageNotification' do
use_frameworks!
#pod 'Firebase/Messaging'
end
在 didReceiveNotificationRequest 中注释 FirebaseMessaging 导入和 Extension Helper 行
#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
这对我有用!!
只需删除“使用模块化标头!”来自 podfile
对我有用的是取消 Podfile 中平台行的注释:
platform :ios, '12.0'
我已经将 GoogleUtilities pod 添加到两个目标,但它只有在设置平台后才起作用。