Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loadable bundle on iOS, is there any way to achieve this?

I am working on a large scale project on iOS, and I want to separate independent modules into several loadable bundles. However, the official document indicates that loadable bundle is not supported on iOS. Also, I plan to use in-house distribution, so app store approval is not an issue.

Now my question is: I call [_bundle principalClass] in the code to access the entry class of the loadable bundle. It works fine on jailbroken iOS devices. For unjailbroken devices, when I use the debug mode with Xcode, it works fine, too. But when I run it independently, from springboard, it crashes to background.

I really wanna know:

1) Why it is so different for loadable bundle running on jailbroken/unjailbroken device?
2) Major differences between XCode debug mode and normal run mode for application?

Are there any other tricky ways for using dynamic library on unjailbroken iOS devices?

like image 679
WinstonZhao Avatar asked Nov 14 '22 06:11

WinstonZhao


1 Answers

Update: as of iOS 8, released in 2014, iOS has proper support for frameworks, so developers are no longer required to use static libraries.

Older answer:

iOS disallows all dynamic loading of executable code that isn't part of the system; this includes Framework, dylibs, executable memory pages using mmap, etc. Hopefully they will someday allow dynamic bundles, but for the time being you will need to build your modules as static libraries and link against them at build time. There is no known way around this limitation.

A lot of people have written about how to do this (e.g., http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/), or you might want to use an existing project as an example. One that I like is the GData objc API, which has targets for both a dynamic framework when built for OS X, and a static library when build for iOS: http://code.google.com/p/gdata-objectivec-client/

like image 183
marcprux Avatar answered Dec 28 '22 17:12

marcprux