[swift-users] DispatchQueue extension

Quinn "The Eskimo!" eskimo1 at apple.com
Fri Oct 7 02:08:45 CDT 2016


On 6 Oct 2016, at 20:20, Nick Brook via swift-users <swift-users at swift.org> wrote:

> I have an extension on DispatchQueue and I have Objective-C code which uses my swift code, so the DispatchQueue extension is exported to the Swift objective-c header as
> 
> @interface OS_dispatch_queue
> 
> However, Xcode 8.0 and 8.2b2 both error ‘Cannot find interface declaration for ‘OS_dispatch_queue’’. I’ve reported this as a bug, but is there any way I can stop the code being exported to objective-c in the interim?

I tried replicating this myself and couldn’t.  Specifically, in Xcode 8.0:

1. I created a command line tool project

2. added `test.swift`, which looks like this:

import Foundation

extension DispatchQueue {
    func foo() {
    }
}

extension NSCoder {
    func bar() {
    }
}

3. added an Objective-C class which imported <xxx-Swift.h>, where `xxx` is the target name

It built just fine.  Looking at <xxx-Swift.h>, I see `bar` generates code like this:

@interface NSCoder (SWIFT_EXTENSION(xxst))
- (void)bar;
@end

but I see no reference to `foo` or `OS_dispatch_queue`.  What am I missing here?

Other than your bug number (-:  Please post that.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware




More information about the swift-users mailing list