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@6b50b15`, 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. Make the changes indicated by `facebook/react-native@261197d85`, where it touches the Android side of the React Native template app. In this example, `new MainReactPackage()` is nowhere to be seen [3], so, remove that from the list. For `ZulipNativePackage`, `NotificationsPackage`, and `SharingPackage`, add these to the new `packages` variable, under the comment, "Packages that cannot be autolinked yet can be added manually here". 3. Now, go back to `react-native-unimodules` [4] 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. [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]: It isn't present in https://github.com/facebook/react-native/blob/769e35ba5f4c31ef913035a5cc8bc0e88546ca55/template/android/app/src/main/java/com/helloworld/MainApplication.java#L22-L28, which the "autolinking" doc (footnote 1, above) links to. [4]: https://github.com/unimodules/react-native-unimodules
- Loading branch information