Xcode 7.3: import Module displayed with strikethrough
Asked Answered
G

4

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.

Gracye answered 23/3, 2016 at 14:11 Comment(5)
Yeah! same I got when i was importing CoraData moduleHeathenism
Yes, and MapKit too.Gracye
CoreData is not struck through for me, but others like ClockKit and CoreLocation are.Decibel
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 ;)Gracye
@PetahChristian see I have added snapshot I am getting for CoreData too here, but interesting MapKit looks fine with meHeathenism
P
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.

Pompom answered 25/3, 2016 at 0:45 Comment(4)
"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.Trichromatic
It is still an answer, if its now clear that its just a bug, already reported and hopefully fixed in the next release.Gracye
@JeffreyBosboom Updated. The commit ID would already be implicitly associated with a release, but I've named it explicitly for clarity.Instruction
Xcode 7.3.1 (currently available for download as a GM seed) includes Swift 2.2.1, according to the Swift download page, although xcrun swift -v still calls it version 2.2.Degrading
O
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.

Orozco answered 23/3, 2016 at 15:46 Comment(4)
While Xcode behaves correctly in your case, where you have intentionally duplicated the module import, misbehaviour explained in this question is still the case. The module required to be imported but displayed in strikethrough font.Spectrometer
@EugeneDubinin right, that's why I said it was potentially a possible duplicate, not for-sure-a100% duplicate.Orozco
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...Altdorf
This also happens if Foundation is imported indirectly via an include from the bridging header file.Stanch
J
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

Jankell answered 8/3, 2019 at 15:36 Comment(0)
D
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
Defeatism answered 21/12, 2017 at 12:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.