Skip to content

[SR-1226] Marking a method as unavailable in iOS Extensions should allow me to use APIs unsafe for extensions #43834

@swift-ci

Description

@swift-ci
Previous ID SR-1226
Radar rdar://problem/34949130
Original Reporter kaybutter (JIRA User)
Type Bug
Environment

Xcode 7.3 with Swift 2.2

Additional Detail from JIRA
Votes 10
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 51ba9fd65347cc3638554b002b1937f1

Issue 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions