Skip to content

Commit 3765420

Browse files
author
Tarik Eshaq
authored
Updates README (#59)
1 parent 050c901 commit 3765420

File tree

1 file changed

+10
-49
lines changed

1 file changed

+10
-49
lines changed

README.md

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ For more information, please consult:
1212
which describes the overall plan for distributing Rust-based components as Swift packages.
1313
* The [Swift Package Manager docs](https://swift.org/package-manager/) and [GitHub repo](https://github.com/apple/swift-package-manager),
1414
which explain the details of how Swift Packages work (and hence why this repo is set up the way it is).
15-
* The [`ios-rust` crate](https://github.com/mozilla/application-services/tree/main/megazords/ios) which is currently
16-
responsible for publishing the pre-built `MozillaRustComponents.xcframework.zip` bundle on which this
17-
repository depends.
15+
* The [`ios-rust` crate](https://github.com/mozilla/application-services/tree/main/megazords/ios-rust) which is currently
16+
responsible for publishing the pre-built `MozillaRustComponents.xcframework.zip` and `FocusRustComponents.xcframework.zip` bundles on which this repository depends.
1817

1918
## Overview
2019

@@ -30,12 +29,12 @@ and its release artifacts:
3029

3130
Key points:
3231

33-
* The `application-services` repo publishes a binary artifact `MozillaRustComponents.xcframework.zip` containing
32+
* The `application-services` repo publishes two binary artifacts `MozillaRustComponents.xcframework.zip` and `FocusRustComponents.xcframework.zip` containing
3433
the Rust code and FFI definitions for all components, compiled together into a single library.
35-
* The `Package.swift` file references `MozillaRustComponents.xcframework.zip` as a Swift binary target.
36-
* The `Package.swift` file defines an individual module for the Swift wrapper code of each component.
37-
* Each module references its Swift source code directly as files in the repo.
38-
* Each module depends on `MozillaRustComponentsWrapper` which wraps `MozillaRustComponents` to provide the pre-compiled Rust code.
34+
* The `Package.swift` file refrences the xcframeworks as Swift binary targets.
35+
* The `Package.swift` file defines a library per target (one for all the components used by `firefox-ios` and one for `focus-ios`)
36+
* Each library references its Swift source code directly as files in the repo. All components used by a target are copied into the same directory. For example, all the `firefox-ios` files are in the `swift-source/all` directory.
37+
* Each library depends on wrapper which wraps the binary to provide the pre-compiled Rust code. For example, [`FocusRustComponentWrapper`](./FocusRustComponentsWrapper/) wraps the Focus xcframework.
3938

4039
## Cutting a new release
4140

@@ -48,46 +47,8 @@ in this repo to make them available to Swift components. To do so:
4847

4948
## Adding a new component
5049

51-
To add a new component to be distributed via this repo, you'll need to:
50+
Check out the instructions in the [docs in `application-services` for adding a new component and publishing it for iOS](https://github.com/mozilla/application-services/blob/main/docs/howtos/adding-a-new-component.md#distribute-your-component-with-rust-components-swift). The docs are also published for convenience in <https://mozilla.github.io/application-services/book/index.html>.
5251

53-
* Add its Rust code and `.h` files to the build for the `MozillaRustComponents.xcframework.zip` bundle,
54-
following the docs for the [`ios-rust` crate](https://github.com/mozilla/application-services/tree/main/megazords/ios).
55-
* If the component needs to dynamically generate any Swift code (e.g. for UniFFI bindings, or Glean metrics),
56-
add logic for doing so to the `./generate.sh` script in this repository.
57-
* Swift packages can't dynamically generate code at build time, so we use the `./generate.sh` script
58-
to do it ahead-of-time when publishing a release.
59-
* Edit `./Package.swift` to add the new component.
60-
* Add a new library product for the component under "products".
61-
* Add a corresponding target for the component under "targets".
62-
* Make sure it depends on "MozillaRustComponentsWrapper" to pull in the pre-compiled Rust code,
63-
as well as on any third-party Swift packages that it may require.
64-
* Follow the instructions below to test it out locally.
65-
66-
That's it! The component will be included in the next release of this package.
67-
68-
## Testing locally
69-
70-
Swift Packages can only be installed from a git repository, but luckily it is possible to use a
71-
local checkout for a git repository for local testing.
72-
73-
You may also need to follow the instructions for [locally testing the `ios-rust` crate](
74-
https://github.com/mozilla/application-services/blob/f3228cf1295154d144be64fc0945c9b3e93a07de/megazords/ios-rust/README.md#testing-locally)
75-
if you need to test changes in the underlying Rust code.
76-
77-
To test out some local changes to this repo:
78-
79-
* Make your changes in a local checkout and commit them.
80-
* Make a new tag via `./make_tag.sh -f 0.0.1`.
81-
* (You won't push this tag anywhere, but using a very low version number helps guard against
82-
any adverse consequences if it does accidentally escape your local machine).
83-
* In a consuming application, delete the Swift Package dependency on `https://github.com/mozilla/rust-components-swift`
84-
and replace it with a dependency on `file:///path/to/your/local/checkout/rust-components-swift` at the `0.0.` release.
85-
86-
### Testing against a local application-services checkout
87-
To run against a local application services checkout, the `make_tag.sh` script supports setting a local path using a `-l` flag, for example:
88-
```sh
89-
./make_tag -l ../application-services 0.0.1
90-
```
91-
92-
That's it! The consuming application should be able to import the package from your local checkout.
9352

53+
## Testing
54+
For testing instructions, you can checkout the [docs in the `application-services`](https://github.com/mozilla/application-services/tree/main/docs/howtos) which are published for convenience in <https://mozilla.github.io/application-services/book/index.html>

0 commit comments

Comments
 (0)