Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Use "Autolinking" (RN >= v0.60) #4026

Closed
chrisbobbe opened this issue Apr 8, 2020 · 10 comments
Closed

Build: Use "Autolinking" (RN >= v0.60) #4026

chrisbobbe opened this issue Apr 8, 2020 · 10 comments

Comments

@chrisbobbe
Copy link
Contributor

chrisbobbe commented Apr 8, 2020

Once we're on RN >= v0.60 (that's #3548), we can further increase the ease of managing our native code dependencies, even more than we did on iOS with CocoaPods in #3987.

EDIT: Ah, I just realized that there'd been some previous discussion of this! That's here.

The autolinking docs are here.

The key step that we will no longer have to do is react-native link. Note that this distinguishes "autolinking" from "automatic linking" (what a choice of names!), described in the "Linking Libraries" doc. Note that the "Manual Linking" step, there, describing steps you can take through Xcode to modify the ios/project.pbxproj file, is completely obsolete following the use of CocoaPods in #3987.

I expect we'll want to improve this issue heading (I'm open to this message being edited, wiki-style), but for now, I wanted a place to put a specific comment about one of our dependencies, which I'll do in the next comment.

@chrisbobbe chrisbobbe added the blocked on other work To come back to after another related PR, or some other task. label Apr 8, 2020
@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Apr 8, 2020

At #3987 (comment), Greg was puzzled about the presence of a libz.tbd in project.pbxproj (our project's Xcode config):

This one isn't in the upstream template -- but it also looks like it never was. It entered our project file in a18c95b (#881).

Well, I guess that makes any cleanup of it orthogonal to this PR, then.

As that commit and PR hint at, but don't really say, libz was introduced when we first installed @sentry/react-native. It still receives some special treatment in the latest version: it appears under platforms.ios.sharedLibraries in @sentry/react-native's react-native.config.js, a file that we know is capable of causing changes in the project.pbxproj file when you run react-native link. The doc for that bit of a react-native.config.js file seems to be here.

I wanted to check whether libz would still be included in a fresh install of @sentry/react-native, now that we're using CocoaPods (which wasn't the case for the original install).

So, I ran react-native unlink @sentry/react-native, then manually removed libz from project.pbxproj (this wasn't done automatically!). Then I ran react-native link @sentry/react-native, and libz did indeed reappear in project.pbxproj.

I'm not sure how the react-native.config.js file gets treated with "autolinking". I understand that config file as something that makes things happen on react-native link, but I'm not sure what the behavior is when react-native link isn't explicitly run anymore. I'm wondering the same thing in the context of some font files included with react-native-vector-icons.

So, I think what I'd like to do when we start using "autolinking" is, as part of the required react-native unlink of everything

Autolinking is a replacement for react-native link. If you have been using React Native before version 0.60, please unlink native dependencies if you have any from a previous install.

— is to also remove libz from project.pbxproj (this can be done through Xcode in the left sidebar, with ZulipMobile > Frameworks > libz.tbd > [right-click] > Delete > Move to Trash).

Then, we can see if it gets re-added when we run pod install.

This was referenced Apr 8, 2020
@rk-for-zulip
Copy link
Contributor

So, I ran react-native unlink @sentry/react-native, then manually removed libz from project.pbxproj (this wasn't done automatically!).

Really! That's interesting, because it does seem to have done so for me.

I wonder if there's something else that depends on it less explicitly. Do you still see libz in the project file if you run the miniscript in that commit message to unlink all the dependencies? It's a few months old, so it still lists the old toast library, but that probably shouldn't matter for this.

(I'd just check myself, but apparently react-native link does approximately nothing to the Xcode project files if you run it on Linux.)

but I'm not sure what the behavior is when react-native link isn't explicitly run anymore. I'm wondering the same thing in the context of some font files included with react-native-vector-icons.

For me, it removed both libz and the fonts (same commit), and replaced neither; I ended up adding the fonts back in manually. I don't know if Sentry still needs an explicit libz link – I didn't add it myself, but I don't think I got to the point of testing Sentry, so that's not meaningful.

@chrisbobbe
Copy link
Contributor Author

Aha, I'm glad to see these results and to have that nonce script to test with!

I'm also happy (one must rejoice when one can, dealing with iOS dependencies) to see what looks like a pattern.

I see

a) an automatic removal of libz after running that script from 33f4b41^, and
b) no automatic removal of libz after running that script from 33f4b41

where 33f4b41 is where we started using CocoaPods. I think the behaviors of both react-native link and react-native unlink change dramatically in the presence of a Podfile.

@chrisbobbe
Copy link
Contributor Author

And, indeed, I see a) and b) when I just run react-native unlink @sentry/react-native, so it's doubtful that some other dependency is involved, which is another win for our understanding.

@chrisbobbe
Copy link
Contributor Author

I don't know if Sentry still needs an explicit libz link – I didn't add it myself, but I don't think I got to the point of testing Sentry, so that's not meaningful.

