Skip to content

Commit

Permalink
chore: upgrade react native in example app
Browse files Browse the repository at this point in the history
  • Loading branch information
aliberski committed Jan 30, 2025
1 parent c87ea72 commit 23fd12c
Show file tree
Hide file tree
Showing 113 changed files with 6,580 additions and 5,091 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
matrix:
configurations:
[
{ react_native_version: '0.72.6', node_version: 18 },
{ react_native_version: '0.71.14', node_version: 18 },
{ react_native_version: '0.70.13', node_version: 18 }
{ react_native_version: '0.77.0', node_version: 18 },
{ react_native_version: '0.76.6', node_version: 18 },
{ react_native_version: '0.75.4', node_version: 18 }
]
env:
TURBO_CACHE_DIR: .turbo/android
Expand Down Expand Up @@ -116,9 +116,9 @@ jobs:
matrix:
configurations:
[
{ react_native_version: '0.72.6', node_version: 18 },
{ react_native_version: '0.71.14', node_version: 18 },
{ react_native_version: '0.70.13', node_version: 18 }
{ react_native_version: '0.77.0', node_version: 18 },
{ react_native_version: '0.76.6', node_version: 18 },
{ react_native_version: '0.75.4', node_version: 18 }
]
env:
TURBO_CACHE_DIR: .turbo/ios
Expand Down
2 changes: 1 addition & 1 deletion __tests__/BleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ test('BleManager properly monitors characteristic value', async () => {
subscription.remove()
expect(listener).toHaveBeenCalledTimes(2)
expect(Native.BleModule.cancelTransaction).toBeCalledWith('x')
expect(Native.BleModule.monitorCharacteristicForDevice).toBeCalledWith('id', 'aaaa', 'bbbb', 'x')
expect(Native.BleModule.monitorCharacteristicForDevice).toBeCalledWith('id', 'aaaa', 'bbbb', 'x', undefined)
})

