DIKit is a dependency injection library for iOS/iPadOS/macOS apps offering a simple interface using the service locator pattern.
# Prepare Ruby environment
$ brew install rbenv ruby-build
$ rbenv install
$ rbenv rehash
$ gem install bundler
# Install fastlane
$ bundle install
From Xcode, go to File > Swift Packages > Add Package Dependency..., then enter the Git repo url for DIKit: https://github.com/andrewscwei/swift-dikit.
Adding DIKit as a local Swift package allows you to modify its source code as you develop your app, having changes take effect immediately during development without the need to commit changes to Git. You are responsible for documenting any API changes you have made to ensure other projects dependent on DIKit can migrate easily.
- Add DIKit as a submodule to your Xcode project repo (it is recommended to add it to a directory called
Submodules
in the project root):$ git submodule add https://github.com/andrewscwei/swift-dikit Submodules/DIKit
- In the Xcode project, drag DIKit (the directory containing its
Package.swift
file) to the project navigator (the left panel). If you've previously created aSubmodules
directory to store DIKit (and possibly other submodules your project may depend on), drag DIKit to theSubmodules
group in the navigator.Once dragged, the icon of the DIKit directory should turn into one resembling a package. If you are unable to expand the DIKit directory from the navigator, it is possible you have DIKit open as a project on Xcode in a separate window. In any case, restarting Xcode should resolve the problem.
- Add DIKit as a library to your app target:
- From project settings, select your target, then go to Build Phases > Link Binary With Libraries. Click on the
+
button and add the DIKit library.
- From project settings, select your target, then go to Build Phases > Link Binary With Libraries. Click on the
In Package.swift
, add the following to dependencies
(for all available versions, see releases):
dependencies: [
.package(name: "DIKit", url: "git@github.com:andrewscwei/swift-dikit", from: "<version>")
]
Ensure that you have installed all destinations listed in the
Fastfile
. For example, a destination such asplatform=iOS Simulator,name=iPhone 15 Pro
will require that you have installed the iPhone 15 Pro simulator in Xcode. In the CI environment, all common simulators are already preinstalled.
$ bundle exec fastlane test