What is the correct process for linking static libraries to shared static libraries?

I am working on a static library called Silicon , which I use for all my iOS applications.

Since I do not want to create one massive static library, which can become difficult to maintain, I create many small static libraries that I attach as submodules.

At the time of this writing, the dependency tree for Silicon is as follows:

Silicon
|
| ==> FDKeychain
| ==> FDDataClient
|
| => FDRequestClient
|
FDFoundationKit
| ==> FDSQLiteDatabase
|
| => FDFoundationKit

As you can see, both FDRequestClient and FDSQLiteDatabase have FDFoundationKit as a regular static library.

It seems that when a project using Silicon is built, it builds all Silicon-dependent dependencies in the project creation directory. The same thing happens for FDDataClient and FDSQLiteDatabase. Therefore, at some point, the FDFoundationKit from FDRequestClient is created and copied to the assembly directory, as well as the FDFoundationKit from FDSQLiteDatabase. Whatever the last one is built, it simply overwrites the previous one.

Just because of the successful work, FDFoundationKit has not changed in any serious ways, so FDRequestClient and FDSQLiteDatabase can not always use the same version, but I can not guarantee that this will be so forever.

I'm trying to find out if there is a way that Silicon can tell which version of FDFoundationKit to use to be responsible for Silicon, to ensure that the version used will work for both FDRequestClient, FDSQLiteDatabase, and any other dependencies that I add in the future .

I know that CocoaPods is trying to solve this problem, but I do not want anyone to have to configure all this just to make my library work. If I could just find how Silicon determines which version of FDFoundationKit will use everything, it will work fine.

+6
source share
2 answers

There should only be two answers to this problem:

1) Use a dependency manager like CocoaPods or Carthage.

2) Any static libraries or frameworks that you release should not have any target dependencies. They should be associated with any dependencies that you have, and the responsibility for integrating your library for integrating the required dependencies rests with it.

0
source

You could (as we do) host all of your libraries within, within the framework of version support. Frames are just a directory tree configured in the usual way. Xcode does not directly support the creation of frameworks, so you need to create them in a script, usually as the last of the build phases. An example (thanks to jverkoey ) can be found in the IOS-framework

Within the framework, you can store all versions of each static library in

 myLibrary.framework->Versions->nn folders. 

myLibary.framework->Versions->Current is a link to the folder of the latest version.

Since you use static libraries, Silicon itself cannot specify versions (which require dynamic libraries), however, the assembly, linker, or environment flags used to build Silicon can certainly.

Thus, by default, applications will always use the latest version of the library, but the actual linked version can easily be overridden by the linker flags when created. In addition, all users will simply include the Silicon project in their project just like any other infrastructure, so it is very simple for developers.

0
source

Source: https://habr.com/ru/post/969646/


All Articles