Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my bundle ignoring its info.plist?
    primarykey
    data
    text
    <p>I am attempting to bundle a set of resources into a bundle, and them access them from code via NSBundle.</p> <p>So far, I can access the resources from the bundle fine, but I cannot get the NSBundle instance to get any meta-data from the bundle's Info.plist file. </p> <p>Strangely, my first attempt worked, and correctly got the meta-data, but since then I have been unable to replicate this behaviour and the bundle always returns null for the bundleIdentifier or other items in the infoDictionary.</p> <p>I have reduced the code to the following test case:</p> <pre><code>NSString *pathToTestBundle = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"testBundle"]; NSLog(@"path to Test Bundle: %@", pathToTestBundle); NSBundle *testBundle = [NSBundle bundleWithPath: pathToTestBundle]; NSLog(@"testBundle: %@", testBundle); NSString *identifier = [testBundle bundleIdentifier]; NSLog(@"testBundle identifier: %@", identifier); NSURL *testResourceURL = [testBundle URLForResource:@"vanGroup" withExtension:@"png"]; NSLog(@"testBundle test resource: %@", testResourceURL); NSImage *testImage = [[NSImage alloc] initByReferencingURL:testResourceURL]; [imageView setImage:testImage]; NSLog(@"%@", [testBundle infoDictionary]); </code></pre> <p>Which gives this: (edited for line length)</p> <pre><code>path to Test Bundle: /.../BundleTester.app/Contents/Resources/test.testBundle testBundle: NSBundle &lt;/../BundleTester.app/Contents/Resources/test.testBundle&gt; (not yet loaded) testBundle identifier: (null) testBundle test resource: file://.../BundleTester.app/Contents/Resources/test.testBundle/Resources/vanGroup.png BundleTester[45083:707] { NSBundleInitialPath = "/Users/diggory/Library/Developer/Xcode/DerivedData/BundleTester-hcbsnhudsdfzlyggjbvlkdbrtxrw/Build/Products/Debug/BundleTester.app/Contents/Resources/test.testBundle"; NSBundleResolvedPath = "/Users/diggory/Library/Developer/Xcode/DerivedData/BundleTester-hcbsnhudsdfzlyggjbvlkdbrtxrw/Build/Products/Debug/BundleTester.app/Contents/Resources/test.testBundle"; } </code></pre> <p>In my Xcode project by test bundle is added as a folder reference and has the following structure:</p> <pre><code>test.testBundle Info.plist Resources vanGroup.png </code></pre> <p>The image resource is loaded correctly, but the values in the plist are ignored.</p> <p>The plist is as follows:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt; &lt;plist version="1.0"&gt; &lt;dict&gt; &lt;key&gt;CFBundleIdentifier&lt;/key&gt; &lt;string&gt;com.monkeyfood.testbundle&lt;/string&gt; &lt;key&gt;badger&lt;/key&gt; &lt;string&gt;Bodger&lt;/string&gt; &lt;/dict&gt; &lt;/plist&gt; </code></pre> <p>Am I missing something? What am I doing wrong?<br> Many thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload