从Xcode 11更新为12后,应用程序委托/场景委托和Firebase问题 [英] App Delegate/Scene Delegate and Firebase issues after updating from Xcode 11 to 12

查看:56
本文介绍了从Xcode 11更新为12后,应用程序委托/场景委托和Firebase问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我一直在构建我的第一个应用程序,最近我更新到Xcode 12时,发生了多个问题...

我注意到不再有应用程序和场景委托文件,但我的项目仍在使用它.想知道我如何清理而不将所有内容复制并粘贴到新项目中.

我也有多个警告说:

将iOS Simulator部署目标'IPHONEOS_DEPLOYMENT_TARGET'设置为8.0,但支持的部署目标版本范围是9.0至14.0.99."

我目前的部署目标是iOS13.如果我将其部署目标更改为9,则URLIMAGE模块会出现一个错误,因为它的最小值为11.当将其更改为11时,我会存在999多个错误...

以下示例:

我不知道要放什么!

我还与URLImage一起看到,我的Firebase无法正常工作,并且大部分UI都消失了.我正在运行instagram教程和主页"资讯提供现在为空白.我的故事供稿文件仍然可以正常运行,不确定是否与firebase或URLImage有关?

我玩过这个视图,并在故事滚动视图的下面添加了一个矩形,它已经出现了,所以我怀疑它与firebase有关.

当前代码:

 导入SwiftUI导入URLImage导入Firebasestruct HomeView:查看{@ObservedObject var homeViewModel = HomeViewModel()var body:some View {NavigationView {ScrollView(.ver​​tical,showsIndicators:false){故事()Rectangle().frame(宽度:200,高度:200).foregroundColor(.red)如果!homeViewModel.isLoading {ForEach(self.homeViewModel.posts,id:\ .postId){VStack(alignment:.center){HeaderCell(post:post)FooterCell(post:post)} .background(Color.white).cornerRadius(10).padding(.leading,10).padding(.trailing,10)}}} 

这是我的HomeViewModel:

  import Foundation导入SwiftUI导入Firebase类HomeViewModel:ObservableObject {@已发布的var帖子:[Post] = []@Published var isLoading =否var listener:ListenerRegistration!//   在里面() {//loadTimeline()//}func loadTimeline(){self.posts = []isLoading = trueApi.Post.loadTimeline(onSuccess:{(posts in inself.isLoading =假如果self.posts.isEmpty {self.posts =帖子}},newPost:{(post)in如果!self.posts.isEmpty {self.posts.insert(post,at:0)}}){(听众)在self.listener =侦听器}}} 

任何帮助将不胜感激!

解决方案

在没有看到您的代码的情况下,很难说出您所看到的问题的确切原因是什么.但是,要回答您的一些问题:

  1. 您仍然可以使用旧的方式设置应用程序(使用 AppDelegate SceneDelegate .请参阅我的回答此答案,以找到与您的Pod的部署目标相匹配的方法.

关于UI消失的原因,如果您可以提供几个相关的代码片段以及日志输出中的几行内容,将很有用.另外,请确保检查您的安全规则设置是否正确.

So I've been building my first app and when I recently updated to Xcode 12 multiple issues have occurred...

I have noticed that there is no longer app and scene delegate files but my project is still using it. Wondering how I clean this up without copying and pasting everything into a new project.

I also am having multiple warnings saying:

"The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.0.99."

I currently have my Deployment target to iOS 13. If I change it to 9 my URLIMAGE module comes up an error as it has a minimum of 11. When I change it to 11 I have 999+ errors...

example below:

I have no idea what to put it to!

I am also seeing along with URLImage that my firebase isn't properly working and that most of my UI has disappeared. I am running through an instagram tutorial and my "Home" feed is now blank. My story feed file is still working fine though, not sure if it has something to do with firebase or URLImage?

I have played around with the view and added in a rectangle underneath my story scrollview and it has appeared so I suspect it has something to do with firebase.

Current code:

import SwiftUI
import URLImage
import Firebase

struct HomeView: View {
    
    @ObservedObject var homeViewModel = HomeViewModel()
    
    var body: some View {
        NavigationView {
            
            ScrollView(.vertical, showsIndicators: false) {
                
                Story()
                Rectangle().frame(width: 200, height: 200).foregroundColor(.red)
                if !homeViewModel.isLoading {
                    ForEach(self.homeViewModel.posts, id: \.postId) { post in
                        VStack(alignment: .center) {
                            
                            HeaderCell(post: post)
                            FooterCell(post: post)
                            
                            }.background(Color.white).cornerRadius(10)
                            .padding(.leading, 10).padding(.trailing, 10)
                    }
                    
                }
                }

This is my HomeViewModel:

import Foundation
import SwiftUI
import Firebase

class HomeViewModel: ObservableObject {
    @Published var posts: [Post] = []
    @Published var isLoading = false
    
    var listener: ListenerRegistration!
    
//    init() {
//        loadTimeline()
//    }
    
    func loadTimeline() {
        self.posts = []
        isLoading = true
        
        Api.Post.loadTimeline(onSuccess: { (posts) in
            self.isLoading = false

            if self.posts.isEmpty {
                self.posts = posts
            }
        }, newPost: { (post) in
            if !self.posts.isEmpty {
                self.posts.insert(post, at: 0)
            }
        }) { (listener) in
            self.listener = listener
        }

    }
}

Any help would be very much appreciated!

解决方案

Without seeing your code, it's hard to say what exactly is the cause for the issues you're seeing. However, to answer some of your questions:

  1. You can still use the old way the app is set up (using the AppDelegate and SceneDelegate. See my answer here for more details
  2. You can safely ignore the warnings. If it bothers you a lot, check out this answer for a way to match the deployment target of your pods.

As for why your UI has disappeared, it would be useful if you could provide a couple of relevant code snippets and a few lines from your log output. Also, make sure to check if your Security Rules are set up correctly.

这篇关于从Xcode 11更新为12后,应用程序委托/场景委托和Firebase问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