Questions tagged [nsbundle]

An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins.

An NSBundle object represents a location in the file system that groups code and resources that can be used in a program. NSBundle objects locate program resources, dynamically load and unload executable code, and assist in localization. You build a bundle in Xcode using one of these project types: Application, Framework, plug-ins.

568 questions
16
votes
4 answers

UIImage imageNamed requires pathForResource?

How necessary is it to search for a path to an image using the NSBundle method pathForResource when creating a UIImage using imageNamed? I see tutorial codes that just specifies the name of the image directly, and then code that goes the extra mile…
johnbakers
  • 24,158
  • 24
  • 130
  • 258
15
votes
1 answer

How do NSBundle pathForResource:ofType: and UIImage imageWithContentsOfFile: handle scale and device modifiers?

In my iOS resource folder, I have the images: foo~iphone.png foo@2x~iphone.png foo~ipad.png foo@2x~ipad.png I load them with: NSString *fileName = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"png"]; UIImage *image = [UIImage…
Jesse Beder
  • 33,081
  • 21
  • 109
  • 146
14
votes
4 answers

How to get path to a subfolder in main bundle?

I have a project which I am migrating from Obj-C to Swift 3.0 (and I am quite a noob in Swift). How do I translate this line? NSString *folder = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"myfolder"]; I managed to get…
Nick
  • 3,205
  • 9
  • 57
  • 108
14
votes
6 answers

XCTest Error: The bundle couldn’t be loaded. Try reinstalling the bundle

After I run ProjectNameTests.m (empty test file) by doint Product -> Test the project builds successfully, but it throws and gives me the following error: 2016-01-10 11:25:32.677 xctest[66104:5611958] The bundle “ProjectNameTests” couldn’t be…
Fengson
  • 4,751
  • 8
  • 37
  • 62
14
votes
7 answers

XCode deployment error: 'NSInvalidArgumentException', Could not find a storyboard named 'MainStoryboard'

Like many of the prior 'MainStoryboard missing in NSBundle' questions, I've got the same prompt but have found no issue with naming and no issue with if the storyboard exists within an area XCode likes. All the pointers lead to the same file, I've…
Harrison Harbers
  • 155
  • 1
  • 1
  • 7
13
votes
3 answers

How to get All paths for files in Documents directory?

I usually get paths by using NSBundle. But, NSBundle does not contain Documents folder. How to get All paths(or names) for files in Documents directory?
ChangUZ
  • 5,380
  • 10
  • 46
  • 64
13
votes
3 answers

access to plist in app bundle returns null

I'm using a piece of code I've used before with success to load a plist into an array: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"species_names" ofType:@"plist"]; NSArray *array = [[NSArray alloc]…
RonC
  • 855
  • 1
  • 8
  • 16
13
votes
5 answers

Swift - read plist file to an array?

I have created a mini translation from English words to Spanish words. I would like to use the englishArray.plist instead of my englishArray = ["the cat"] How can I create this? I have also used a localizable.strings to retrieve the value "the…
Miguel
  • 213
  • 1
  • 3
  • 12
12
votes
2 answers

NSBundle pathForResource returns nil with subdirs

I have a bunch of directories and files in my app, for instance images/misc/mainmenu_background.. I'm running the following code in the "iPad Simulator 3.2": NSString *images = [[NSBundle mainBundle] pathForResource:@"images" ofType:nil]; NSString…
Martin Wickman
  • 19,662
  • 12
  • 82
  • 106
12
votes
2 answers

How to check if a Storyboard exists in a specific NSBundle

I'm making an app that makes use of a framework that I'm creating. The framework contains storyboards but in some cases the project making use of the framework will need to override the storyboard by providing a new one. So my goal is to check if a…
Swinny89
  • 7,273
  • 3
  • 32
  • 52
12
votes
3 answers

Get Bundle reference from Path in Swift

I want to get NSBundle reference from Path in swift. Like in Objective-c > NSBundle* languageBundle = [NSBundle bundleWithPath:path]; How we can achieve same in swift .
Alok
  • 24,880
  • 6
  • 40
  • 67
12
votes
2 answers

When a UIImageView's image is set from Interface Builder, how is that image loaded?

When an image view's source is pre-set from the attributes inspector, when/how is the actual path to the file resolved? There don't seem to be any calls to NSBundle, but I may be wrong. EDIT: I'm trying to swizzle whatever method is called (if…
kasrak
  • 470
  • 4
  • 12
11
votes
2 answers

NSBundle pathForResource returns nil

I've been trying to load a simple text file in a unit test for an iOS app. NSString* resourcePath = [[NSBundle mainBundle] pathForResource: @"stopPointsInCircleData" ofType:@"txt"]; NSString* stopPointData = [NSData dataWithContentsOfFile:…
Chris
  • 3,192
  • 4
  • 30
  • 43
11
votes
4 answers

Impossible to load an image in xcassets on bundle

I need to include images in a static library. I created a bundle and inserted in my images, the problem is that it seems to work if I include the images directly in the bundle, but stops working if I put in a xcassets file. I followed many guides…
Serluca
  • 2,102
  • 2
  • 19
  • 31
10
votes
2 answers

How can I find the path to a file in an application bundle (NSBundle) using C?

Is there a C API for finding the path to a file in an application bundle? I know that this can be done in Objective-C with the following syntax. NSString *path = [[NSBundle mainBundle] pathForResource:@"MyImage" ofType:@"bmp"]; Is there a…
Chris Frederick
  • 5,482
  • 3
  • 36
  • 44
1 2
3
37 38