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
3
votes
3 answers

iPhone/iPad: Unable to copy folder from NSBundle to NSDocumentDirectory

I am trying to copy a folder in my NSBundle which contains quite a number of images. I tried doing it with these codes. NSFileManager *fileManager = [NSFileManager defaultManager]; NSError *error; NSArray *paths =…
Lloydworth
  • 743
  • 6
  • 20
  • 38
3
votes
0 answers

Has anyone attempted to place compiled code in an NSBundle and load it at runtime?

If so, how did you do it? I've read up on the Mac documentation, but am not experienced at creating bundles in iOS. To be clear, the app is not going on the app store so I'm not concerned about app store guidelines or hidden APIs. I'm aware of…
James
  • 2,346
  • 1
  • 16
  • 18
3
votes
3 answers

Using CFBundleGetVersionNumber

I want to get the version number from info.plist using: NSString *version = (NSString *)CFBundleGetVersionNumber(CFBundleGetMainBundle()); That doesn't give me the string value from Bundle Version that I expect. This does give me the string I…
3
votes
2 answers

Resource-only NSBundle: is this kosher?

In my iOS app, I'm downloading content from the web into my /Library/Caches directory. I'd like to represent this directory as an NSBundle for better compatibility with some of the external APIs we're using. (That way, we can simply change…
Archagon
  • 2,470
  • 2
  • 25
  • 38
3
votes
1 answer

How to create Resource only Bundle for iPhone

We are experimenting with delivering our nibs in language specific bundles. For a couple of different reasons this would help us out. My questions are around setting up a resource only bundle. When I add a new bundle in xcode through the “New…
Matt Eaton
  • 155
  • 2
  • 7
3
votes
2 answers

Why does NSBundle only return the first localization present in a bundle that matches the user's language preferences instead of all matches?

Given the localization directories returned by -[NSBundle localizations] (en, es, it, nl) and the language preferences set by the user as returned by -[NSLocale preferredLanguages] ( en, es, nl, ja, fr, de, it, pt-PT, sv, nb, fi, zh-Hans,…
Huperniketes
  • 940
  • 7
  • 17
3
votes
2 answers

Bundle.main.path does not find text file added in project

I have a command line project in Xcode 9 and I'm trying to read a text file I added to the project via "Add files to...". I'm using the following line to grab the path to the file: guard let filePath = Bundle.main.path(forResource: "stops", ofType:…
pedroremedios
  • 763
  • 1
  • 11
  • 39
3
votes
3 answers

'Could not find a storyboard named 'MainTabController' in bundle NSBundle

the error I'm receiving that I can't seem to fix is Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MainTabController' in bundle NSBundle the app will build and the login…
3
votes
2 answers

NSBundle bundleWithIdentifier returning null for Static framework and resource bundle

I am trying to create a static framework which will use some images to show in its view. I have created a MyFrameworkBundle.bundle from XCode by adding the target in my sdk project. Added all my images in the bundle and created the bundle and gave…
Anas iqbal
  • 1,036
  • 8
  • 23
3
votes
1 answer

Cocoapod bundle not available in my app

I'm creating my own pod with some resources files. It is basically defined like this : Pod::Spec.new do |s| s.name = 'MyName' s.version = '0.0.1' s.license = { :type => 'MIT' } s.homepage = 'not important' s.authors = { …
aimak
  • 540
  • 2
  • 12
3
votes
2 answers

Correct way to get Application directory path in Mac App

From my Mac OS app I was trying to get applications current directory using following code for generating a log file in the app bundle path. NSString *path = [[[NSFileManager defaultManager] currentDirectoryPath]…
tojohere
  • 93
  • 1
  • 8
3
votes
1 answer

Where should I add my own Markdown file in Vapor project?

I want to add my own Markdown file, a file named profile.md. However, I don't know where I should add the file in my Vapor project, which is developed in Xcode. I tried adding it to Sources/ or just the root directory, but it cannot be searched by…
Blaszard
  • 30,954
  • 51
  • 153
  • 233
3
votes
1 answer

Get path to assets file in iOS: NSBundle is missing

I am trying to get the path to a file I have in the Assets.xcassets directory for my iOS app, but I am not able to. It seems like I should use NSBundle.mainBundle() somehow, but Xcode cannot find NSBundle even though I import Foundation or UIKit. If…
Krøllebølle
  • 2,878
  • 6
  • 54
  • 79
3
votes
2 answers

Loading PDF file from Resource directory in iPhone crashes

NSURL *pdfURL = [[NSBundle mainBundle] URLForResource:@"sampleLayout.pdf" withExtension:nil]; This above line warns NSBundle may not respond to -URLForResource:withExtension: and the app crashes while loading the PDF file from this URL path.
The Debugger
  • 330
  • 8
  • 19
3
votes
1 answer

Trying to read InfoPlist.strings file... getting the key (?)

As many people don't know, the way to localize an application name on iOS and OSX is to add an InfoPlist.strings file to the bundle and localize that file. People mix this file with the Info.Plist file. Localization is not done into the Info.plist,…
Duck
  • 34,902
  • 47
  • 248
  • 470