Divide a large fast project into structures with basic structures and modules

I am trying to split my large Swift structure into many modules, so each module in my application will be independent to reuse in other applications. Due to the fact that I have big data, such as classes and libraries, which are shared with all the modules that I thought created core_framework, they contain common data and force the application to use this structure to use all other frameworks (one or more)

enter image description here

I saw an example of FBSDK, there is a basic structure and other functional frameworks: FBSDKCoreKit and FBSDKLoginKit

It is important for me that all other structures will not contain the main structure for reasons of efficiency.

My question is: after creating the main structure, what should I do in my node structure so that it recognizes the main classes and functionality, but it compiles with the main files?

thanks

+6
source share
1 answer

When you divide a project into submodules, what you need to do is pretty simple, although some details depend on how you split your project.

The simplest case: 1 project with N goals

Say that you only work with this one application and divide it into modules. The easiest way is to add additional Framework targets to the project.

Add infrastructure for the project

Then you need to implement them in your target program. Make sure that it is part of both the “embedded binaries” and the “related structures and libraries”.

You now have a new frame module.

  • Create a pair of them (for example, "Core" and "Module 1"). Then:
  • In the "General Settings of Project 1 Module 1" add "Kernel" to "Related Structures and Libraries". There is no built-in option for frameworks, since they cannot include libraries, but only a dependency on them.
  • In the target application program, paste and add the link "Module 1".

This is all you need to configure.

I tried to adjust the insert and link options, so you see that only the target application program contains other frameworks:

Target Link Dependencies and Binary Containment

A bit more complicated: several projects

The basic installation from above applies to all other options: frameworks (modules) may depend on other frameworks, but they cannot be delivered with them. Only an application can finally resolve a binary dependency.

If you divide the project into several subprojects, for example. retrieving open source deployable libraries for other people, then you should make “Module 1” aware of the “Core” in each project by binding to the “Core” module in the same way as described above. What makes isolated Xcode projects somewhat more complex: how does the Module 1 project know about Core.framework ?

  • You can expose each module through Carthage and depend on one of the other,
  • you can use CocoaPods,
  • you can check the dependencies via git submodule .

The above parameters support the autonomy of each module. Dependencies are part of the module directory tree.

A little less streamlined:

  • You can create an Xcode workspace, drag and drop all projects inside, and then drag Core.framework from the Products group of one project to the Linked Libraries list on another or
  • drag and drop the Core.framework file from the Finder into the "Module 1" project (if necessary, select "Copy files if necessary" to put the resulting binary into the "Module 1" directory tree).

The above options may also work, but they make assumptions about the location of files in the file system. A workspace approach should help reduce problems with legacy structure binaries, though, since a workspace can help create a formalization of build dependencies from cross-project dependencies. Just as the target application program depends on its infrastructure objectives and, like test objects, depends on the purpose of the application, which must be compiled first.

0
source

All Articles