Reputation: 322
I am trying to get some info from a plist but when I try to access bundle in a swift file I am not able to access it. When I type bundle, Xcode is not recommending anything. It works on other swift files in the same project. I don't know what can be the issue.
Upvotes: 0
Views: 458
Reputation: 1739
It's may a bug of Xcode about code suggestion.
You can access Bundle.main
normally without any problem.
Restart Xcode may solve code suggestion problem.
UPDATE: If your file not import Foundation or UIKit, You must import Foundation to access Bundle
Upvotes: 0
Reputation: 1391
Since Bundle
is a Foundation class, ensure you are importing the Foundation framework at the beginning of your Swift file.
đź“Ś Note: UIKit includes the Foundation framework, so you can alternatively
import UIKit
.
import Foundation
This should enable SourceKit’s—& therefore Xcode’s—code completion.
Upvotes: 2