0

Check out this error in the most recently updated Xcode (13):

enter image description here

Did Apple screw something up? How do I fix this? I can see when I start typing SortOrder it shows a Protocol and an Enum.

Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100
  • I only get the enum. Can you command + click on the protocol version and show where it is defined? – George Sep 23 '21 at 12:27
  • @George - cannot click on it in the list, when I click on it when there is no list it understandably shows a ? because, heh, it's ambiguous. This is in a react-native app, FWIW. Weird thing is this built fine is XCode 12. – Adam Jenkins Sep 23 '21 at 12:31
  • Worth adding the `react-native` tag as it could be relevant. I only can see `SortOrder` from Foundation – George Sep 23 '21 at 12:35
  • @George - you are right, there is another dependency that I failed to mention - CouchbaseLiteSwift that is exporting the protocol. Still unsure why this built in Xcode 12. Now, because I'm new to swift stuff, maybe I can ask for help - any idea how to namespace this? – Adam Jenkins Sep 23 '21 at 12:37

1 Answers1

2

Because of the conflicting SortOrder enum and protocol, it's ambiguous to the compiler which one you want to use.

Because the SortOrder enum is part of the Foundation framework, you can do the following to explicitly use it:

Foundation.SortOrder

Example usage:

Foundation.SortOrder.forward

Or in your case, you needed SortOrder from CouchbaseLiteSwift:

CouchbaseLiteSwift.SortOrder
George
  • 25,988
  • 10
  • 79
  • 133
  • 1
    In my specific case I actually needed to do `var sort: CouchbaseLiteSwift.SortOrder` but the intention of your answer is correct. Gotta say, `SortOrder` is a pretty generic sounding thing, I can only imagine how many issues exposing this enum from Foundation in iOS 15 this could've potentially caused. – Adam Jenkins Sep 23 '21 at 13:26
  • 1
    @Adam It looks like `SortOrder` is new to Foundation as of iOS 15, so I assume that's why there is now a conflict. Glad it helped! (sorry for using wrong `SortOrder`, it's even ambiguous to me :p) – George Sep 23 '21 at 13:29