58

After upgrading Xcode to 7.3, I just found that some modules are stricken out while importing, like in this screenshot:

But after adding the module (so just pressing enter) everything is fine. What does that mean? The module here is written in Swift and works fine.

shim
  • 9,289
  • 12
  • 69
  • 108
derdida
  • 14,784
  • 16
  • 90
  • 139
  • Yeah! same I got when i was importing **CoraData** module – swiftBoy Mar 23 '16 at 14:14
  • Yes, and MapKit too. – derdida Mar 23 '16 at 14:15
  • `CoreData` is not struck through for me, but others like `ClockKit` and `CoreLocation` are. –  Mar 23 '16 at 14:25
  • Its strange - because everything work fine (and it happens not to all modules) Maybe a Bug, or maybe a Feature which does not make any sense ;) – derdida Mar 23 '16 at 14:27
  • @PetahChristian see I have added snapshot I am getting for CoreData too [**here**](http://i.stack.imgur.com/LQ3l1.png), but interesting MapKit looks fine with me – swiftBoy Mar 23 '16 at 14:35

4 Answers4

39

This is a bug. We have fixed it in 218010af, which should be included in the Swift 2.2.1 release and is included in the 2016-04-12-a developer snapshot.

JAL
  • 41,701
  • 23
  • 172
  • 300
Xi Ge
  • 406
  • 3
  • 4
  • 10
    "This is a bug that was fixed in version X" is an answer -- but this answer doesn't mention the version, so it's not very helpful to future readers. – Jeffrey Bosboom Mar 25 '16 at 02:39
  • 2
    It is still an answer, if its now clear that its just a bug, already reported and hopefully fixed in the next release. – derdida Mar 25 '16 at 08:12
  • 1
    @JeffreyBosboom Updated. The commit ID would already be implicitly associated with a release, but I've named it explicitly for clarity. – Jeremy Apr 13 '16 at 19:23
  • 1
    Xcode 7.3.1 (currently available for download as a [GM seed](https://developer.apple.com/xcode/download/)) includes Swift 2.2.1, according to [the Swift download page](https://swift.org/download/), although `xcrun swift -v` still calls it version 2.2. – rob mayoff Apr 29 '16 at 03:02
24

The strikethrough occurs if you try to import a module that has already been imported by your file or module:

import

In this case, I have already imported Foundation (which implicitly imports CoreFoundation), so Xcode is telling you that there is no need to import either module again.

JAL
  • 41,701
  • 23
  • 172
  • 300
  • 2
    While Xcode behaves correctly in your case, where you have intentionally duplicated the module `import`, misbehaviour explained in [this question](http://stackoverflow.com/q/35671637/1492173) is still the case. The module required to be imported but displayed in strikethrough font. – Yevhen Dubinin Mar 23 '16 at 16:19
  • @EugeneDubinin right, that's why I said it was potentially a possible duplicate, not for-sure-a100% duplicate. – JAL Mar 23 '16 at 16:24
  • If the class Dog is a subclass to class Animal, and animal has imported e.g. Alamofire, then you import Alamofire in Dog Alamofire gets a red strikethrough as well. But it is misleading, since subclasses cant use the imports of its superclass, so I guess this is a bug as well... – Sajjon Jun 24 '16 at 08:35
  • This also happens if Foundation is imported indirectly via an include from the bridging header file. – Martin R Nov 04 '18 at 10:21
6

It usually happens when a framework is already imported by any other framework you have already been imported.

For example, UIKit is already imported with Foundation so you don't need to import it manually.

enter image description here

Abhijith
  • 3,094
  • 1
  • 33
  • 36
1

I changed the order of the imports

import Foundation
import UIKit
import LayerKit
import Atlas  < red line


import Foundation
import UIKit
import Atlas
import LayerKit

Some notes that may be causing it:

  • LayerKit importing Atlas even though LayerKit is the lower level API Atlas is the UI layer

  • Both were Cocoapod imports

  • Error appeared when I created an 2nd Schema for App Store/Enteprise releases and cleaned one and switch to the other.

  • Deleting Derived Data didnt clear it.
  • So tried rearranging them and red line disappeared
brian.clear
  • 5,277
  • 2
  • 41
  • 62