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

Fix variable expansion in ReactNative-application.cmake #35306

Conversation

kkafar
Copy link
Contributor

@kkafar kkafar commented Nov 10, 2022

Summary

Hi, while adjusting react-native-screens to 0.71.0-rc.0 I encountered the same problems as reported here by @WoLewicki.

Basically inside CMake's foreach loop iterator variable is not being expanded to the actual value:

foreach(autolinked_library ${AUTOLINKED_LIBRARIES})
    target_link_libraries(autolinked_library common_flags) // <-- here we are literally linking to "autolinked_library".
endforeach()

Changelog

[Android] [Fixed] - Fix Android autolinking failing because of not expanded variable

Test Plan

@kkafar kkafar marked this pull request as ready for review November 10, 2022 14:44
@kkafar kkafar changed the title Fix variable ref in ReactNative-application.cmake Fix variable expansion in ReactNative-application.cmake Nov 10, 2022
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,100,529 +0
android hermes armeabi-v7a 6,469,939 +0
android hermes x86 7,518,012 +0
android hermes x86_64 7,376,882 +0
android jsc arm64-v8a 8,964,718 +0
android jsc armeabi-v7a 7,696,111 +0
android jsc x86 9,027,215 +0
android jsc x86_64 9,505,348 +0

Base commit: 0376aa4
Branch: main

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 0376aa4
Branch: main

@pull-bot
Copy link

PR build artifact for bf22691 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@pull-bot
Copy link

PR build artifact for bf22691 is ready.
To use, download tarball from "Artifacts" tab in this CircleCI job then run yarn add <path to tarball> in your React Native project.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 11, 2022
@facebook-github-bot
Copy link
Contributor

@rshest has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

kelset pushed a commit that referenced this pull request Nov 22, 2022
Summary:
Hi, while adjusting [react-native-screens](https://github.com/software-mansion/react-native-screens) to `0.71.0-rc.0` I encountered the same problems as reported [here](reactwg/react-native-releases#41 (reply in thread)) by WoLewicki.

Basically inside `CMake`'s `foreach` loop iterator variable is not being expanded to the actual value:

```cmake
foreach(autolinked_library ${AUTOLINKED_LIBRARIES})
    target_link_libraries(autolinked_library common_flags) // <-- here we are literally linking to "autolinked_library".
endforeach()
```

## Changelog

[Android] [Fixed] - Fix Android autolinking failing because of not expanded variable

Pull Request resolved: #35306

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D41220408

Pulled By: rshest

fbshipit-source-id: 12ce993f0c5227ca7d3c2cc272fe3739126930b3
kkafar added a commit to software-mansion/react-native-screens that referenced this pull request Jan 11, 2023
## Description

It seems that autolinking got complete overhaul in 0.71.0 as
`android/app/src/main/jni` directory was deleted -> thus it works
differently for sure now.

Still need to dive into it.

**FabricTestExample**

* [x] Android
* [x] iOS

**TestsExample**

* #1679

**FabricExample**

* #1680

**TODO**: Consider whether to use `com.facebook.react:react-native:+` or
`com.facebook.react:react-native` (without `+`) in
`android/build.gradle` of the library.

AFAIK the former takes highest available version from defined
repositories (should be `node_modules`?), the latter uses version
injected by React Native Gradle Plugin (but I believe it works since
React Native 0.71.0 or 0.70.0 (need to check) -- so version check might
be necessary).


Decided to leave:

```gradle
implementation 'com.facebook.react:react-native:+'
```

in library's `android/build.gradle` due to following reasons: 

* [Android's readme in RN
repo](https://github.com/facebook/react-native/blob/e108e9ebf1e6c52b6eeffeb6c41f842ad95baa0d/android/README.md)
* [Road to 0.71.0
post](reactwg/react-native-releases#41 (reply in thread))

Blocked by:

* ~facebook/react-native#35306
*
~software-mansion/react-native-reanimated#3745
*
~software-mansion/react-native-gesture-handler#2313
(decided to fix version on commit)
* ~`react-native-safe-area-context` - lacks support for RN71~ (created
patch)
* ~`@react-native-community/cli-platform-android` requires this patch:
kkafar/RNS-tester@9edaaa9.
The patch is already merged, but it is not shipped with `react-native`
yet.~

**NOTE**: Example application will handled in separate PR, as there are
problems with detox (it does not support 0.71 yet) and we run CI on that
app.

## Changes

* Updated examples 
* Updated library's build code

## Test code and steps to reproduce

Run example applications

## Checklist

- [ ] Ensured that CI passes
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Hi, while adjusting [react-native-screens](https://github.com/software-mansion/react-native-screens) to `0.71.0-rc.0` I encountered the same problems as reported [here](reactwg/react-native-releases#41 (reply in thread)) by WoLewicki.

Basically inside `CMake`'s `foreach` loop iterator variable is not being expanded to the actual value:

```cmake
foreach(autolinked_library ${AUTOLINKED_LIBRARIES})
    target_link_libraries(autolinked_library common_flags) // <-- here we are literally linking to "autolinked_library".
endforeach()
```

## Changelog

[Android] [Fixed] - Fix Android autolinking failing because of not expanded variable

Pull Request resolved: facebook#35306

Reviewed By: christophpurrer, cipolleschi

Differential Revision: D41220408

Pulled By: rshest

fbshipit-source-id: 12ce993f0c5227ca7d3c2cc272fe3739126930b3
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
mccoyplayer pushed a commit to mccoyplayer/reactScreen that referenced this pull request Feb 9, 2024
## Description

It seems that autolinking got complete overhaul in 0.71.0 as
`android/app/src/main/jni` directory was deleted -> thus it works
differently for sure now.

Still need to dive into it.

**FabricTestExample**

* [x] Android
* [x] iOS

**TestsExample**

* software-mansion/react-native-screens#1679

**FabricExample**

* software-mansion/react-native-screens#1680

**TODO**: Consider whether to use `com.facebook.react:react-native:+` or
`com.facebook.react:react-native` (without `+`) in
`android/build.gradle` of the library.

AFAIK the former takes highest available version from defined
repositories (should be `node_modules`?), the latter uses version
injected by React Native Gradle Plugin (but I believe it works since
React Native 0.71.0 or 0.70.0 (need to check) -- so version check might
be necessary).


Decided to leave:

```gradle
implementation 'com.facebook.react:react-native:+'
```

in library's `android/build.gradle` due to following reasons: 

* [Android's readme in RN
repo](https://github.com/facebook/react-native/blob/e108e9ebf1e6c52b6eeffeb6c41f842ad95baa0d/android/README.md)
* [Road to 0.71.0
post](reactwg/react-native-releases#41 (reply in thread))

Blocked by:

* ~facebook/react-native#35306
*
~software-mansion/react-native-reanimated#3745
*
~software-mansion/react-native-gesture-handler#2313
(decided to fix version on commit)
* ~`react-native-safe-area-context` - lacks support for RN71~ (created
patch)
* ~`@react-native-community/cli-platform-android` requires this patch:
kkafar/RNS-tester@9edaaa9.
The patch is already merged, but it is not shipped with `react-native`
yet.~

**NOTE**: Example application will handled in separate PR, as there are
problems with detox (it does not support 0.71 yet) and we run CI on that
app.

## Changes

* Updated examples 
* Updated library's build code

## Test code and steps to reproduce

Run example applications

## Checklist

- [ ] Ensured that CI passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants