Skip to content

Commit

Permalink
Merge pull request #208 from Giphy/feat/drop-old-rn-support
Browse files Browse the repository at this point in the history
feat!: drop support for React Native <0.73.0
  • Loading branch information
ALexanderLonsky authored Feb 3, 2025
2 parents abf0de2 + 88b8402 commit 6a78471
Show file tree
Hide file tree
Showing 24 changed files with 3,435 additions and 1,522 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ inputs:
description: 'Set up JDK environment'
required: false
java-version:
default: '13.0.13'
default: '17'
description: 'Java version'
required: false
node-version:
Expand Down
45 changes: 0 additions & 45 deletions android/Android.mk

This file was deleted.

88 changes: 13 additions & 75 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
classpath "com.android.tools.build:gradle:8.1.0"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
Expand All @@ -19,30 +19,17 @@ apply plugin: "kotlin-android"

import groovy.json.JsonSlurper

// https://github.com/callstack/react-native-builder-bob/discussions/359
def registrationCompat = {
def reactNativeVersion = {
def reactNativeManifest = file("$projectDir/../node_modules/react-native/package.json").exists()
? file("$projectDir/../node_modules/react-native/package.json") // developer mode, to run example app
: file("$projectDir/../../../react-native/package.json")
def reactNativeVersion = new JsonSlurper().parseText(reactNativeManifest.text).version as String
// Fabric was introduced at [email protected], full CMake support were introduced at [email protected]
// Use Android.mk for compatibility with [email protected]/0.69
reactNativeVersion.matches('(0.68.*|0.69.*)')
}()

def codegenViewLibraryName = "GiphyReactNativeSDK"
def codegenViewModuleName = {
// Autolink for Fabric uses codegenConfig.name in package.json since [email protected]
// Use codegenViewLibraryName for compatibility with [email protected]/0.69
def libraryManifestJson = new JsonSlurper().parseText(file("$projectDir/../package.json").text)
registrationCompat ? codegenViewLibraryName : libraryManifestJson.codegenConfig.name
new JsonSlurper().parseText(reactNativeManifest.text).version as String
}()

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
Expand All @@ -61,65 +48,19 @@ def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["GiphyReactNativeSDK." + name]).toInteger()
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
}

android {
if (supportsNamespace()) {
namespace "com.giphyreactnativesdk"
} else {
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestDeprecated.xml"
}
}
}
android {
buildFeatures {
buildConfig = true
}

namespace "com.giphyreactnativesdk"

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "String", "CODEGEN_MODULE_REGISTRATION", (isNewArchitectureEnabled() && registrationCompat ? "\"${codegenViewModuleName}_registration\"" : "null")

if (isNewArchitectureEnabled() && registrationCompat) {
def reactAndroidProject = project(':ReactAndroid')
externalNativeBuild {
ndkBuild {
arguments "APP_PLATFORM=android-21",
"APP_STL=c++_shared",
"NDK_TOOLCHAIN_VERSION=clang",
"GENERATED_SRC_DIR=$buildDir/generated/source", // for react_codegen_* in this library's codegen/jni
"PROJECT_BUILD_DIR=${appProject.buildDir}", // for REACT_NDK_EXPORT_DIR in ReactAndroid's Android-prebuilt.mk
"REACT_ANDROID_DIR=${reactAndroidProject.projectDir}",
"REACT_ANDROID_BUILD_DIR=${reactAndroidProject.buildDir}",
"CODEGEN_MODULE_NAME=$codegenViewModuleName"
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
cppFlags "-std=c++17"
targets "${codegenViewModuleName}_registration"
}
}
}
}

if (isNewArchitectureEnabled() && registrationCompat) {
// We configure the NDK build only if you decide to opt-in for the New Architecture.
externalNativeBuild {
ndkBuild {
path "Android.mk"
}
}
}

