• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Swift circular imports
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swift circular imports


  • Subject: Swift circular imports
  • From: Alex Kac <email@hidden>
  • Date: Tue, 03 Nov 2015 10:07:38 -0700

I’ve got a bit of a foggy head this morning so perhaps I’m just not thinking clearly. We are moving our code from Obj-C to swift. All new code is in Swift. We are hitting an issue with a circular import however.

So here is an example:

App Delegate is still in ObjC, but all new code is written in an extension in Swift. The goal is to move more and more code into Swift and eventually turn it around where the app delegate is a Swift class with an objective C extension.

The App Delegate.swift refers to classes that are written in Objective C - our main View Controllers.
We are writing a new super class for our main view controllers in Swift, but the view controllers themselves are still ObjC (for now).

So you have a Swift extension, calling an objective C subclass of a swift super class.

Hopefully you see the problem: Swift has to compile first to generate its -Swift.h file, but it can’t compile since the header for the main view controllers refer to a Swift super class (so no forward declarations), and the main view controller headers don’t work until the -Swift file is generated.

So I’m curious if anyone else has had to hit that scenario and what was your solution (besides rewriting everything into Swift…which is kind of what I’ve been doing, but now I’ve hit large classes I’m not into that yet).


Also, how do I change my email address for this list without unsubscribing/resubscribing - or is that the only way?



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Swift circular imports
      • From: Alex Kac <email@hidden>
  • Prev by Date: More of a dev tools question, so please advise if this is the wrong place to ask - automating the Network Link Conditioner
  • Next by Date: Re: Swift circular imports
  • Previous by thread: More of a dev tools question, so please advise if this is the wrong place to ask - automating the Network Link Conditioner
  • Next by thread: Re: Swift circular imports
  • Index(es):
    • Date
    • Thread