iOS: staic framework and dynamic framework? - objective-c

Recently, I decide to make a framework for login module. I add the image resources to the framework, but I could not get it by code. I change the build the setting. mach-o type static library into dynamic library. I can get the image.
It is easier to make a moudle with dynamic framework than static framework.
but I google and find the dynamic framework made by developer is different with the Apple's dynamic framework. the app contain custom dynamic framework can not upload to Appstore ? Is it true?
who can answer my question? Thank you so much!!!

Dynamic frameworks are extremely common in AppStore apps. What you're probably seeing in posts is that you cannot manually load frameworks at runtime on iOS (i.e. there's no access to dlopen). They all have to be loaded at link time. You also cannot ship "shared" frameworks, where multiple apps share a single copy (like Apple's system frameworks). Each app must contain all of its custom frameworks.
But you can certainly ship dynamic frameworks in your bundle.

Related

Using static library in both App and Cocoa Touch Framework targets

I've created a new "Cocoa Touch Framework" target called MyAppCore in my iPad project called MyApp, with the intention of putting some common code in there. Overall it works great, however, I've encountered problems with adding the static library provided by Google Analytics.
I want to be able to use Google Analytics not only in the MyApp target, but inside of the MyAppCore target as well. In order to make both targets build, I have to link both targets with libGoogleAnalyticsServices.a. That appears to work, but when I run the app, the log is bombarded with messages like these:
Class GAI is implemented in both /path/to/MyAppCore.framework/MyAppCore
and /path/to/MyApp.app/MyApp.
One of the two will be used. Which one is undefined.
How can I share Google Analytics between the two targets in a successful way?
I managed to solve this issue by creating a wrapper class for Google Analytics (which is pretty handy to have, anyways) in the MyAppCore target. All access to Google Analytics will go through this wrapper. That way the only target that will use Google Analytics directly is MyAppCore, so I only have to link that target with Google Analytics.
This does not solve the underlying issue of sharing static libraries between my app target and a Cocoa Touch Framework, but for this purpose it works just as well.
Even if your static library depends on the external static library, don't link against it. Your main app will link against BOTH your library and the 3rd party library. A static library is a bunch of built code so you have two copies of everything doing things the way you are doing now.
You should still be able to reference the headers for the 3rd party library and things should compile on your static library without any warnings.
In my application I have two static libraries. "Wraith" is dependent on "PhilosophersStone" and the app is dependent on both. (Target Dependencies in Build Phases)
"Wraith" does not link against "PhilosophersStone", main app links against both. (Link Binary With Libraries in Build Phases)

how to make static library link against frameworks needed automatically in xcode

I have a static library base on MapKit.framework CoreLocation.framework etc.
I want to distribute the static library to other developers, to make it easy, I hope to find a method to eliminate the process of linking against frameworks in developers project.
I know there are some people achieve this.
If you can read chinese, you can refer to
http://dev.umeng.com/releasenote/releasenote_ana_ios.html
简化SDK集成,一句代码集成友盟SDK([MobClick startWithAppkey:]),不再需要手动link framework
There is no way to do this as of Xcode 4.5.2. A static library cannot specify its dynamic library dependencies. Only a dynamic library can do that.

Build static library in monotouch

Is it possible to build a static library using MonoTouch that can be used by Xcode developers? What about the headers?
I come from a C# background and I have a large library to port over to iOS.
It'd save me oodles of time if I could keep it in C# and adjust as needed.
AFAIK it is not possible. See here:
MonoTouch: talking from Obj-C to MonoTouch
Which links to a project that tries to do what you want:
http://www.guidebee.biz/forum/redirect.php?fid=16&tid=176&goto=nextoldset

Understanding bundles frameworks and libraries

I'm developing ios B2B app and I have several questions regarding app modularization.
Firstly i need to understand main difference between bundles and frameworks. When to use bundles and when frameworks.
Another question is. Is it possible for bundle to contain a .framework inside in it and vice versa.
Is it possible to create a plugins for ios app and load them dynamically, if yes then what it should be? bundle framework or library?
Is it possible for library to contain a resource files ?
Is it possible to create a resource bundle and dynamic library and then load them dynamically at runtime.
Is it possible to create a plugins for ios app and load them
dynamically, if yes then what it should be? bundle framework or
library?
No
Is it possible for library to contain a resource files ?
No
Is it possible to create a resource bundle and dynamic library and
then load them dynamically at runtime.
No
A Bundle is a type of Directory, a folder. A Framework is a bundle. So is an Application and so is a Plugin.
A Static Library is a single file code archive you can compile into your app at build time
A Dynamic Library is a single file code archive you can load at Runtime
A Framework is a Dynamic library in a Bundle with other things
A Plugin is a Dynamic library in a Bundle with other things
The Xcode build option 'Bundle' means 'Place the compiled Dynamic Library in a Bundle' - this is what you do when you want to create a Plugin.
Static libraries are the only option for modularising your code on iOS.
On the desktop..
Typically a Framework is for sharing code and resources between multiple apps. You want your app to behave as though the code was actually compiled into it. You want loading to happen transparently and you don't want to do anything special to use the methods, functions, etc. contained in it.
A Plugin (a Bundle containing compiled code and resources) is for optional, dynamically loaded code, e.g. a software extension that you can choose to load or not. You want to carefully architect your app so that it isn't dependent on the Plugin but acquires new behaviour if you manually locate and load it at Runtime.
A Framework and a Plugin are very similar, but a Framework has a strict file layout to facilitate locating and loading code and resources. With a plugin, these jobs are your responsibility so you can structure the Bundle contents however you want.
Because loading code is so easy in Cocoa on OSX (but not iOS) Frameworks can contain Plugins which contain Frameworks which contain more Frameworks, etc.
On iOS some people put Static Libraries in Bundles with resources and call them Frameworks. This has none of the benefits and all of the drawbacks of a real framework.

Plug-in architecture, access to code in application?

For a project I am doing, I want the Mac application to accept plug-ins. I like the whole idea of just adding Bundles to the application to extend it's functionality.
Only I came across a small question, where I can't find the answer to:
I need to include a JSON parser in my application, for some functionality. Is it possible for a plug-in Bundle to also use that same parser? Or does every plug-in that uses a JSON parser, need to include the parser themselves?
What is the best way to do this for separate Bundles?
On OS X there are two types of loadable things, a dylib and a plugin. (These two terms have specialized technical meaning in the context of mach-o, the binary format OS X uses.)
A loaded dylib can't refer to the libraries in the executable, while a loaded plugin can. As a side effect, a dylib can be loaded to any executable, but a plugin can only be loaded into the executable you specify when you make the plugin.
So you want to make a plugin. There is a template in the XCode to do that. Don't forget to specify the target executable in the linker flag, which can be set somewhere in the inspector.
For more, read Code Loading Programming Topics.