iOS self made framework can contain other third party framework ? - ios

all:
My company now uses sereval third-party framework,now we want to make ourselves sdk ,the sdk hide all the details of the third party framework ,can this be implemented? How I can get some information of this ?

Generally, you have two ways to make SDK with third part framework.
Rename the classes name in third part framework with prefix string. For example, ASIHttp, change to MySDK_ASIHTTP. This can prevent compile error when uses include the same third part framework in their project.
Don't include third part framework, just write a document which tells use to add required third part framework by themselves. This make use just have only a copy of third part framework in their project.
If you have modified the third part frameworks, I think you should use 1 method

Related

How Objective-C Runtime detect framework is exist

I'm making a framework that use several third party framework, and those third party framework were install by developer who use my framework using cocoapods, I got some problem and I can not find any solution.
I was try __has_include to detect framework is exist, that just work at compiler time not work at runtime.
The problem like below:
How detect framework exist at runtime.
I need import framework if the framework exist.
I need to implement the third party protocol if the framework exist.

Xcode links a Third Party framework in my Framework and includes it's symbols

I am building a Framework and the code there uses a Third party framework. When I compile my Framework it seems to contain all the symbols from the Third party framework. If I don't add the third party framework to Linked Frameworks and Libraries I get compiler errors about undefined symbols.
On the other hand, when I add the third party framework to Linked Frameworks and Libraries it compiles fine. However, in a sample app when I link both my framework and the third party one I get the following runtime warnings: Class is implemented in both, One of the two will be used. Which one is undefined.
My question is how do I build my framework with a dependency on another framework without actually linking it? I want to do all the linking on the app level.
I wasn’t able to achieve this behavior building dynamic frameworks. However, as I built my framework as static, the framework compiled fine and did not include third party framework symbols. All the linking with the third party framework has to be done on the app level.
I have seen many questions on stack overflow like this with no definite answer. I hope my finding would help.

Do I have to include third party frameworks separately with my app?

I am building an iOS cocoa touch static library. It depends on a third party framework. Would I have to ship the framework with my app or not?
I am guessing that the definition of static library means that the output .a file should already have the necessary parts of the included framework and therefore I should not have to supply the framework separately. Is that true ?
When you "Ship" your app, xcode creates an .ipa file where everything is bundled together so you dont have to do anything extra....
Although from what I understand your actual question is when you include a third party static library in your app and that static library uses other frameworks, Do you need to include those libraries in your app or not?
If that is the question then answer is yes, let's say your .a static library depends on AFNetworking framework(a popular third party framework) or/and needs CoreLocation.framework by apple, then in your apps settings
Build Phases -> Link Library With Libraries you need to import those frameworks that your static library uses, then when you build and "ship" your app to the appstore, xcode takes care of it(bundles) it. So you dont have to worry.
ALTERNATIVE SOLUTION:
It is also possible that you can just add source code of third party frameworks and when you build your .a framework everything is bundled. If you do that you need to make sure class names and method names are unique though.
Are you making something like a cocoapod? Because then, you can specify it as a proper dependency in the podspec. Otherwise, you can include instructions on including the third party framework or bundle it in yourself.

Can I make iOS all-in-one framework? or include private static library into my framework?

I'm a novice on XCode and I'm making an iOS Framework with Swift2, including 3rd party libraries(*.a) and frameworks.
I want to provide it as API to others, but I also want to hide the 3rd party libs and frameworks files from my framework distribution files because they are private.
Therefore I just want to open API interfaces and classes I defined.
Is it possible? How to configure my build options?
You can do that but there are some things you need to consider:
You cannot embed one framework into another one. That means if you do not have the sources to a particular framework you have to ship it alongside your own framework. If you have the sources you may consider compiling them into your framework directly.
Depending on the sources that you use in the framework you might have to do some post processing of the framework to obfuscate private headers etc. For example, if you use Objective-C or C code alongside Swift you definitely need to do some post processing of your *.framework file to hide any API that you want to keep private.
If you use Swift code in your framework please be aware that your framework can only be used by someone with the same Swift compiler version due to the absence of an ABI. That means binaries produced by one compiler version have a high likelihood of being incompatible to a newer version of the compiler.
Static linked libraries can be linked and therefore "merged" into your framework binary directly. You just need to make sure that you have a compatible binary for the architecture you want to target, e.g., you cannot use a static linked library that was build for simulator and link it against your framework that you want to build for the actual iOS device.
If you use Swift in your framework, the users of your framework need to include the Swift dylib libraries in their app bundle - either by using Swift in the app or by enabling the Embedded Content Contains Swift Code build setting.

How can be 'Class is implemented in both' issue be solved inside of an iOS framework?

I am building an iOS framework which embeds a 3rd party static library. If the developer implementing the framework wants to also include the 3rd party static library which has been used, multiple 'Class is implemented in both' warnings will be displayed at runtime. How can I solve those warnings providing I can't rename the classes since the library is compiled?
Thank you in advance.
If you are distributing manually, you have to tell everything(which 3rd party library to add in Link Binary with Libraries, Other Linker Flags & probably few more) to your client.
Eg: Install Manually section for GoogleMaps
If you have a Podspec(which probably means the 3rd party Library also does), then you can simply add dependency to it like this
BTW static library can't be embedded in an iOS Framework, you can only link it.

Resources