Ios 如何消除这些与使用SwiftUI相关的常见Firebase警告?
我在我的SwiftUI/Combine应用程序中使用Firebase,我注意到几个警告,我想进行故障排除。他们没有破坏东西,但我想解决它们。我使用Xcode 12.4和最新的Swift包依赖项(GoogleUtilities 7.2.2和Firebase 7.7.0)得到这些警告 这是控制台中出现的第一个警告:Ios 如何消除这些与使用SwiftUI相关的常见Firebase警告?,ios,firebase,swiftui,navigationbar,Ios,Firebase,Swiftui,Navigationbar,我在我的SwiftUI/Combine应用程序中使用Firebase,我注意到几个警告,我想进行故障排除。他们没有破坏东西,但我想解决它们。我使用Xcode 12.4和最新的Swift包依赖项(GoogleUtilities 7.2.2和Firebase 7.7.0)得到这些警告 这是控制台中出现的第一个警告: [GoogleUtilities/AppDelegateSwizzler][I-SWZ001014] App Delegate does not conform to UIApplica
[GoogleUtilities/AppDelegateSwizzler][I-SWZ001014] App Delegate does not conform to UIApplicationDelegate protocol.
以下是我配置Firebase的方式,仅供参考:
import SwiftUI
import Firebase
@main
struct MyApp: App {
@StateObject var authState = AuthState()
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
RootView()
.environmentObject(authState)
}
}
}
这是第二个警告,在我使用.navigationBarTitle
修改器设置导航栏标题后出现
[LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(
"<NSLayoutConstraint:0x280c8cfa0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x109219b60]-(6)-[_UIModernBarButton:0x109218760'Fullres'] (active)>",
"<NSLayoutConstraint:0x280c8cff0 'CB_Trailing_Trailing' _UIModernBarButton:0x109218760'Fullres'.trailing <= _UIButtonBarButton:0x109217100.trailing (active)>",
"<NSLayoutConstraint:0x280c8dd60 'UINav_static_button_horiz_position' _UIModernBarButton:0x109219b60.leading == UILayoutGuide:0x2816bcfc0'UIViewLayoutMarginsGuide'.leading (active)>",
"<NSLayoutConstraint:0x280c8ddb0 'UINavItemContentGuide-leading' H:[_UIButtonBarButton:0x109217100]-(0)-[UILayoutGuide:0x2816bcee0'UINavigationBarItemContentLayoutGuide'] (active)>",
"<NSLayoutConstraint:0x280c88f00 'UINavItemContentGuide-trailing' UILayoutGuide:0x2816bcee0'UINavigationBarItemContentLayoutGuide'.trailing == _UINavigationBarContentView:0x109214320.trailing (active)>",
"<NSLayoutConstraint:0x280c8e530 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x109214320.width == 0 (active)>",
"<NSLayoutConstraint:0x280c892c0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x2816bcfc0'UIViewLayoutMarginsGuide'](LTR) (active, names: '|':_UINavigationBarContentView:0x109214320 )>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x280c8cfa0 'BIB_Trailing_CB_Leading' H:[_UIModernBarButton:0x109219b60]-(6)-[_UIModernBarButton:0x109218760'Fullres'] (active)>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
[LayoutConstraints]无法同时满足约束。
可能下面列表中至少有一个约束是您不想要的。
试试这个:
(1) 看看每一个约束,试着找出你不期望的;
(2) 找到添加了不需要的约束的代码,然后修复它。
(
"",
“第一条消息是由Firebase试图查找AppDelegate
引起的,但由于您的应用程序遵循新的SwiftUI应用程序生命周期,因此没有
您可以通过如下方式添加AppDelegate
来消除此警告:
导入快捷界面
进口火基
类AppDelegate:NSObject,UIApplicationDelegate{
func应用程序(u应用程序:ui应用程序,
didFinishLaunchingWithOptions launchOptions:[UIApplication.LaunchOptionKey:Any]?=nil)->Bool{
FirebaseApp.configure()
返回真值
}
}
@主要
结构MyApp:App{
@UIApplicationDelegateAdaptor(AppDelegate.self)变量委托
@StateObject变量authState=authState()
init(){
FirebaseApp.configure()
}
var body:某个场景{
窗口组{
RootView()
.environmentObject(authState)
}
}
}
有关更多详细信息,请参阅
作为补充说明,我们正在研究初始化Firebase SDK的其他方法(swizzling也有它的挑战)——请参阅类似的GitHub问题
至于第二个警告,这与Firebase无关。如果您的搜索StackOverflow,您会发现许多其他人也遇到了此问题。看起来非常相似,并且有一个您可能想要尝试的公认答案。这太好了–谢谢您,Peter!