Skip to content

Commit 68395bf

Browse files
authored
fix: windows builds (#1248)
## 📜 Description Added a job for building example app on windows and shortened `codegen` name to fix build errors. ## 💡 Motivation and Context This is a continuation of #1251 In #1251 we shortened codegen name from `reactnativekeyboardcontroller` till `keyboardcontroller`. In this PR we make it even shorter: from `keyboardcontroller` -> `RNKC`. The `keyboardcontroller` has 18 symbols, `safeareacontext` (very popular lib) has 15 symbols, so our lib will exceed symbols limitation, when `safeareacontext` will not. Now I make length only 4 symbols. While I'm not a big fan of making variables/pathname shorter, because it makes more effort for newcomers to understand the code, but here I'm ready to sacrifice readability in favor of smaller amount of issues with complaints that builds are failing on windows. I hope in 2026 RN team will update Ninja/CMake to newest version and this limitation will gone, but for now let's use shorter name and fix windows build errors. Also I'd like to say few words about CI job. I've tried to assemble example app on windows runners, but I had compilation errors because of reanimated. So I went in a different direction. I create a new app and then link my lib locally to this project (just to check compilation issues). Not very elegant but it does its job - it gives me more confidence, that windows builds are not occasionally get broken 🤞 Closes #1247 #1147 #1253 ## 📢 Changelog <!-- High level overview of important changes --> <!-- For example: fixed status bar manipulation; added new types declarations; --> <!-- If your changes don't affect one of platform/language below - then remove this platform/language --> ### CI - add a job for windows builds; ### iOS - make codegen name shorter; ### Android - make codegen name shorter; ### C++ - make codegen name shorter; ## 🤔 How Has This Been Tested? Tested on CI. ## 📸 Screenshots (if appropriate): |Before|After| |-------|-----| |<img width="1250" height="824" alt="image" src="https://github.com/user-attachments/assets/fa9a34de-3451-4689-9964-37b3f4576ca8" />|<img width="1201" height="203" alt="image" src="https://github.com/user-attachments/assets/8788f6b8-3299-48f8-9d97-c91dd1a69c85" />| ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent afdd6b3 commit 68395bf

35 files changed

Lines changed: 134 additions & 65 deletions
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: 🤖 Build Android Fabric
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- ".github/workflows/build-android-fabric-windows.yml"
9+
- "android/**"
10+
- "yarn.lock"
11+
- "src/specs/**"
12+
- "common/**"
13+
pull_request:
14+
paths:
15+
- ".github/workflows/build-android-fabric-windows.yml"
16+
- "android/**"
17+
- "yarn.lock"
18+
- "src/specs/**"
19+
- "common/**"
20+
21+
jobs:
22+
build:
23+
name: 💠 Build Android on Windows
24+
runs-on: windows-latest
25+
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Setup JDK 17
29+
uses: actions/setup-java@v4
30+
with:
31+
distribution: "microsoft"
32+
java-version: "17"
33+
- name: Create sample app
34+
run: cd ..\..\ && npx @react-native-community/cli@latest init WindowsWithUnbelievablyHugeAndReallyLongPathName --version 0.83.1
35+
- name: Get yarn cache directory path
36+
id: fabric-windows-yarn-cache-dir-path
37+
shell: pwsh
38+
run: |
39+
$dir = yarn cache dir
40+
echo "dir=$dir" >> $env:GITHUB_OUTPUT
41+
- name: Restore node_modules from cache
42+
uses: actions/cache@v4
43+
id: yarn-cache
44+
with:
45+
path: ${{ steps.fabric-windows-yarn-cache-dir-path.outputs.dir }}
46+
key: ${{ runner.os }}-fabric-windows-yarn-${{ hashFiles('**/yarn.lock') }}
47+
restore-keys: |
48+
${{ runner.os }}-fabric-windows-yarn-
49+
- name: Install node_modules for windows/
50+
shell: pwsh
51+
run: |
52+
cd ..\..\ && yarn install --frozen-lockfile --cwd WindowsWithUnbelievablyHugeAndReallyLongPathName
53+
- name: Link keyboard controller
54+
shell: pwsh
55+
run: cd ..\..\WindowsWithUnbelievablyHugeAndReallyLongPathName && yarn add react-native-keyboard-controller@link:../react-native-keyboard-controller/react-native-keyboard-controller
56+
- name: Restore Gradle cache
57+
uses: actions/cache@v4
58+
with:
59+
path: |
60+
C:\Users\runneradmin\.gradle\caches
61+
C:\Users\runneradmin\.gradle\wrapper
62+
key: ${{ runner.os }}-fabric-windows-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
63+
restore-keys: |
64+
${{ runner.os }}-fabric-windows-gradle-
65+
- name: Run Gradle Build for windows/android/
66+
shell: pwsh
67+
run: |
68+
cd ..\..\WindowsWithUnbelievablyHugeAndReallyLongPathName\android
69+
.\gradlew.bat assembleDebug --build-cache -PreactNativeArchitectures=arm64-v8a

.github/workflows/build-android-fabric.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626

2727
jobs:
2828
build:
29-
name: Build Android Fabric Example App
29+
name: 🖥️ Build Android Fabric Example App
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4

FabricExample/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,7 @@ SPEC CHECKSUMS:
31173117
React-microtasksnativemodule: 44b44a4d3cd6ffb85d928abf741acdc26722de2e
31183118
react-native-advanced-input-mask: 7e8cb58287774c4447485387661abe946d0e0bb2
31193119
react-native-blur: ba0e9ad6274783c8d45f42da82acae02e25784ad
3120-
react-native-keyboard-controller: d07a35e49d478d26b2eb44b10aedc4e1d35354d6
3120+
react-native-keyboard-controller: 0bf45b0ab9c8f2caf632832e80abfd33978d212c
31213121
react-native-safe-area-context: 6d8a7b750e496e37bda47c938320bf2c734d441f
31223122
React-NativeModulesApple: b5d18bc109c45c9a1c6b71664991b5cc3adc4e48
31233123
React-oscompat: 93b5535ea7f7dff46aaee4f78309a70979bdde9d

android/src/main/jni/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.13)
22
set(CMAKE_VERBOSE_MAKEFILE ON)
33

