-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Working with BrowserKit
BrowserKit is a local Swift package in the firefox-ios repository. It contains multiple libraries that are currently used by the Firefox iOS client app. The package is structured in a way that allows in-line editing of the libraries from within the same Xcode project as the Firefox iOS app code, changes made to the libraries are consumed immediately without needing to deal with releases or semantic versioning.
The main goal of building out this package is to modularize the codebase. The current lack of separation of concerns is a significant issue in the codebase. Although the app is broken out into several targets, many files are shared across multiple targets. Using targets in this way does not enforce good boundaries in the code, which is not an ideal solution. Independent libraries do a better job of enforcing proper separation, as it becomes very difficult to have code that lives in the client target exposed to these libraries.
Any code that is logically tied to the existing libraries should be included in BrowserKit. For example, anything that adds functionality to tab storage should go into the TabDataStore library.
For single classes or lightweight utilities that are intended to be shared across libraries, it often makes the most sense to add them to the Common library. Creating an entire library for such components would introduce unnecessary overhead.
When building out a new feature or refactoring code in the existing codebase, any large block of self-contained code would likely make sense to put in a new library within BrowserKit.
Here are the steps for an example package, SVGKit:
- Open the BrowserKit > Package file
- Add your new package dependency under the
dependencies
array
dependencies: [
...
.package(
url: "https://github.com/SVGKit/SVGKit.git",
exact: "3.0.0"),
],
- Add your new dependency to the appropriate target's dependencies array
targets: [
...
.target(
name: "SiteImageView",
dependencies: ["Fuzi", "Kingfisher", "Common", "SVGKit"],
swiftSettings: [.unsafeFlags(["-enable-testing"])]),
...
]