Uploaded image for project: 'Swift'
  1. Swift
  2. SR-1226

Marking a method as unavailable in iOS Extensions should allow me to use APIs unsafe for extensions

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None
    • Environment:

      Xcode 7.3 with Swift 2.2

      Description

      I am writing a dynamic framework used both by an iOS application target and an iOS extension target. The framework is marked with the "allow app extension API only" flag.

      The following swift code from the framework will fail to compile:

      @available(iOSApplicationExtension, unavailable)
      func test() {
          _ = UIApplication.sharedApplication()
      }
      

      The Objective-C version, using NS_EXTENSION_UNAVAILABLE will compile:

      - (void)test NS_EXTENSION_UNAVAILABLE("don't use this in extensions") {
          [UIApplication sharedApplication];
      }
      

      Expected Behavior:
      @available(iOSApplicationExtension, unavailable) should behave like NS_EXTENSION_UNAVAILABLE. Methods or classes marked as available in extensions should be allowed to use APIs not available for extensions.

        Attachments

          Activity

            People

            • Assignee:
              tjw Timothy Wood
              Reporter:
              kaybutter Kay Butter
            • Votes:
              9 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated: