Managing dependencies in static libraries with cocoapods

I use CocoaPods in an application where the workspace consists of the main application project and some static libraries as subprojects, each of which has its own dependencies. Static libraries are tied to the main project at compile time and exist primarily as a means of encapsulation and code organization.

A problem arises when CocoaPods bundles dependencies in static subproject libraries. If two or more of these static libraries have the same dependencies, they cannot be linked in the main project, as this leads to duplication of characters.

The workaround that I have at the moment is to create a "dummy" target in each of the subprojects and set it as the target link in the swap file. The real goal is using the xcconfig file generated by CocoaPods, without dependency binding.

Although this really works, and id is the easiest solution I could find, it still carries an extra unnecessary burden on having a dummy target in each project, for example:

xcodeproj 'MyApp/MyApp.xcodeproj' target :'MyApp' do xcodeproj 'MyApp/MyApp.xcodeproj' pod 'MBProgressHUD', '0.9' link_with 'PodDummy' end 

Another disadvantage of this approach is that all dependencies should still be specified in the main project, so that they are associated with the final executable.


So my question is: how can I use CocoaPods in a static library project without binding dependencies in binary?

Or even better: can I specify the dependencies only in the subprojects of the static library, and CocoaPods find out what needs to be linked in the main project, allowing duplicates in the process?

I mean only the main project in the pod file, and subprojects manually refer to the "Pods" directory for the headers.

There has apparently been some discussion of this issue in the past, but I do not understand what came of it. Related discussions:

+6
source share
1 answer

CocoaPods works well for people using containers. It is much harder to use when you develop pods or, even worse, when developing an application along with (a) the libra (y), which are all pods ... (which can depend on pods as well).

What you should know is that CocoaPods is here to resolve dependencies. Your problem seems to me that you completely bypass this function, having your pods in dev already in your workspace! Of course, if you perform the “pod installation” inside your project directory, you will simply get a mess of dependencies, meanwhile, the Pod will install according to the subfile, and your own codebases right in the same folder tree.

What I am doing is to separate the pods (which may or may not depend on other pods) separately. In addition, it’s good practice not to be in the same “workspace” of the application. And you can develop your module with a demo application.

And in the directory of the main application, I indicate "develop" the branch of my own containers in the subfile. Consequently, the application is being developed with depdencies on pods, as if these pods were published officially. Besides being simple in dev as well.

This makes you, of course, have things separate, which is not so nice when you need to change someting in the pod code for your application.

Two possibilities (none of them are very pleasant). First, change your module, and then do the "pod update" update inside your application folder.

Secondly, play with the module code directly in the application workspace (the module code was imported by the module update command). And once satisfied, the return port will change the source code of the module for fixing.

Much back and forth, but I havent found better than that.

0
source

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


All Articles