swiftcompiler-warningsswift-playgroundpreprocessor-directiveipad-playgrounds

Is there a way to ignore warnings in dependent packages? Is there a way to #if an os that the compiler doesn't know about?


I am using Swift Playgrounds to do App Development. One of my dependencies has some code like this:

#if os(visionOS)

That causes my app to have a warning due to Swift Playgrounds not being updated to Swift 5.9 and thus it doesn't know about visionOS.

The dependency is an open project so I could do a pull request, but is there a way to do a #if check for an OS that the compiler doesn't know about? Perhaps there's a way to define the OS temporarily to silence the warning?


Solution

  • Add this Swift version check to use os(visionOS):

    #if swift(>=5.9)
      #if os(visionOS)
        // Do Stuff Here
      #endif // os(visionOS)
    #endif // swift(>=5.9)