2 Replies
      Latest reply on Feb 5, 2017 3:17 AM by adamzikmund
      adamzikmund Level 1 Level 1 (0 points)

        Hi, I am working on my diploma where i am comparing Swift 3 with Objective-C. So i make two my own frameworks which one is named obj and second one is called swt. obj framework is containig Objective-C classes and swt is containing Swift classes. And there is my problem both frameworks are containing Person class.


        So i want in my code call something like

        let swtPerson = swt.Person()
        let objPerson = obj.Person()


        But when i make class "Person" in swt framework public then i can't use "Person" class from obj framework due to message "No type named Person in module obj".

        When i remove public from class "Person" in swt framework then i can use "Person" class from obj framework without error but i cannot use "Person" class from swt framework anymore.


        I search for the answer why is this happening, but i can't anything useful. Maybe it's caused somehow by Swift itself which is in someway overlaps Objective-C class "Person" from obj framework.

        • Re: Objective-C and Swift frameworks with same classes
          eskimo Apple Staff Apple Staff (13,345 points)

          I’m not 100% sure why you’re seeing the error you’re seeing.  However, I have a big picture comment.  You wrote:

          I am working on my diploma where i am comparing Swift 3 with Objective-C.

          Given that the goạl is to compare the two languages, why are you naming the classes the same?  In Objective-C classes use a prefix (NS for Foundation and AppKit, UI for UIKit, and so on) to prevent name collisions.  If you’re doing a side-by-side comparison of the two languages, it would make sense to use the ‘native’ conventions of each language, which means the Objective-C Person should be AZPerson, right?

          Share and Enjoy

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