I saw that it built successfully without libz, but I didn't go to the trouble of getting Sentry working in debug mode, to test, either. Since libz is still mentioned in that react-native.config.js file in Sentry's latest master, I think it's plausible that it is still needed, but we'll have a better picture once we see if libz gets automatically re-added under the "autolinking" regime.

@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Apr 9, 2020

I ended up adding the fonts back in manually

They should be added by CocoaPods, regardless of whether you're using CocoaPods on RN v0.59 or RN v0.60. Did you have CocoaPods working in that commit?

On running pod install, CocoaPods reacts to the line

s.resources      = "Fonts/*.ttf"

in react-native-vector-icons' Podspec by creating a new build phase, called "[CP] Copy Pods Resources", in our ZulipMobile project, which makes sure the font files are included. I haven't fully tracked down what code handles the create/edit/delete of that build phase, but it looks like an important piece that's used by the build phase is a script generated by this code in CocoaPods.

There's been some discussion about how these fonts are handled here and here, in addition to my link on "wondering" above.

Also, the font files don't appear as "files" in "Resources", or anywhere else in the left sidebar, but rather, as "paths" in that new build phase; Greg mentions that here.

@gnprice
Copy link
Member

gnprice commented Apr 9, 2020

So, I think what I'd like to do when we start using "autolinking" [...] is to also remove libz from project.pbxproj [...]

Then, we can see if it gets re-added when we run pod install.

One more observation on this bit: the RNSentry.podspec inside node_modules/@sentry/react-native/ pulls in the Sentry pod:

  s.dependency 'Sentry', '~> 4.4.0'

And in turn Sentry.podspec has this line:

  s.libraries = 'z', 'c++'

I expect that means that under pod install, a libz dependency (as well as libc++) will end up in the generated Pods.xcodeproj, but not in our own Xcode project.

@chrisbobbe
Copy link
Contributor Author

And in turn Sentry.podspec has this line:

Ohhh — is the z -> libz transformation similar to the transformation we've seen with React -> libReact.a, etc.? I didn't make that connection, but it sounds reasonable.

@chrisbobbe
Copy link
Contributor Author

chrisbobbe commented Apr 9, 2020

I expect that means that under pod install, a libz dependency (as well as libc++) will end up in the generated Pods.xcodeproj, but not in our own Xcode project.

In the status quo, without "autolinking", we see what we expect: pod install doesn't put libz in in our own Xcode project.

But pod install isn't the complete linking procedure in the status quo, react-native link is (which, among other things, seems to run pod install if you have a Podfile). And react-native link does add it.

One interesting observation, given what you've just pointed out about Sentry.podspec, is that libz is nowhere to be found in Pods.xcodeproj after running just pod install in the status quo.

@gnprice
Copy link
Member

gnprice commented Apr 10, 2020

Ohhh — is the z -> libz transformation similar to the transformation we've seen with React -> libReact.a, etc.?

Yup! Here's GCC's documentation for it:
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

-llibrary

Search the library named library when linking. [...]

Static libraries are archives of object files, and have file names like liblibrary.a. Some targets also support shared libraries, which typically have names like liblibrary.so. [...]

