I think the behavior is due to the compiler from Xcode 10.3.
Of course it does.
Could I somehow use the compiler from Xcode 11.3 to Xcode 10.3?
No: what you do is write code that works with both compilers.
Let’s be clearer. This has to do only indirectly with the version of Xcode. What’s really important is the version of Swift. Different versions of Swift have different compilers and different language rules, as the language evolves over time.
Let’s take the second one:
var hasViewed: Bool { firstViewedTimestamp > 0 }
In Xcode 11.3 no errors. In Xcode 10.3: “Missing return in a function expected to return ‘Bool'”.
Correct. In Swift 5.1 a new rule was introduced that it is legal to omit the keyword return
in a one-line function body. But the rule is new, so for an earlier version of Swift you still have to say that the old way:
var hasViewed: Bool { return firstViewedTimestamp > 0 }
That will work for both older and newer versions of Swift, so just use that and all will be well.
1
solved But failed in Xcode 10.3 but work in Xcode 11.3