buildTypes {
Expand All @@ -133,8 +74,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

sourceSets {
Expand Down Expand Up @@ -197,12 +138,9 @@ task configureGiphyVideoPlayerAdapter {
preBuild.dependsOn configureGiphyVideoPlayerAdapter

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "com.facebook.react:react-android:$reactNativeVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.giphy.sdk:ui:2.3.15-fresco-v2.5.0'
implementation 'com.giphy.sdk:ui:2.3.16'
}

if (isNewArchitectureEnabled()) {
Expand Down
7 changes: 4 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Fri May 07 15:08:27 EEST 2021
GiphyReactNativeSDK.kotlinVersion=1.7.0
GiphyReactNativeSDK.kotlinVersion=1.9.0
GiphyReactNativeSDK.minSdkVersion=21
GiphyReactNativeSDK.targetSdkVersion=31
GiphyReactNativeSDK.compileSdkVersion=31
GiphyReactNativeSDK.targetSdkVersion=34
GiphyReactNativeSDK.compileSdkVersion=34
GiphyReactNativeSDK.ndkversion=21.4.7075529
android.useAndroidX=true
android.enableJetifier=true
org.gradle.jvmargs=-Xmx4g
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 1 addition & 4 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.giphyreactnativesdk">

</manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
7 changes: 0 additions & 7 deletions android/src/newarch/RTNGiphyGridViewManagerSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@ abstract class RTNGiphyGridViewManagerSpec<T : View> : SimpleViewManager<T>(),
return mDelegate
}

companion object {
init {
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
}
}
}
}
7 changes: 0 additions & 7 deletions android/src/newarch/RTNGiphyMediaViewManagerSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@ abstract class RTNGiphyMediaViewManagerSpec<T : View> : SimpleViewManager<T>(),
return mDelegate
}

companion object {
init {
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
}
}
}
}
7 changes: 0 additions & 7 deletions android/src/newarch/RTNGiphyVideoViewManagerSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,4 @@ abstract class RTNGiphyVideoViewManagerSpec<T : View> : SimpleViewManager<T>(),
return mDelegate
}

companion object {
init {
if (BuildConfig.CODEGEN_MODULE_REGISTRATION != null) {
SoLoader.loadLibrary(BuildConfig.CODEGEN_MODULE_REGISTRATION)
}
}
}
}
11 changes: 5 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,15 @@ may be helpful if you experience issues linking your iOS project.
If you encounter an issue where GIFs appear as static images instead of animating, this may be due to a dependency conflict between
React Native and the Fresco library used by our SDK.

By default, our SDK references our Android SDK, which uses Fresco version 2.5.0. However, as of React Native 0.73.0,
the default Fresco version is 3.1.3.
By default, our SDK versions below 3.3.2 use Fresco 2.5.0, while React Native 0.73.0 and above defaults to a newer Fresco version.

Developers using our SDK with React Native versions from 0.73 up to but not including 0.76 can resolve this conflict
by adding the following block to the `android/build.gradle` file in the `:app module`,
right before the `dependencies` section:
If you are using our SDK below 3.3.2 and React Native below 0.73.0, follow the configurations to resolve potential conflicts:

For React Native 0.73 up to (but not including) 0.76, add this block to android/build.gradle(:app) before `dependencies`:
```gradle
configurations.all {
resolutionStrategy {
forcedModules = ['com.giphy.sdk:ui:2.3.13']
forcedModules = ['com.giphy.sdk:ui:2.3.15']
}
}
```
Expand All @@ -109,6 +107,7 @@ configurations.configureEach {
}
```

However, if you are using our SDK version 3.3.2 or later, there is no need for any manual Fresco configuration. Our latest SDK version fully supports React Native starting from 0.73.0, ensuring compatibility with the correct Fresco version.

#### Feel free to open an [issue](https://github.com/Giphy/giphy-react-native-sdk/issues) here in this repo if you run into any problems.

Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
</intent-filter>
</activity>
<activity
android:name="com.facebook.react.devsupport.DevSettingsActivity"
android:exported="true" />
android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
</application>

</manifest>
6 changes: 3 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import com.github.jk1.license.render.JsonReportRenderer

buildscript {
ext {
buildToolsVersion = "33.0.0"
buildToolsVersion = "34.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
compileSdkVersion = 34
targetSdkVersion = 34

// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=true
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
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.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions example/ios/.xcode.env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export NODE_BINARY=/opt/homebrew/bin/node

14 changes: 8 additions & 6 deletions example/ios/GiphyReactNativeSdkExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-GiphyReactNativeSdkExample/Pods-GiphyReactNativeSdkExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -357,11 +357,11 @@
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-GiphyReactNativeSdkExample-GiphyReactNativeSdkExampleTests/Pods-GiphyReactNativeSdkExample-GiphyReactNativeSdkExampleTests-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/RCTI18nStrings.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCTI18nStrings.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand Down Expand Up @@ -545,7 +545,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down Expand Up @@ -614,6 +614,7 @@
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
};
name = Debug;
};
Expand All @@ -622,7 +623,7 @@
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++17";
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
Expand Down Expand Up @@ -686,6 +687,7 @@
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
Loading

0 comments on commit 6a78471

Please sign in to comment.