Bundle.main.path(forResource:) returns nil
Thanks to https://stackoverflow.com/users/1187415/martin-r:
The file system on iOS devices is case-sensitive: "zip" != "ZIP".
After changing to ZIP it worked perfectly.
Bundle.main.path(forResource... always returns nil when looking for xml file
Try this code:
if let filePath = Bundle.main.url(forResource: "config.xml", withExtension: nil, subdirectory: "/Resources") {
/// Do something with the filePath
}
Bundle.main.path(forResource:ofType:inDirectory:) returns nil when app name contains space
It's highly recommended to use the URL related API anyway
Bundle.main.url(forResource: "testFile", withExtension: "rtf")
pathForResource returns nil
The resources will be put in the root of your app bundle. The only time you will get folders inside your app bundle is when you create folder references in your project. These will be blue folders, not yellow.
Change your code to (remove the inDirectory
part):
if let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") {
print("this should work but doesn't")
}
Related Topics
Find Attributes from Attributed String That User Typed
Uitextfield in Uialertcontroller (Border, Backgroundcolor)
How to Disable the Back Navigation Menu in iOS 14+
How to Send Multiple Parameterts to PHP Server in Http Post
Centering a View in Its Superview Using Visual Format Language
Expanding and Collapsing Uitableviewcells with Datepicker
Why Is There an Frame Rectangle and an Bounds Rectangle in an Uiview
Xcode 6 Save for Enterprise Deployment Does Not Create Plist for IPA Anymore
Open Uisplitviewcontroller to Master View Rather Than Detail
Swift Protocol Get Only Settable
Uitextfield -Webview No Longer Supported
Google Places Autocomplete on iOS - Can't Load Search Results - Try Again
Are View Controllers with Nib Files Broken in iOS 8 Beta 5
iPhone Different Screen Sizes in Flash? (Getting Black Bars)
Multiline Label in Uistackview
Avplayer Stops Playing and Doesn't Resume Again
iOS Builds/Ipa Creation No Longer Works from the Command Line
Facebook Graph API Get Request - Should Contain "Fields" Parameter (Swift, Facebook Sdk V4.5.1)