4-
set(LIB_LITERAL keyboardcontroller)
4+
set(LIB_LITERAL RNKC)
55
set(LIB_TARGET_NAME react_codegen_${LIB_LITERAL})
66

77
set(LIB_ANDROID_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)

android/src/main/jni/RNKC.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <ReactCommon/JavaTurboModule.h>
4+
#include <ReactCommon/TurboModule.h>
5+
#include <jsi/jsi.h>
6+
7+
/**
8+
* Note this import and that it is not present in autogenerated header file
9+
* under android/build/generated/source/codegen/jni/RNKC.h
10+
*
11+
* Here we are overriding autogenerated component descriptors by prioritizing our custom headers via include path setup.
12+
*/
13+
#include <react/renderer/components/RNKC/RNKCKeyboardControllerViewComponentDescriptor.h>
14+
#include <react/renderer/components/RNKC/RNKCKeyboardGestureAreaComponentDescriptor.h>
15+
#include <react/renderer/components/RNKC/RNKCOverKeyboardViewComponentDescriptor.h>
16+
#include <react/renderer/components/RNKC/RNKCKeyboardBackgroundViewComponentDescriptor.h>
17+
18+
#include <memory>
19+
#include <string>
20+
21+
namespace facebook::react {
22+
JSI_EXPORT
23+
std::shared_ptr<TurboModule> RNKC_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
24+
} // namespace facebook::react

android/src/main/jni/keyboardcontroller.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

common/cpp/react/renderer/components/keyboardcontroller/RNKCKeyboardBackgroundViewComponentDescriptor.h renamed to common/cpp/react/renderer/components/RNKC/RNKCKeyboardBackgroundViewComponentDescriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "RNKCKeyboardBackgroundViewShadowNode.h"
1111

1212
#include <react/debug/react_native_assert.h>
13-
#include <react/renderer/components/keyboardcontroller/Props.h>
13+
#include <react/renderer/components/RNKC/Props.h>
1414
#include <react/renderer/core/ConcreteComponentDescriptor.h>
1515

1616
namespace facebook::react {

common/cpp/react/renderer/components/keyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.cpp renamed to common/cpp/react/renderer/components/RNKC/RNKCKeyboardBackgroundViewShadowNode.cpp

File renamed without changes.

common/cpp/react/renderer/components/keyboardcontroller/RNKCKeyboardBackgroundViewShadowNode.h renamed to common/cpp/react/renderer/components/RNKC/RNKCKeyboardBackgroundViewShadowNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#include "RNKCKeyboardBackgroundViewState.h"
1111

12-
#include <react/renderer/components/keyboardcontroller/EventEmitters.h>
13-
#include <react/renderer/components/keyboardcontroller/Props.h>
12+
#include <react/renderer/components/RNKC/EventEmitters.h>
13+
#include <react/renderer/components/RNKC/Props.h>
1414
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
1515
#include <jsi/jsi.h>
1616

common/cpp/react/renderer/components/keyboardcontroller/RNKCKeyboardBackgroundViewState.h renamed to common/cpp/react/renderer/components/RNKC/RNKCKeyboardBackgroundViewState.h

File renamed without changes.

0 commit comments

Comments
 (0)