From ecdf459c87ba862388f04ef95e68ffe516156e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Roz=CC=87niata?= <56474758+krozniata@users.noreply.github.com> Date: Mon, 12 Oct 2026 09:23:06 +0200 Subject: [PATCH] chore: clean up native build config --- .github/workflows/main.yml | 2 +- CONTRIBUTING.md | 4 +- README.md | 4 + android/Android.mk | 45 ---- android/build.gradle | 249 +++--------------- android/debug.keystore | Bin 2257 -> 0 bytes android/gradle.properties | 7 - android/registration.cpp | 18 -- android/src/main/AndroidManifest.xml | 4 +- .../PagerViewViewManager.kt | 19 +- example/ios/Podfile.lock | 6 +- package.json | 21 +- react-native-pager-view.podspec | 3 +- src/PagerView.tsx | 8 +- src/utils.ios.tsx | 2 +- src/utils.tsx | 2 +- tsconfig.json | 6 +- 17 files changed, 78 insertions(+), 322 deletions(-) delete mode 100644 android/Android.mk delete mode 100644 android/debug.keystore delete mode 100644 android/gradle.properties delete mode 100644 android/registration.cpp diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3bd5177..29118270 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: run: bun run lint - name: Typecheck files - run: bun run typescript + run: bun run typecheck - name: Typecheck example run: bun run typescript diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0697b700..a5d22fc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,7 +42,7 @@ bun example:ios Make sure your code passes TypeScript, Prettier and ESLint. Run the following to verify: ```sh -bun typescript +bun typecheck bun format:check bun lint ``` @@ -98,7 +98,7 @@ bun release The `package.json` file contains various scripts for common tasks: - `bun bootstrap`: setup project by installing all dependencies and pods. -- `bun typescript`: type-check files with TypeScript. +- `bun typecheck`: type-check files with TypeScript. - `bun lint`: lint files with ESLint (cached). - `bun format`: format files with Prettier. - `bun format:check`: check formatting with Prettier without writing changes. diff --git a/README.md b/README.md index 13a9420b..f166c5cf 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,10 @@ The library is autolinked. On iOS, install the pods afterwards: cd ios && pod install ``` +## Compatibility + +We support the three latest React Native versions: **0.85**, **0.86** and **0.87**. Only the New Architecture is supported. + ## Usage ```tsx diff --git a/android/Android.mk b/android/Android.mk deleted file mode 100644 index d2ff7090..00000000 --- a/android/Android.mk +++ /dev/null @@ -1,45 +0,0 @@ -THIS_DIR := $(call my-dir) - -include $(REACT_ANDROID_DIR)/Android-prebuilt.mk - -include ${GENERATED_SRC_DIR}/codegen/jni/Android.mk - -include $(CLEAR_VARS) - -LOCAL_PATH := $(THIS_DIR) - -# Define the library name here. -LOCAL_MODULE := ${CODEGEN_MODULE_NAME}_registration - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_SHARED_LIBRARIES := \ - libfabricjni \ - libfbjni \ - libglog \ - libjsi \ - libreact_codegen_rncore \ - libreact_codegen_${CODEGEN_MODULE_NAME} \ - libreact_debug \ - libreact_nativemodule_core \ - libreact_render_componentregistry \ - libreact_render_core \ - libreact_render_debug \ - libreact_render_graphics \ - librrc_view \ - libruntimeexecutor \ - libturbomodulejsijni \ - libyoga - -ifneq ($(filter $(call modules-get-list),folly_runtime),) - LOCAL_SHARED_LIBRARIES += libfolly_runtime # since react-native@0.69 -else - LOCAL_SHARED_LIBRARIES += libfolly_futures libfolly_json # react-native@0.68 -endif - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReactNative\" \ - -DCODEGEN_COMPONENT_DESCRIPTOR_H="" -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 5973c32c..97b626cb 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,6 +1,19 @@ buildscript { - // Buildscript is evaluated before everything else so we can't use getExtOrDefault - def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['PagerView_kotlinVersion'] + ext.PagerView = [ + kotlinVersion: "2.0.21", + composeVersion: "1.7.8", + lifecycleVersion: "2.6.1", + minSdkVersion: 24, + compileSdkVersion: 36 + ] + + ext.getExtOrDefault = { prop -> + if (rootProject.ext.has(prop)) { + return rootProject.ext.get(prop) + } + + return PagerView[prop] + } repositories { google() @@ -8,240 +21,52 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.2.1' + classpath "com.android.tools.build:gradle:8.7.2" // noinspection DifferentKotlinGradleVersion - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}" + classpath "org.jetbrains.kotlin:compose-compiler-gradle-plugin:${getExtOrDefault('kotlinVersion')}" } } -apply plugin: 'com.android.library' - -def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() - -// AGP 9 compiles Kotlin sources on its own ("built-in Kotlin"), which is enabled by default and -// can be turned off with `android.builtInKotlin=false`. Applying the Kotlin Android plugin on top -// of it fails the build, so only apply it explicitly when built-in Kotlin is not in play. -def builtInKotlinProperty = findProperty('android.builtInKotlin') -def hasBuiltInKotlin = agpVersion >= 9 && - (builtInKotlinProperty == null || builtInKotlinProperty.toString().toBoolean()) - -if (!hasBuiltInKotlin) { - apply plugin: 'kotlin-android' -} -apply plugin: 'org.jetbrains.kotlin.plugin.compose' -apply plugin: 'com.facebook.react' +apply plugin: "com.android.library" -def getExtOrDefault(name) { - return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['PagerView_' + name] +if (project.extensions.findByName("kotlin") == null) { + apply plugin: "kotlin-android" } -def getExtOrIntegerDefault(name) { - return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['PagerView_' + name]).toInteger() -} -def shouldUseNameSpace = agpVersion >= 8 -def PACKAGE_PROP = "package=\"com.reactnativepagerview\"" -def manifestOutFile = file("${projectDir}/src/main/AndroidManifest.xml") -def manifestContent = manifestOutFile.getText() -if(shouldUseNameSpace){ - manifestContent = manifestContent.replaceAll( - PACKAGE_PROP, - '' - ) -} else { - if(!manifestContent.contains("$PACKAGE_PROP")){ - manifestContent = manifestContent.replace( - 'st5|P)KF1_Z;y){W{<7K{nl!CPuE z_^(!C(Ol0n8 zK13*rzAtW>(wULKPRYLd7G18F8#1P`V*9`(Poj26eOXYyBVZPno~Cvvhx7vPjAuZo zF?VD!zB~QG(!zbw#qsxT8%BSpqMZ4f70ZPn-3y$L8{EVbbN9$H`B&Z1quk9tgp5FM zuxp3pJ0b8u|3+#5bkJ4SRnCF2l7#DyLYXYY8*?OuAwK4E6J{0N=O3QNVzQ$L#FKkR zi-c@&!nDvezOV$i$Lr}iF$XEcwnybQ6WZrMKuw8gCL^U#D;q3t&HpTbqyD%vG=TeDlzCT~MXUPC|Leb-Uk+ z=vnMd(|>ld?Fh>V8poP;q;;nc@en$|rnP0ytzD&fFkCeUE^kG9Kx4wUh!!rpjwKDP zyw_e|a^x_w3E zP}}@$g>*LLJ4i0`Gx)qltL}@;mDv}D*xR^oeWcWdPkW@Uu)B^X&4W1$p6}ze!zudJ zyiLg@uggoMIArBr*27EZV7djDg@W1MaL+rcZ-lrANJQ%%>u8)ZMWU@R2qtnmG(acP z0d_^!t>}5W zpT`*2NR+0+SpTHb+6Js4b;%LJB;B_-ChhnU5py}iJtku*hm5F0!iql8Hrpcy1aYbT z1*dKC5ua6pMX@@iONI?Hpr%h;&YaXp9n!ND7-=a%BD7v&g zOO41M6EbE24mJ#S$Ui0-brR5ML%@|ndz^)YLMMV1atna{Fw<;TF@>d&F|!Z>8eg>>hkFrV)W+uv=`^F9^e zzzM2*oOjT9%gLoub%(R57p-`TXFe#oh1_{&N-YN z<}artH|m=d8TQuKSWE)Z%puU|g|^^NFwC#N=@dPhasyYjoy(fdEVfKR@cXKHZV-`06HsP`|Ftx;8(YD$fFXumLWbGnu$GMqRncXYY9mwz9$ap zQtfZB^_BeNYITh^hA7+(XNFox5WMeG_LtJ%*Q}$8VKDI_p8^pqX)}NMb`0e|wgF7D zuQACY_Ua<1ri{;Jwt@_1sW9zzdgnyh_O#8y+C;LcZq6=4e^cs6KvmK@$vVpKFGbQ= z$)Eux5C|Fx;Gtmv9^#Y-g@7Rt7*eLp5n!gJmn7&B_L$G?NCN`AP>cXQEz}%F%K;vUs{+l4Q{}eWW;ATe2 zqvXzxoIDy(u;F2q1JH7Sf;{jy_j})F+cKlIOmNfjBGHoG^CN zM|Ho&&X|L-36f}Q-obEACz`sI%2f&k>z5c$2TyTSj~vmO)BW~+N^kt`Jt@R|s!){H ze1_eCrlNaPkJQhL$WG&iRvF*YG=gXd1IyYQ9ew|iYn7r~g!wOnw;@n42>enAxBv*A zEmV*N#sxdicyNM=A4|yaOC5MByts}s_Hpfj|y<6G=o=!3S@eIFKDdpR7|FY>L&Wat&oW&cm&X~ z5Bt>Fcq(fgnvlvLSYg&o6>&fY`ODg4`V^lWWD=%oJ#Kbad2u~! zLECFS*??>|vDsNR&pH=Ze0Eo`sC_G`OjoEKVHY|wmwlX&(XBE<@sx3Hd^gtd-fNwUHsylg06p`U2y_={u}Bc -#include CODEGEN_COMPONENT_DESCRIPTOR_H - -namespace facebook { -namespace react { - -void registerProviders() { - auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry(); - providerRegistry->add(concreteComponentDescriptorProvider()); -} - -} -} - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { - facebook::react::registerProviders(); - return JNI_VERSION_1_6; -} \ No newline at end of file diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 068070f9..a2f47b60 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,2 @@ - - + diff --git a/android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt b/android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt index d41052a7..cccd4185 100644 --- a/android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt +++ b/android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt @@ -3,13 +3,11 @@ package com.reactnativepagerview import android.view.View import android.view.ViewGroup import com.facebook.react.bridge.ReadableArray -import com.facebook.react.common.MapBuilder import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.* import com.facebook.react.uimanager.annotations.ReactProp import com.facebook.react.viewmanagers.RNCViewPagerManagerDelegate import com.facebook.react.viewmanagers.RNCViewPagerManagerInterface -import com.facebook.soloader.SoLoader import com.reactnativepagerview.event.PageScrollEvent import com.reactnativepagerview.event.PageScrollStateChangedEvent import com.reactnativepagerview.event.PageSelectedEvent @@ -19,12 +17,6 @@ import com.reactnativepagerview.event.PageSelectedEvent class PagerViewViewManager : ViewGroupManager(), RNCViewPagerManagerInterface { companion object { const val NAME = "RNCViewPager" - - init { - if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) { - SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION) - } - } } private val mDelegate: ViewManagerDelegate = RNCViewPagerManagerDelegate(this) @@ -157,10 +149,9 @@ class PagerViewViewManager : ViewGroupManager(), RNCViewPagerM } } - override fun getExportedCustomDirectEventTypeConstants(): MutableMap> { - return MapBuilder.of( - PageScrollEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageScroll"), - PageScrollStateChangedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageScrollStateChanged"), - PageSelectedEvent.EVENT_NAME, MapBuilder.of("registrationName", "onPageSelected")) - } + override fun getExportedCustomDirectEventTypeConstants(): MutableMap = mutableMapOf( + PageScrollEvent.EVENT_NAME to mapOf("registrationName" to "onPageScroll"), + PageScrollStateChangedEvent.EVENT_NAME to mapOf("registrationName" to "onPageScrollStateChanged"), + PageSelectedEvent.EVENT_NAME to mapOf("registrationName" to "onPageSelected"), + ) } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index cb738996..009061c5 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1246,7 +1246,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - react-native-pager-view (9.0.6): + - react-native-pager-view (9.0.7): - hermes-engine - RCTRequired - RCTTypeSafety @@ -2280,7 +2280,7 @@ SPEC CHECKSUMS: FBLazyVector: e08a27053b503eeb756ea4bd75d570d2f2522a1b fmt: ba0886e864ebb21d14c98b2e12e164b8002f5b93 glog: 3cf7cb46f743c4bc758ae3e6d9c15bd1b4cfd6d4 - hermes-engine: 63c5db7d529c36335fada6582fd293ae2a105d77 + hermes-engine: 35975068890c71d4609534b47111140882468c3a RCT-Folly: 82921e585c0400eda46fac1068297aa9dfb035e4 RCTDeprecation: 5cc865306ce4974b7a57ddbc575fd1f3fef41957 RCTRequired: ea6f2c41f2670961ce9a48a4bf17a190dd53e493 @@ -2321,7 +2321,7 @@ SPEC CHECKSUMS: React-Mapbuffer: 295203fc648a43acf7fba609ddf573aa9fca849f React-microtasksnativemodule: 269f81deee27a2a9bedb6b2d1088c1ae93de9bd3 React-mutationobservernativemodule: 877e9f730e0d8175c2e952901b55c170fc3d372f - react-native-pager-view: b558d26913abc7415563648759b77e6bd1b61da9 + react-native-pager-view: 0f825e2af4fc75b3cf10d896d64fa3ea1eb8e7aa react-native-safe-area-context: f2bf5d3db254014a48910436c4a58ab0c4e2fe1f React-NativeModulesApple: adb1dd8361dff80e9f6652fb3fdbf033cfbe2a89 React-networking: c00b437c4408f0640ba0d4158357133488521eca diff --git a/package.json b/package.json index 6f1d8be3..a4bbca61 100644 --- a/package.json +++ b/package.json @@ -12,17 +12,22 @@ "lib", "android", "ios", - "react-native-pager-view.podspec", - "!lib/typescript/example", - "!android/build", + "*.podspec", "!ios/build", + "!android/build", + "!android/gradle", + "!android/gradlew", + "!android/gradlew.bat", + "!android/local.properties", + "!android/src/test", "!**/__tests__", "!**/__fixtures__", - "!**/__mocks__" + "!**/__mocks__", + "!**/.*" ], "scripts": { "test": "jest", - "typescript": "tsc --noEmit", + "typecheck": "tsc", "lint": "eslint .", "format": "prettier --write \"**/*.{js,ts,tsx}\"", "format:check": "prettier --check \"**/*.{js,ts,tsx}\"", @@ -103,8 +108,10 @@ "javaPackageName": "com.reactnativepagerview" }, "ios": { - "componentProvider": { - "RNCViewPager": "RNCPagerViewComponentView" + "components": { + "RNCViewPager": { + "className": "RNCPagerViewComponentView" + } } } }, diff --git a/react-native-pager-view.podspec b/react-native-pager-view.podspec index 0ea42a10..d55795ac 100644 --- a/react-native-pager-view.podspec +++ b/react-native-pager-view.podspec @@ -10,7 +10,7 @@ Pod::Spec.new do |s| s.license = package["license"] s.authors = package["author"] - s.platforms = { :ios => "10.0", :visionos => "1.0" } + s.platforms = { :ios => min_ios_version_supported, :visionos => "1.0" } s.source = { :git => "https://github.com/callstack/react-native-pager-view.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,swift}" @@ -18,5 +18,4 @@ Pod::Spec.new do |s| s.dependency "SwiftUIIntrospect", '~> 1.0' install_modules_dependencies(s) - end diff --git a/src/PagerView.tsx b/src/PagerView.tsx index 5bb6401c..08c302a0 100644 --- a/src/PagerView.tsx +++ b/src/PagerView.tsx @@ -7,10 +7,10 @@ import { childrenWithOverriddenStyle } from './utils'; import PagerViewNativeComponent, { Commands as PagerViewNativeCommands, - OnPageScrollEventData, - OnPageScrollStateChangedEventData, - OnPageSelectedEventData, - NativeProps, + type OnPageScrollEventData, + type OnPageScrollStateChangedEventData, + type OnPageSelectedEventData, + type NativeProps, } from './PagerViewNativeComponent'; /** diff --git a/src/utils.ios.tsx b/src/utils.ios.tsx index 7bb5a339..7d00c9ba 100644 --- a/src/utils.ios.tsx +++ b/src/utils.ios.tsx @@ -1,4 +1,4 @@ -import React, { Children, ReactNode } from 'react'; +import React, { Children, type ReactNode } from 'react'; import { StyleSheet, View } from 'react-native'; export const childrenWithOverriddenStyle = ( diff --git a/src/utils.tsx b/src/utils.tsx index bf2367a5..ac4076e9 100644 --- a/src/utils.tsx +++ b/src/utils.tsx @@ -1,4 +1,4 @@ -import React, { Children, ReactNode } from 'react'; +import React, { Children, type ReactNode } from 'react'; import { StyleSheet, View } from 'react-native'; export const childrenWithOverriddenStyle = ( diff --git a/tsconfig.json b/tsconfig.json index b5496c9a..1337c5c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,8 @@ "lib": ["esnext"], "module": "esnext", "moduleResolution": "bundler", - "customConditions": ["react-native"], + "noEmit": true, + "customConditions": ["react-native", "react-native-strict-api"], "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noUncheckedIndexedAccess": true, @@ -23,7 +24,8 @@ "resolveJsonModule": true, "skipLibCheck": true, "strict": true, - "target": "esnext" + "target": "esnext", + "verbatimModuleSyntax": true }, "exclude": ["example", "e2e", "lib"] }