'Xcode project cannot see .txt file (Bundle.main.path(forResource:, ofType:) returns nil)
I am writing a console app and I am trying to add .txt file to my Xcode project via Bundle.main.path(forResource:, ofType:), but my project cannot see this file (function readFromTestFile() returns nil - screen #1). Picture 1
File was added to the project successfully, checkboxes are checked screen #2, but I don't have "Target membership" for this file and there’s no way to set it Picture 3, because it’s greyed out.
I managed to tick the "Target membership" after I googled that I need to add a Headers phase (Picture 4) in the Target settings. I added it, and it seems like the file in the project ("Target membership" now ticked for this file, but I can’t do anything with this option, because it’s grayed out), but the project still doesn’t see the file and Bundle.main.path(forResource:, ofType:) returns nil.
The question is how can I add a file to the project to work with it, maybe I doing something wrong?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
