ios-debug
is a tool for creating and managing mock implementation. It currently creates a mock implementation for each repository protocol within an iOS project.
...that the app is expected to have:
- there are repository protocols conforming to
...Repository
naming convention - there is a single
rootViewController
assigned (doesn't matter in which file) - there is a
ContainerBuilder.swift
file withregisterRepositoryLayer
function
If you have some version of pip
, either pip install ios-debug
or pip3 install ios-debug
should do the job.
There is a simple console UI that show when ios-debug
is called. Names of the shown options should be pretty self-explanatory :-)
Each command can be also called by passing it as an argument to ios-debug
, e.g. ios-debug start
or ios-debug stop
.
When the debug mode is starting, the following happens:
- Swift files are gathered and read
- Repository protocols are found
- Protocols are parsed and function declarations are extracted
- Repository mock implementation template is processed so there is a mock implementation for each protocol function for each repository. Also,
Container
registration are generated, overriding the origin registration. - Registration functions are added to
registerRepositoryLayer
function inContainerBuilder
. MockManager
andShakeableNavigationController
are generated.MockManager
enables user to choose different mock function implementations at runtime.ShakeableNavigationController
is used asrootViewController
. It responds to shake gesterus by showing theMockManager
.
rootViewController
is reassigned toShakeableNavigationController
.- A Run Script build phase is added in order to sync* mock function variants and protocol functions during build.
When the debug mode is stopping, the following happens:
- Swift files are gathered and read.
- All mock repositories are gathered and saved to a binary file.
- Calls to registration function are removed from
ContainerBuilder
. MockManager
andShakeableNavigationController
are removed andShakeableNavigationController
is unassigned asrootViewController
.- The Run Script build phase is removed from the project.
*Syncing is basically just turning the debog mode off and on again. The whole process is designed to be a function of the code's state, so there are minimal side effect expectation during the processing.