Cache usage
To help you understand the various approaches implemented in Geko Cache, we'll walk through all the available commands using examples.
App
├── A ── B ── C (external)
└── D ── E ── F
ATests ── A
Z - orphanUsing only cache flag
geko generate --cacheIn this case, we don't focus on any specific targets. Geko will build all possible targets, and non-cacheable targets will remain available. All orphan targets will be pruned. We'll get the following graph:
App
ATestsUsing focus on targets
For example, we want to work only with target A, but we also want to build and test our app. In this case, we should specify both modules A and App in the command. If we don't specify App, Geko will focus only on target A and exclude all other targets, including App. You'll be able to build target A, but you won't be able to build App on the simulator.
geko generate App A --cacheApp
└── AFocus supports the use of regular expressions.
geko generate 'A.*' --cacheApp
└── A
ATests ── ATo simplify the focus, you can use the -s, --scheme <scheme> flag, in which case Geko will focus only on the targets specified in the scheme.
Using focus tests
The --focus-tests command will save all Unit/UI targets and their AppHost targets that are found in the projects specified in focus.
geko generate App A --cache --focus-testsApp
└── A
ATests ── AUsing dependencies-only flag
When passing the --dependencies-only flag, Geko will cache only external dependencies of your project, and all local targets will remain sources.
geko generate App A --cache --dependencies-onlyApp
├── A ── B
└── D ── E ── F
ATests ── ABuild for a simulator or a real device
-d, --destination <destination> – allows you to specify the build destination. Two options are available: simulator and device. simulator is used by default.
Unsafe cache
To understand this, we need to define safe and unsafe caches. Let's look at an example:
App +----> A (Framework) +----> B (Framework) +----> C (Framework)Safe cache
geko generate App B --cacheIn the safe approach, you can generate a project and focus on target B, then Geko will precompile and remove target C, and leave targets A and B as sources that you can modify.
Unsafe cache
geko generate App B --cache --unsafeIf you specify the --unsafe flag, Geko will precompile and remove targets A and C, leaving target B as source. This option will allow you to compile your project without issues in most cases, as long as you don't change the public interface of target B, which is used by target A. Changing the public interface used by targets A may cause problems at link time or runtime.
In most cases, this is still a safe approach; you have nothing to lose, only gain. In a very large project, you may encounter situations where many targets depend on the target you need.
Cache with focus direct dependencies
In large projects, listing all the required targets can be tedious. To simplify the caching approach, Geko has an additional flag – --focus-direct-dependencies. If passed, all direct dependencies of targets in focus will not be cached.
geko generate App A --cache --focus-direct-dependenciesApp
└── A ── BTIP
We recommend using the --focus-direct-dependencies flag in combination with the --unsafe flag, this way you can avoid too many targets being left as sources, which will affect the build time of your project.
