3 Replies
      Latest reply: Oct 19, 2016 4:15 PM by eskimo RSS
      Tadd Level 1 Level 1 (0 points)

        Would someone mind sanity-checking me on something, please?

         

        I'm trying to build the RabbitMQ Client, while porting it to Swift 3 and OS X (which it doesn't support).  That is, the tests are written in Swift while the RabbitMQ library itself remains Obj-C.  I'm have a frustrating compile error between the two.  I've boiled the error down to the following two files.  When I make an Xcode 8 project with just these, it won't build...  and they couln't be simpler...

         

        ChannelSpy.swift :

        import Foundation
        class ChannelSpy: RMQChannel {
          func direct(_ name: String!) {}
        }
        

         

        RMQChannel.h :

        #import <Foundation/Foundation.h>
        @protocol RMQChannel
        - (void) direct:(NSString *)name;
        @end
        

         

        Bridging-Header.h :

        #import "RMQChannel.h"
        

         

        Upon Build, I get the following:

           Type 'ChannelSpy' does not conform to protocol 'RMQChannel'

               Protocol requires function 'dirent' with type '(String!) -> Void'; do you want to add a stub?

        /Proj/. . ./ChannelSpy.swift:4:7: error: type 'ChannelSpy' does not conform to protocol 'RMQChannel'
        class ChannelSpy: RMQChannel {
              ^
        __ObjC.RMQChannel:2:17: note: protocol requires function 'dirent' with type '(String!) -> Void'; do you want to add a stub?
            public func dirent(_ name: String!)
                        ^
        

         

        What's this "dirent" stuff?  Am I (or the Rabbit project) not allowed to use the name "direct"?  I googled this (extensively, of course) and I see vestiges of "#define direct dirent" in ancient BSD code remnants, but I'm sure that has nothing to do with anything.

         

        Can anyone shed any light on this mystery?  Or help verify whether or not I've lost my mind?  Thanks SO MUCH for any help...

         

        Tadd

        • Re: "direct" vs. "dirent" -- am I crazy?
          Tadd Level 1 Level 1 (0 points)

          Why do some "moderator approvals" on messages (like this one) take so long?

          • Re: "direct" vs. "dirent" -- am I crazy?
            eskimo Apple Staff Apple Staff (6,995 points)

            I managed to reproduce the problem with the minimal test case you described.  I’m pretty sure this is a bug in Xcode.  You should definitely file a bug about it.  Please post your bug number, just for the record.

            Curiously, if I change RMQChannel.h to this:

            @class NSString;
            @protocol RMQChannel 
            - (void) direct:(NSString *)name; 
            @end
            

            things work.  I can then add the @import Foundation; to other includes listed after RMQChannel.h in the bridging header, and things still work.  But any include of Foundation in or before RMQChannel.h triggers the failure.

            If I change the method name to something else (-directQ, for example), it works.

            If I switch direct to be a property, things work.

            My conclusion is that something in Foundation has caused Swift’s C importer to mix up dirent and direct, but anything beyond that would be pure speculation on my part.  Regardless, it’s definitely Radar Time™.

            Share and Enjoy

            Quinn “The Eskimo!”
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"