Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

Why Xcode doesn't show me deprecated methods?

I have an issue with Xcode. While I was working with Android Studio, it showed me deprecated methods once I used them. However, when it comes to Xcode, it doesn't show me deprecated methods. Look at the image below: Xcode 1

Xcode 2

According to Apple's docs, the ".navigationBarTitle" is deprecated, however Xcode doesn't light it up.

Code:

import SwiftUI

struct HomeView: View {
    var body: some View {
        NavigationView {
                Spacer()
                    .navigationBarTitle("title", displayMode: .inline)
        }
    }
}

struct HomeView_Previews: PreviewProvider {
    static var previews: some View {
        HomeView()
    }
}

question from:https://stackoverflow.com/questions/65647440/why-xcode-doesnt-show-me-deprecated-methods

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If look at code where ".navigationBarTitle" is declared I see this code:

@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use navigationTitle(_:) with navigationBarTitleDisplayMode(_:)")
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public func navigationBarTitle(_ titleKey: LocalizedStringKey, displayMode: NavigationBarItem.TitleDisplayMode) -> some View

It has different redeclarations, but here no any words about ".navigationBarTitle" is deprecated. It's presented in ios13, will be deprecated in ios100000 :).

XCode shows deprecated methods for sure, but it also depends of used minimaldeveloper ios version you use - if you use some old ios versions - you can not see messages, because of code is "not yet" deprecated for used minimal version.

Update: here I attach the image showing XCode deprecation message.

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...