iOS static vs dynamic framework 4 - ios

There are previous threads about iOS static vs dynamic framework. However, I still need to clarification on this one. What my understanding is:
There are static and dynamic framework in iOS.
Static framework is essentially a package of static lib (.a) and other resources like bundle and header files.
Only Apple can create dynamic framework in iOS.
Regular developer outside Apple can only create static framework.
Is my understanding, correct?

No it is not.
3.- Anyone can create dynamic frameworks on iOS.
4.- Any developer can create Static libraries, static frameworks or dynamic frameworks.

Related

Why do we have this confusing setup about Static Library and Framework in Xcode

I have read many articles about static/dynamic library/framework. So my understanding is (let me know if it's inaccurate):
Framework = Library + Bundle
Static = Linking at build time
Dynamic = Linking at run time
In Xcode, we have "Static Library" and "Framework". Which raises a few confusing points:
Why there's no "Dynamic Library" option?
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
Why there's no "Dynamic Library" option?
Because Dynamic Library is not permitted for iOS apps at beginning.
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
Because old Xcode only support Static Library.
Static Framework was added later, and they keep the Static Library.
There are many concepts that must be clear
Libraries have two categories based on how they are linked to the executable file
Static library .a, .so. link at compile time. wiki
Dynamic libraries .dylib .dll etc. link at runtime. only apple can use it for iOS for some safe reason, we cannot build this.
ps, a special kind in apple platform
Text Based .dylib stubs — .tbd
Framework
Framework is a package that can contain resources such as dynamic libraries, strings, headers, images, storyboards etc.
vs Libraries, Framework has more features
Framework also has static and dynamic
iOS 8 later, we can use a dynamic framework, why Apple releases this. maybe Extension and App share code
this Dynamic Framework for iOS is named embedded frameworks, because when we build the app copy the framework in app bundle.
so the embedded framework is different from system dynamic Frameworks like UIKit.Framework
Why there's no "Dynamic Library" option?
the embedded library is allowed with the Framework option, but dynamic framework shared in muti app is also not allowed
Given that we can already link framework statically, why do we still need a "Static Library"? (isn't StaticFramework = StaticLibrary + Bundle? )
well, Xcode not only support Objective-c and Swift, but also support C, C++ which may use the static library

How to use shared Swift static library in other Swift static libraries

I am experimenting using Swift static libraries for an iOS app.
This works if the app links to static libraries, as long as there are no cross-dependencies between the libraries.
Where I am having some issues, is when using static libraries from other static libraries. For example, there is a static library with general purpose code, which is used by higher level libraries and the app:
Utilities (shared library)
Database (depends on Utilities)
Network (depends on Utilities)
App (depends on Database, Network, and Utilities)
In an Objective-C or C code base, it would be possible to set the header include path, and link the shared library in the app. Is there an equivalent procedure in Swift?
This is using Swift 4, and Xcode 9.2.

Third-Party Static Frameworks within a XCode Framework Project

I have created a iOS Framework using the iOS-Universal-Framework:
https://github.com/kstenerud/iOS-Universal-Framework
When I use a static library, let's say libGoogleAnalytics.a I can build my framework let's say MyObjectiveCLib.framework and put everything into the main app. The static libraries will be properly linked into the app.
As soon as I try to add another Third-Party static framework, let's say WindowsAzureMessaging.framework to the framework project, I cannot build the app if I don't link this framework against the app too.
So I'm going to have the WindowsAzureMessaging.framework twice within the iOS app and within the app's core framework MyObjectiveCLib.framework
A solution that I have found is to build every imported framework as a static library (of course we are talking about static libraries in all cases, since it's all about static libs in iOS, hence in this case we are talking about a static framework).
Anyway I cannot do this for every framework when I do not have the source libraries for them.
So since iOS8 release I was able to compile and run the Embedded Frameworks:
Look at my post XCode 6 and Embedded Frameworks only supported in iOS8

How to create a iOS static framework which refers to other static libraries/frameworks?

I am working on a static framework. Now I have to add support for some other third party libraries to it.
Which is the best approach to link a static library to a iOS static framework?
Managed to do this with the below approach, this is without adding the dependancy static libraries into the static framework.
Added the dependancy libraries to the linked binaries section in the Build phase of the Static Framework to build it.
Used id & NSClassFromString to avoid strong reference to the classes used in the dependancy libraries
So when the built static framework is used in a project, the dependancies are added to the project.

split an existing iOS app project into static library and app skin project

I would like to split an existing iOS app project into one static library and one app project.
Since the existing app project has been copies multiple times into brand new instances with different resources(graphics, icons etc) and settings.
I find it's hard to maintain across difference instances once the core project has been updated.
So i'm turning the core project into a static library with model, views and third party libraries.
the other project contains the app part which only contains customised resources and app settings.
the problem is how can the classes in the static library getting the app settings from the app project and the main app project calling classes in the library.
any good practise and tools for that?
The main app project can make use of your static library classes through exported header (.h) files. I would recommend reading a bit about them here:
http://developer.apple.com/library/ios/#technotes/iOSStaticLibraries/Articles/creating.html
And creating the static library here:
http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/
As for providing the app-specific settings to your static library, it sounds like your static library might need to contain a ApplicationSettings protocol or similar, that can be provided to the static library for any calls that require it. Your protocol could define getters/setters for any known properties your application possesses.
#protocol ApplicationSettings
- (BOOL)isUserReallyAwesome;
- (void)setIsUserReallyAwesome:(BOOL)awesome;
#end
Then you can either configure an instance of this object statically, or you can provide to each static library method that requires it:
- (void)someStaticLibraryMethodWithArg:(NSString *)arg settings:(id<ApplicationSettings>)settings { ... }

Resources