(Xcode is built on Clang, not GCC; but this convention is standard across all kinds of Unix-style compilers and linkers, and because we found Clang's documentation was thin when looking into the #include "foo.h" question, I just went straight to the GCC docs.)

chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue May 23, 2020
Part of the RN v0.59.10 -> v0.60.0 upgrade [1]. (Or, at least, RN
and most library maintainers assume it is done as such.) This must
happen at or after the upgrade commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern,
   so you can just look at the third:

   261197d85 Implement changes to enable native modules auto linking (#24506)
   da7d3dfc7 Partially back out #24506, fixing iOS e2e tests (#24788)
   86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main upgrade
   commit, earlier in this series, where we moved to RN v0.60.0.

4. Add our two dependencies that we explicitly do not link on iOS to
   the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. So, job done.

Closes: zulip#4026

[1]: https://react-native-community.github.io/upgrade-helper/?from=0.59.10&to=0.60.0

[2]: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md

[3]: https://github.com/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 1, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern:

   - 261197d85 Implement changes to enable native modules auto
   linking (#24506)

   - da7d3dfc7 Partially back out #24506, fixing iOS e2e tests
   (#24788)

   - 86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the ">=
   0.60" branch of the "Configure iOS" instructions. Turns out that
   no changes are needed here; the differences in expressing our
   React pod dependencies were handled in the main RN v0.60 upgrade
   commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. So, job done.

Closes: zulip#4026

[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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 1, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern:

   - 261197d85 Implement changes to enable native modules auto
   linking (#24506)

   - da7d3dfc7 Partially back out #24506, fixing iOS e2e tests
   (#24788)

   - 86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the ">=
   0.60" branch of the "Configure iOS" instructions. Turns out that
   no changes are needed here; the differences in expressing our
   React pod dependencies were handled in the main RN v0.60 upgrade
   commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. So, job done.

Closes: zulip#4026

[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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 1, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern:

   - 261197d85 Implement changes to enable native modules auto
   linking (#24506)

   - da7d3dfc7 Partially back out #24506, fixing iOS e2e tests
   (#24788)

   - 86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the ">=
   0.60" branch of the "Configure iOS" instructions. Turns out that
   no changes are needed here; the differences in expressing our
   React pod dependencies were handled in the main RN v0.60 upgrade
   commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. So, job done.

Closes: zulip#4026

[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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 3, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern:

   - 261197d85 Implement changes to enable native modules auto
   linking (#24506)

   - da7d3dfc7 Partially back out #24506, fixing iOS e2e tests
   (#24788)

   - 86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the ">=
   0.60" branch of the "Configure iOS" instructions. Turns out that
   no changes are needed here; the differences in expressing our
   React pod dependencies were handled in the main RN v0.60 upgrade
   commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 3, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the changes recommended by these commits in
   `facebook/react-native`. They follow an A, revert-A, A' pattern:

   - 261197d85 Implement changes to enable native modules auto
   linking (#24506)

   - da7d3dfc7 Partially back out #24506, fixing iOS e2e tests
   (#24788)

   - 86a97e783 – Bring back autolinking to the iOS template (#25314)

   It simply imports and runs a command, `use_native_modules`.

3. Now, go back to `react-native-unimodules` and follow the ">=
   0.60" branch of the "Configure iOS" instructions. Turns out that
   no changes are needed here; the differences in expressing our
   React pod dependencies were handled in the main RN v0.60 upgrade
   commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 4, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the change recommended by `facebook/react-native@86a97e783`:
   import and call a method, `use_native_modules!`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main RN v0.60
   upgrade commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
chrisbobbe added a commit that referenced this issue Jun 4, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the change recommended by `facebook/react-native@86a97e783`:
   import and call a method, `use_native_modules!`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main RN v0.60
   upgrade commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     #4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: #4026
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 5, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the change recommended by `facebook/react-native@86a97e783`:
   import and call a method, `use_native_modules!`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main RN v0.60
   upgrade commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 5, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the change recommended by facebook/react-native@86a97e783:
   import and call a method, `use_native_modules!`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main RN v0.60
   upgrade commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
chrisbobbe added a commit to chrisbobbe/zulip-mobile that referenced this issue Jun 8, 2020
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 commit because autolinking is a new
feature.

Just like the previous commit, but for iOS.

1. Following the doc [2] as before, unlink everything. Again, with a
   script, but this time, only for iOS:

   ```
   for dep in `tools/deps`; do
     react-native unlink --platforms=ios "$dep"
   done
   ```

   Exclude the same set of Sentry changes as we did in this step for
   Android. Also, exclude a change to our Info.plist that would
   remove the "Fonts provided by application", a.k.a., `UIAppFonts`.
   This is a setup step [3] that we need to keep.

   So, we're left with the removal of all items from the "Pods we
   need that depend on React Native" list.

   Additionally, remove "libz" from our Xcode config. It was put
   there by Sentry, as a consequence of running `react-native link`
   before we were using CocoaPods. But Sentry expresses the same
   dependency in `Sentry.podspec`. So, having it in our Xcode config
   is redundant. [4]

2. Make the change recommended by facebook/react-native@86a97e783:
   import and call a method, `use_native_modules!`.

3. Now, go back to `react-native-unimodules` and follow the
   ">= 0.60" branch of the "Configure iOS" instructions. Turns out
   that no changes are needed here; the differences in expressing
   our React pod dependencies were handled in the main RN v0.60
   upgrade commit.

4. Move the two deps under "RN-dependent Pods that we could include,
   but we've decided not to" into the `react-native.config.js`.

5. Add a workaround in `tools/postinstall` for an issue [5] with
   running `pod install` from the root directory with
   `--project-directory=ios`.

   We tried the workaround suggested in that issue, where we have
   `use_native_modules!(".")` in the Podfile and still call
   `pod install --project-directory=ios` from the root directory.
   (This might have led to a cleaner solution, where we pass "." in
   the postinstall case, and pass nothing otherwise.) But we got
   this error, which isn't addressed in that issue, and doesn't seem
   easy to fix without changes to `native_modules.rb`:

   ```
   [!] No podspec found for `RNCAsyncStorage` in
   `./node_modules/@react-native-community/async-storage`
   ```

   It's plausible that those investigating this issue were only
   testing with a template project that didn't have RN-dependent
   pods like RNCAsyncStorage, so, never saw this error.

6. Run `pod install` and see that the only change to
   `ios/Podfile.lock` is in the checksum. 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/oblador/react-native-vector-icons#option-manually

[4]: There's some uncertainty here; we're not seeing `z` or `libz`
     in ios/Pods/Pods.xcodeproj/project.pbxproj after running `pod
     install`, with or without autolinking. But it seems to work.
     More discussion at
     zulip#4026 (comment)
     and
     https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/RN.20autolinking/near/884333.

[5]: react-native-community/cli#657

Fixes: zulip#4026
@gnprice gnprice closed this as completed in a9a9ac7 Jun 8, 2020
@gnprice gnprice removed the blocked on other work To come back to after another related PR, or some other task. label Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants