Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android build: Enable "autolinking".
Part of the RN v0.59 -> v0.60 upgrade [1]. (Or, at least, RN and most library maintainers assume it is done as such.) This must happen at or after the upgrade because autolinking is a new feature. "Autolinking" [2] aims to make the "react-native link" command unnecessary, so that when we add a module with native code, all we have to do for the module to be included is run `yarn add`. (Other native-code changes, such as calling functions that the module provides, may still be necessary.) So, for Android: 1. As indicated in the doc [2], unlink everything from Android. As done in rk-for-zulip/zulip-mobile@6b50b1521, we do this with a script, but here, we tell `react-native unlink` to only unlink from Android. To be as exhaustive as possible, we tell it to unlink *all dependencies* in our package.json. Thankfully, if one isn't already linked, unlinking it is a no-op: ``` for dep in `tools/deps`; do react-native unlink --platforms=android "$dep" done ``` As in rk-for-zulip/zulip-mobile@6b50b1521, it looks like a custom script in Sentry removed some setup that we want to remain intact. So, exclude these from the commit: - In `ios/ZulipMobile.xcodeproj/project.pbxproj`, removing the "Upload Debug Symbols to Sentry" PBXShellScriptBuildPhase. We don't want to touch the iOS side at all right now. - In `android/app/build.gradle`, the removal of the line: ``` apply from: "../../node_modules/@sentry/react-native/sentry.gradle" ``` Strangely, `react-native unlink`'s changes in MainApplication.java did not touch the list returned by `getPackages`, but it did remove the imports that many of these list items depend on. So, remove these list items, taking note, for a future step, that a few are left intact: - `new MainReactPackage()` - `new ZulipNativePackage()` - `new NotificationsPackage()` - `new SharingPackage()` 2. Apply the Android-side changes from facebook/react-native@261197d85. In `getPackages`, this removes `MainReactPackage` and gives a new form to put the references to `ZulipNativePackage`, `NotificationsPackage`, and `SharingPackage`. 3. Now, go back to `react-native-unimodules` [3] and follow the "react-native >= 0.60" branch of the "Configure Android" instructions. We had to make some trivial changes in `MainApplication.java`; we push to the list at the now-existing `packages` variable instead of changing the literal list that was previously returned without being stored in a variable. 4. Add a `react-native.config.js` file, as the recommended way [2] to say we don't want certain modules to be linked. For details on `react-native-vector-icons`, see a commit earlier in this series that solidified our choice not to link `VectorIconsPackage`. 5. To compare the list of linked packages before and after this commit, note that in both cases, the list to be observed is the one returned by the `getPackages` implementation in `MainApplication.java`. Autolinking introduces an auto-generated `PackageList` class in `android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java` with a `getPackages` method of its own, which helps compose that list of packages we're observing. The `getPackages` implementation is auto-generated when you build for Android. So, compare (by alphebetizing and diffing) the list before autolinking with the new list put together with help from that auto-generated code. They are the same, so, job done. [1]: https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.6 [2]: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md [3]: https://github.com/unimodules/react-native-unimodules
- Loading branch information