- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
由于公司的决定,我目前正在处理一个 Swift 项目,其中工作区包含多个项目(ACM...)。
在使用 Cocoapods 添加 Firebase 时,我需要在两个项目中使用它(在“myapp”和“ACMLoyalty”中)。所以我的 .podfile
看起来像这样:
workspace 'myapp.xcworkspace'
platform :ios, '12.0'
use_frameworks!
def shared_pods
source 'https://github.com/CocoaPods/Specs.git'
pod 'Nuke', '9.2.3'
pod 'Alamofire', '~> 4.9.1'
pod 'DeepDiff', '2.3.1'
end
def firebase_pods
pod 'Firebase/Analytics', '7.4.0'
pod 'Firebase/Crashlytics', '7.4.0'
pod 'Firebase', '7.4.0'
end
def appcenter_pods
pod 'AppCenter', '4.1.0'
pod 'AppCenter/Distribute', '4.1.0'
end
project 'myapp.xcodeproj'
project 'ACMCore/ACMCore.xcodeproj'
project 'ACMData/ACMData.xcodeproj'
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
project 'ACMMVVM/ACMMVVM.xcodeproj'
project 'ACMNetwork/ACMNetwork.xcodeproj'
project 'ACMShared/ACMShared.xcodeproj'
target :myapp do
project 'myapp.xcodeproj'
shared_pods
firebase_pods
appcenter_pods
end
target :ACMCore do
project 'ACMCore/ACMCore.xcodeproj'
shared_pods
end
target :ACMData do
project 'ACMData/ACMData.xcodeproj'
shared_pods
end
target :ACMLoyalty do
use_frameworks! :linkage => :dynamic
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
shared_pods
firebase_pods
target 'ACMLoyaltyTests' do
inherit! :search_paths
shared_pods
firebase_pods
end
target 'ACMLoyaltyTestHost' do
inherit! :search_paths
shared_pods
firebase_pods
end
end
target :ACMMVVM do
project 'ACMMVVM/ACMMVVM.xcodeproj'
shared_pods
target 'ACMMVVMTests' do
inherit! :search_paths
shared_pods
end
end
target :ACMNetwork do
project 'ACMNetwork/ACMNetwork.xcodeproj'
shared_pods
target 'ACMNetworkTests' do
inherit! :search_paths
shared_pods
end
end
target :ACMShared do
project 'ACMShared/ACMShared.xcodeproj'
shared_pods
target 'ACMSharedTests' do
inherit! :search_paths
shared_pods
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new('9.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
在运行时,我在控制台中收到以下警告:
objc[2946]: Class FIRAnalyticsConnector is implemented in both /private/var/containers/Bundle/Application/05B31227-083E-42A7-9E27-DB7924A754B9/myapp.app/Frameworks/ACMLoyalty.framework/ACMLoyalty (0x107c4d1b8) and /private/var/containers/Bundle/Application/05B31227-083E-42A7-9E27-DB7924A754B9/myapp.app/myapp (0x104217298). One of the two will be used. Which one is undefined.
这只是示例中的一行,但还有许多具有相同描述的其他 Firebase 类。
经过一些研究我知道,问题是 Firebase 是一个静态库,将被简单地复制到导致此问题的特定目标。对于其他库(动态),不会出现此问题。
有人能解决我的问题吗?
我已经尝试过使用 abstract_target
的解决方案。
请为这次尝试找到我的 .podfile
:
# Uncomment the next line to define a global platform for your project
workspace 'myapp.xcworkspace'
platform :ios, '12.0'
use_frameworks!
project 'myapp.xcodeproj'
project 'ACMCore/ACMCore.xcodeproj'
project 'ACMData/ACMData.xcodeproj'
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
project 'ACMMVVM/ACMMVVM.xcodeproj'
project 'ACMNetwork/ACMNetwork.xcodeproj'
project 'ACMShared/ACMShared.xcodeproj'
abstract_target 'myapp-app' do
source 'https://github.com/CocoaPods/Specs.git'
pod 'Nuke', '9.2.3'
pod 'Alamofire', '~> 4.9.1'
pod 'DeepDiff', '2.3.1'
pod 'Firebase/Analytics', '7.4.0'
pod 'Firebase/Crashlytics', '7.4.0'
pod 'Firebase', '7.4.0'
def appcenter_pods
pod 'AppCenter', '4.1.0'
pod 'AppCenter/Distribute', '4.1.0'
end
target :myapp do
project 'myapp.xcodeproj'
appcenter_pods
end
target :ACMCore do
project 'ACMCore/ACMCore.xcodeproj'
end
target :ACMData do
project 'ACMData/ACMData.xcodeproj'
end
target :ACMLoyalty do
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
target 'ACMLoyaltyTests' do
end
target 'ACMLoyaltyTestHost' do
end
end
target :ACMMVVM do
project 'ACMMVVM/ACMMVVM.xcodeproj'
target 'ACMMVVMTests' do
end
end
target :ACMNetwork do
project 'ACMNetwork/ACMNetwork.xcodeproj'
target 'ACMNetworkTests' do
end
end
target :ACMShared do
project 'ACMShared/ACMShared.xcodeproj'
target 'ACMSharedTests' do
end
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new('9.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
问题是,对于这个解决方案,我有更多的警告,因为 Firebase 是在所有项目和冲突中构建的。
... 实现的情况下工作...
带有以下 podfile 的警告:# Uncomment the next line to define a global platform for your project
workspace 'myapp.xcworkspace'
platform :ios, '12.0'
use_frameworks!
project 'myapp.xcodeproj'
project 'ACMCore/ACMCore.xcodeproj'
project 'ACMData/ACMData.xcodeproj'
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
project 'ACMMVVM/ACMMVVM.xcodeproj'
project 'ACMNetwork/ACMNetwork.xcodeproj'
project 'ACMShared/ACMShared.xcodeproj'
abstract_target 'myapp-app' do
source 'https://github.com/CocoaPods/Specs.git'
pod 'Nuke', '9.2.3'
pod 'Alamofire', '~> 4.9.1'
pod 'DeepDiff', '2.3.1'
def firebase_pods
pod 'Firebase/Analytics', '7.4.0'
pod 'Firebase/Crashlytics', '7.4.0'
pod 'Firebase', '7.4.0'
end
def appcenter_pods
pod 'AppCenter', '4.1.0'
pod 'AppCenter/Distribute', '4.1.0'
end
target :myapp do
project 'myapp.xcodeproj'
firebase_pods
appcenter_pods
target 'myappTests' do
end
end
target :ACMCore do
project 'ACMCore/ACMCore.xcodeproj'
target 'ACMCoreTests' do
firebase_pods
end
end
target :ACMData do
project 'ACMData/ACMData.xcodeproj'
target 'ACMDataTests' do
firebase_pods
end
end
target :ACMLoyalty do
project 'ACMLoyalty/ACMLoyalty.xcodeproj'
firebase_pods
target 'ACMLoyaltyTests' do
end
target 'ACMLoyaltyTestHost' do
end
end
target :ACMMVVM do
project 'ACMMVVM/ACMMVVM.xcodeproj'
target 'ACMMVVMTests' do
end
end
target :ACMNetwork do
project 'ACMNetwork/ACMNetwork.xcodeproj'
target 'ACMNetworkTests' do
end
end
target :ACMShared do
project 'ACMShared/ACMShared.xcodeproj'
target 'ACMSharedTests' do
end
end
end
PROJECT_ROOT_DIR = File.dirname(File.expand_path(__FILE__))
PODS_DIR = File.join(PROJECT_ROOT_DIR, 'Pods')
PODS_TARGET_SUPPORT_FILES_DIR = File.join(PODS_DIR, 'Target Support Files')
post_install do |installer|
## For more information: https://stackoverflow.com/questions/65904011/cocoapods-with-multiple-projects-firebase-causes-class-xxx-is-implemented-in-b
remove_static_framework_duplicate_linkage({
'ACMLoyalty' => ['FBLPromises', 'FIRAnalyticsConnector', 'FirebaseAnalytics', 'FirebaseCore', 'FirebaseCoreDiagnostics', 'FirebaseCrashlytics', 'FirebaseInstallations', 'GoogleAppMeasurement', 'GoogleDataTransport', 'GoogleUtilities']
})
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
#config.build_settings['LD_NO_PIE'] = 'NO'
if Gem::Version.new('9.0') > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
end
# CocoaPods provides the abstract_target mechanism for sharing dependencies between distinct targets.
# However, due to the complexity of our project and use of shared frameworks, we cannot simply bundle everything under
# a single abstract_target. Using a pod in a shared framework target and an app target will cause CocoaPods to generate
# a build configuration that links the pod's frameworks with both targets. This is not an issue with dynamic frameworks,
# as the linker is smart enough to avoid duplicate linkage at runtime. Yet for static frameworks the linkage happens at
# build time, thus when the shared framework target and app target are combined to form an executable, the static
# framework will reside within multiple distinct address spaces. The end result is duplicated symbols, and global
# variables that are confined to each target's address space, i.e not truly global within the app's address space.
#
# Previously we avoided this by linking the static framework with a single target using an abstract_target, and then
# provided a shim to expose their interfaces to other targets. The new approach implemented here removes the need for
# shim by modifying the build configuration generated by CocoaPods to restrict linkage to a single target.
def remove_static_framework_duplicate_linkage(static_framework_pods)
puts "Removing duplicate linkage of static frameworks"
Dir.glob(File.join(PODS_TARGET_SUPPORT_FILES_DIR, "Pods-*")).each do |path|
pod_target = path.split('-', -1).last
static_framework_pods.each do |target, pods|
next if pod_target == target
frameworks = pods.map { |pod| identify_frameworks(pod) }.flatten
Dir.glob(File.join(path, "*.xcconfig")).each do |xcconfig|
lines = File.readlines(xcconfig)
if other_ldflags_index = lines.find_index { |l| l.start_with?('OTHER_LDFLAGS') }
other_ldflags = lines[other_ldflags_index]
frameworks.each do |framework|
other_ldflags.gsub!("-framework \"#{framework}\"", '')
end
File.open(xcconfig, 'w') do |fd|
fd.write(lines.join)
end
end
end
end
end
end
def identify_frameworks(pod)
frameworks = Dir.glob(File.join(PODS_DIR, pod, "**/*.framework")).map { |path| File.basename(path) }
if frameworks.any?
return frameworks.map { |f| f.split('.framework').first }
end
return pod
end
最佳答案
一些 pod 依赖项被编译为静态库而不是动态库(例如 Firebase 和其他 Google 库)。
静态框架不能链接多次(例如,在框架目标和主目标中也链接上面的框架),因为静态框架的链接发生在构建时,但对于动态框架链接发生在运行时,链接器足够智能,可以避免重复。
因此您需要在 podfile 中编写一个脚本来删除静态库链接。
一个肮脏的例子:
post_install do |installer|
remove_static_framework_duplicate_linkage({
'FrameworkTarget1' => ['Firebase', 'FirebaseAnalytics', 'FirebaseCore', 'FirebaseCoreDiagnostics', 'FirebaseCoreDiagnosticsInterop', 'FirebaseInstanceID', 'FirebaseInstallations', 'GoogleAppMeasurement', 'GoogleDataTransport', 'GoogleDataTransportCCTSupport', 'GoogleUtilities'],
'FrameworkTarget2' => ['GoogleMaps', 'GooglePlaces'],
})
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LD_NO_PIE'] = 'NO'
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
# CocoaPods provides the abstract_target mechanism for sharing dependencies between distinct targets.
# However, due to the complexity of our project and use of shared frameworks, we cannot simply bundle everything under
# a single abstract_target. Using a pod in a shared framework target and an app target will cause CocoaPods to generate
# a build configuration that links the pod's frameworks with both targets. This is not an issue with dynamic frameworks,
# as the linker is smart enough to avoid duplicate linkage at runtime. Yet for static frameworks the linkage happens at
# build time, thus when the shared framework target and app target are combined to form an executable, the static
# framework will reside within multiple distinct address spaces. The end result is duplicated symbols, and global
# variables that are confined to each target's address space, i.e not truly global within the app's address space.
#
# Previously we avoided this by linking the static framework with a single target using an abstract_target, and then
# provided a shim to expose their interfaces to other targets. The new approach implemented here removes the need for
# shim by modifying the build configuration generated by CocoaPods to restrict linkage to a single target.
def remove_static_framework_duplicate_linkage(static_framework_pods)
puts "Removing duplicate linkage of static frameworks"
Dir.glob(File.join(PODS_TARGET_SUPPORT_FILES_DIR, "Pods-*")).each do |path|
pod_target = path.split('-', -1).last
static_framework_pods.each do |target, pods|
next if pod_target == target
frameworks = pods.map { |pod| identify_frameworks(pod) }.flatten
Dir.glob(File.join(path, "*.xcconfig")).each do |xcconfig|
lines = File.readlines(xcconfig)
if other_ldflags_index = lines.find_index { |l| l.start_with?('OTHER_LDFLAGS') }
other_ldflags = lines[other_ldflags_index]
frameworks.each do |framework|
other_ldflags.gsub!("-framework \"#{framework}\"", '')
end
File.open(xcconfig, 'w') do |fd|
fd.write(lines.join)
end
end
end
end
end
end
def identify_frameworks(pod)
frameworks = Dir.glob(File.join(PODS_DIR, pod, "**/*.framework")).map { |path| File.basename(path) }
if frameworks.any?
return frameworks.map { |f| f.split('.framework').first }
end
return pod
end
关于ios - 具有多个项目的 Cocoapods : Firebase causes "Class XXX is implemented in both (...)" warning,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65904011/
我刚刚设置了新的 Firebase 托管以及我的自定义域和我的网页等... 一切都很好,除了真正困扰我的是默认域: projectname.web.app projectname.firebaseap
Firebase 云消息传递和 Firebase 应用内消息传递有什么区别?它们都会向您的应用发送发生了某些事情的通知。我查看了他们的文档,这些是他们的单行描述: Firebase 云消息传递: Fi
是否有任何工具可以帮助将数据从开发迁移到登台再到生产?如果没有,是否有计划 build 它们? 我知道您可以从 Forge 导出 JSON 和导入 JSON,但这不包括授权和安全设置。 最佳答案 我们
firebase 网络应用和 firebase 托管有什么区别?据我所知,网络应用程序用于实际上只是浏览器的应用程序,并且 firebase 托管仅用于网站。 最佳答案 Firebase for We
我有两个 firebase 项目 F1 和 F2。我正在使用基于密码的身份验证来识别 F1 上的用户。我希望在 F2 中识别相同的用户。所以我正在考虑以下基于 this question 的场景: C
正在使用 firebase 云功能 构建服务器,我需要其他服务器来调用我的服务器端点。最重要的是,我需要这些调用我的服务器的第三方域进行身份验证。 问题 1:如何创建这样的服务帐户,在调用中包含服务帐
我开发了一个应用程序来测试使用 flutter 和谷歌身份验证的谷歌登录功能。该项目是一个封闭的项目,只有我可以访问它。但最近我看到有一个来自未知电子邮件 ID 的谷歌登录。用户如何在没有构建我的应用
我有 2 个存储库,一个用于 firebase 功能,另一个用于静态 firebase 托管 react 站点。他们都使用相同的firebase项目。 myfirebaseproject --- fi
背景 -我正在设置一项新功能,允许用户选择他们所在的城市,因为我的应用程序是一个公共(public)交通应用程序。我希望城市位于单独的数据库中,为此我在我的 firebase 项目中创建了一个辅助数据
我构建了一个网络平台,允许用户使用一个用户帐户注册多个网络应用程序。每个应用程序都有自己独立的 Firebase 数据库。是否可以使用 firebase 身份验证并在各种 firebase 数据库之间
在 Firebase 控制台内的 Cloud Messaging View 下,用户可以创建测试通知。此功能还允许您安排通知将发送到一个设备或一组设备的时间。 是否可以创建和发送预定 使用 Fireb
我们正在为我们最近的项目使用 firebase 平台。我们最近推出并一直在监控使用情况。 我可以在 firebase 控制台中看到 firebase 调用的总数,但找不到查看每个函数调用次数的方法。
我正在开发一个使用 Webpack 捆绑模块的 Web 应用程序。无论出于何种原因,在应用程序中引入 Firebase 都会导致 Webpack 抛出错误。当 Webpack 尝试加载 Firebas
我无法在 firebase 控制台中提交支持请求。 登录 Firebase 控制台 导航至 https://firebase.google.com/support/contact/troublesho
我安装 Firebase CLI (firebase-tools) https://github.com/firebase/firebase-tools通过此代码: curl -sL firebase
在我的应用程序中,我尝试使用Firebase crash10.2.1,但无法获得编译的好处。我不断收到消息: 'Failed to resolve:com.google.firebase:fireba
我的 firebase 应用有一个注册用户列表。这些是通过电子邮件和密码身份验证创建的。 我想将 Firebase 数据和用户列表传输到另一个 Firebase 应用。 传输 firebase 数据很
如果我将数据插入到 firebase 中的 node/a/0 中。 结果将把a视为数组a[0]。 同样,如果我在 node/a/1 中设置数据,第一个数组将变为 null "a" : [
我是 Firebase 新手,我正在尝试 Firebase 数据库规则和 Firebase 身份验证。 我尝试使用 firebase 身份验证来执行 firebase 数据库规则。 因此,我创建了一封
所以场景如下: 当我从 Firebase 存储访问文件时: 我从存储桶获取文件(.html、.png、.zip 等)(尺寸较小,不超过 2mb)。 将该文件存储在我的本地存储中,这样应用就不需要再次下
我是一名优秀的程序员,十分优秀!