test('BleManager properly handles errors while monitoring characteristic values', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Characteristic.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Test if Characteristic is properly calling BleManager's utility functi
test('monitor', async () => {
const listener = jest.fn()
await characteristic.monitor(listener, 'id')
expect(bleManager._monitorCharacteristic).toBeCalledWith('cId', listener, 'id')
expect(bleManager._monitorCharacteristic).toBeCalledWith('cId', listener, 'id', undefined)
})

test('readDescriptor', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe("Test if Device is properly calling BleManager's utility function:", ()
test('monitorCharacteristicForService', async () => {
const listener = jest.fn()
await device.monitorCharacteristicForService('aaaa', 'bbbb', listener, 'id')
expect(bleManager.monitorCharacteristicForDevice).toBeCalledWith('id', 'aaaa', 'bbbb', listener, 'id')
expect(bleManager.monitorCharacteristicForDevice).toBeCalledWith('id', 'aaaa', 'bbbb', listener, 'id', undefined)
})

test('readDescriptorForService', async () => {
Expand Down
2 changes: 1 addition & 1 deletion __tests__/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("Test if Service is properly calling BleManager's utility function:", (
test('monitorCharacteristic', async () => {
const listener = jest.fn()
await service.monitorCharacteristic('bbbb', listener, 'id')
expect(bleManager._monitorCharacteristicForService).toBeCalledWith('serviceId', 'bbbb', listener, 'id')
expect(bleManager._monitorCharacteristicForService).toBeCalledWith('serviceId', 'bbbb', listener, 'id', undefined)
})

test('readDescriptorForCharacteristic', async () => {
Expand Down
42 changes: 0 additions & 42 deletions example-expo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,3 @@ yarn-error.*

# typescript
*.tsbuildinfo

# @generated expo-cli sync-8d4afeec25ea8a192358fae2f8e2fc766bdce4ec
# The following patterns were generated by expo-cli

# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts

# Native
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

# @end expo-cli
10 changes: 2 additions & 8 deletions example-expo/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import React from 'react'
import { View, Text } from 'react-native'
// import { AppComponent } from './src/AppComponent'
import { AppComponent } from './src/AppComponent'

export function App() {
// return <AppComponent />
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>TEST</Text>
</View>
)
return <AppComponent />
}
22 changes: 9 additions & 13 deletions example-expo/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ react {
bundleCommand = "export:embed"

/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
Expand Down Expand Up @@ -57,9 +57,6 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]

/* Autolinking */
autolinkLibrariesWithApp()
}

/**
Expand Down Expand Up @@ -113,17 +110,13 @@ android {
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
crunchPngs (findProperty('android.enablePngCrunchInReleaseBuilds')?.toBoolean() ?: true)
}
}
packagingOptions {
jniLibs {
useLegacyPackaging (findProperty('expo.useLegacyPackaging')?.toBoolean() ?: false)
}
}
androidResources {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}

// Apply static values from `gradle.properties` to the `android.packagingOptions`
Expand Down Expand Up @@ -174,3 +167,6 @@ dependencies {
implementation jscFlavor
}
}

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
12 changes: 3 additions & 9 deletions example-expo/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.withintent.bleplxexample" xmlns:tools="http://schemas.android.com/tools">
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" tools:targetApi="31"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="https"/>
</intent>
</queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:supportsRtl="true">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
Expand All @@ -34,5 +27,6 @@
<data android:scheme="com.withintent.bleplxexample"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" android:exported="false"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.facebook.react.ReactPackage
import com.facebook.react.ReactHost
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

import expo.modules.ApplicationLifecycleDispatcher
Expand All @@ -22,10 +21,9 @@ class MainApplication : Application(), ReactApplication {
this,
object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> {
val packages = PackageList(this).packages
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages
return PackageList(this).packages
}

override fun getJSMainModuleName(): String = ".expo/.virtual-metro-entry"
Expand All @@ -42,7 +40,7 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, OpenSourceMergedSoMapping)
SoLoader.init(this, false)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
3 changes: 1 addition & 2 deletions example-expo/android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="android:statusBarColor">#ffffff</item>
</style>
<style name="ResetEditText" parent="@android:style/Widget.EditText">
<item name="android:padding">0dp</item>
<item name="android:textColorHint">#c8c8c8</item>
<item name="android:textColor">@android:color/black</item>
</style>
<style name="Theme.App.SplashScreen" parent="AppTheme">
<item name="android:windowBackground">@drawable/ic_launcher_background</item>
<item name="android:windowBackground">@drawable/splashscreen</item>
</style>
</resources>
8 changes: 4 additions & 4 deletions example-expo/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

buildscript {
ext {
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '35.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '24')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '35')
buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0'
minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23')
compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34')
targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34')
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.24'
kotlinVersion = findProperty('android.kotlinVersion') ?: '1.9.23'

ndkVersion = "26.1.10909125"
}
Expand Down
6 changes: 2 additions & 4 deletions example-expo/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true

# Enable AAPT2 PNG crunching
android.enablePngCrunchInReleaseBuilds=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
Expand Down Expand Up @@ -54,5 +54,3 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true

# Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false

expo.jsEngine=jsc
Binary file modified example-expo/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 2 additions & 5 deletions example-expo/android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -86,8 +84,7 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
26 changes: 3 additions & 23 deletions example-expo/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
pluginManagement {
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile().toString())
}
plugins { id("com.facebook.react.settings") }

extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
ex.autolinkLibrariesFromCommand()
} else {
def command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'android'
].toList()
ex.autolinkLibrariesFromCommand(command)
}
}

rootProject.name = 'example-expo'

dependencyResolutionManagement {
Expand All @@ -34,5 +11,8 @@ dependencyResolutionManagement {
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle");
useExpoModules()

apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'
includeBuild(new File(["node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })"].execute(null, rootDir).text.trim()).getParentFile())
3 changes: 1 addition & 2 deletions example-expo/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
},
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.withintent.bleplxexample",
"appleTeamId": "RF945WPAGS"
"bundleIdentifier": "com.withintent.bleplxexample"
},
"android": {
"adaptiveIcon": {
Expand Down
8 changes: 0 additions & 8 deletions example-expo/index.js

This file was deleted.

Loading

0 comments on commit 23fd12c

Please sign in to comment.