Tutorial :Loading external .bundles on iPhone



Question:

I would like to add resource files to a .bundle and push them to my application and it seems to work fine in the simulator but fails to build when I change to the device.

/Users/sosborn/Projects/MyPro/build/Debug-iphoneos/FooBar.bundle: object file format invalid or unsuitable

I don't want to load any code or anything, just plain text and jpegs and it would be nice to be able to package them as dependencies.


Solution:1

iPhones and iPod touchs do not have support for loading external modules (neither bundles nor dylibs). If you need to share object code between projects, you can use static libraries


Solution:2

Instead of trying to load it like an NSBundle, just reference the resources therein by path.

You could pretty easily create your own class that did something similar to the non-code stuff in NSBundle to help out, as there really isn't much logic in there.


Solution:3

I found a better solution to my problem. It actually doesn't require the use of bundles at all. I just created an aggregate target instead of a bundle target. Then I added a copy step and a script step. The copy step contains all of the resources I had in the bundle target and the script step actually zips up the files. Then when I download the content into my application I can just unzip it and use it just as if it were a bundle since I'm just storing resource dependencies.

Thanks for your help.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »