Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions .detoxrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,90 @@
module.exports = {
testRunner: {
args: {
'$0': 'jest',
config: 'e2e/jest.config.js'
$0: 'jest',
config: 'e2e/jest.config.js',
},
jest: {
setupTimeout: 120000
}
setupTimeout: 120000,
},
},
apps: {
'ios.debug': {
start: 'yarn example start',
type: 'ios.app',
binaryPath: 'example/ios/build/Build/Products/Debug-iphonesimulator/SourcepointCmpExample.app',
build: 'xcodebuild -workspace example/ios/SourcepointCmpExample.xcworkspace -scheme SourcepointCmpExample -configuration Debug -sdk iphonesimulator -derivedDataPath example/ios/build'
binaryPath:
'example/ios/build/Build/Products/Debug-iphonesimulator/ReactNativeCmpExample.app',
build:
'xcodebuild -workspace example/ios/ReactNativeCmpExample.xcworkspace -scheme ReactNativeCmpExample -configuration Debug -sdk iphonesimulator -derivedDataPath example/ios/build',
},
'android.debug': {
start: 'yarn example start',
type: 'android.apk',
binaryPath: 'example/android/app/build/outputs/apk/debug/app-debug.apk',
build: 'cd example/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [8081]
build:
'cd example/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug',
reversePorts: [8081],
},
'ios.release': {
type: 'ios.app',
binaryPath: 'example/ios/build/Build/Products/Release-iphonesimulator/SourcepointCmpExample.app',
build: 'xcodebuild -workspace example/ios/SourcepointCmpExample.xcworkspace -scheme SourcepointCmpExample -configuration Release -sdk iphonesimulator -derivedDataPath example/ios/build'
binaryPath:
'example/ios/build/Build/Products/Release-iphonesimulator/ReactNativeCmpExample.app',
build:
'xcodebuild -workspace example/ios/ReactNativeCmpExample.xcworkspace -scheme ReactNativeCmpExample -configuration Release -sdk iphonesimulator -derivedDataPath example/ios/build',
},
'android.release': {
type: 'android.apk',
binaryPath: 'example/android/app/build/outputs/apk/release/app-release.apk',
build: 'cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
reversePorts: [8081]
}
binaryPath:
'example/android/app/build/outputs/apk/release/app-release.apk',
build:
'cd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release',
reversePorts: [8081],
},
},
devices: {
simulator: {
type: 'ios.simulator',
device: {
type: 'iPhone 15'
}
type: 'iPhone 16',
},
},
emulator: {
type: 'android.emulator',
device: {
avdName: 'Pixel_9_API_34'
}
avdName: 'Pixel_9_API_34',
},
},
// attached: {
// type: 'android.attached',
// device: {
// adbName: '.*'
// }
// adbName: '.*',
// },
// },
},
configurations: {
'ios.sim.debug': {
device: 'simulator',
app: 'ios.debug'
app: 'ios.debug',
},
'android.emu.debug': {
device: 'emulator',
app: 'android.debug'
app: 'android.debug',
},
'ios.sim.release': {
device: 'simulator',
app: 'ios.release'
app: 'ios.release',
},
'android.emu.release': {
device: 'emulator',
app: 'android.release'
}
app: 'android.release',
},
// 'android.att.debug': {
// device: 'attached',
// app: 'android.debug'
// app: 'android.debug',
// },
// 'android.att.release': {
// device: 'attached',
// app: 'android.release'
// app: 'android.release',
// },
}
},
};
27 changes: 2 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The [example app](/example/) demonstrates usage of the library. You need to run

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/SourcepointCmpExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > @sourcepoint/react-native-cmp`.
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/ReactNativeCmpExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > @sourcepoint/react-native-cmp`.

To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `sourcepoint-react-native-cmp` under `Android`.

Expand All @@ -47,33 +47,10 @@ To run the example app on iOS:
yarn example ios
```

By default, the example is configured to build with the old architecture. To run the example with the new architecture, you can do the following:

1. For Android, run:

```sh
ORG_GRADLE_PROJECT_newArchEnabled=true yarn example android
```

2. For iOS, run:

```sh
cd example/ios
RCT_NEW_ARCH_ENABLED=1 pod install
cd -
yarn example ios
```

If you are building for a different architecture than your previous build, make sure to remove the build folders first. You can run the following command to cleanup all build folders:

```sh
yarn clean
```

To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:

```sh
Running "SourcepointCmpExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
Running "ReactNativeCmpExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
```

Note the `"fabric":true` and `"concurrentRoot":true` properties.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 André Herculano
Copyright (c) 2025 André Herculano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
Expand Down
23 changes: 23 additions & 0 deletions ReactNativeCmp.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

puts "Min iOS version: #{min_ios_version_supported} (from .podspec)"

Pod::Spec.new do |s|
s.name = "ReactNativeCmp"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/SourcePointUSA/react-native-sourcepoint-cmp.git", :tag => "#{s.version}" }

s.dependency "ConsentViewController", "7.9.0"
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
s.private_header_files = "ios/**/*.h"

install_modules_dependencies(s)
end
72 changes: 18 additions & 54 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,64 +1,38 @@
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["SourcepointCmp_kotlinVersion"]
ext.getExtOrDefault = {name ->
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeCmp_' + name]
}

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
classpath "com.android.tools.build:gradle:8.7.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
}
}

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

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SourcepointCmp_" + name]
}
apply plugin: "com.facebook.react"

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SourcepointCmp_" + 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
return (major == 7 && minor >= 3) || major >= 8
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ReactNativeCmp_" + name]).toInteger()
}

android {
if (supportsNamespace()) {
namespace "com.sourcepoint.reactnativecmp"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}
namespace "com.sourcepoint.reactnativecmp"

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

buildFeatures {
Expand All @@ -82,15 +56,10 @@ android {

sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"src/newarch",
// This is needed to build Kotlin project with NewArch enabled
"${project.buildDir}/generated/source/codegen/java"
]
} else {
java.srcDirs += ["src/oldarch"]
}
java.srcDirs += [
"generated/java",
"generated/jni"
]
}
}
}
Expand All @@ -103,19 +72,14 @@ repositories {
def kotlin_version = getExtOrDefault("kotlinVersion")

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"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

implementation "com.sourcepoint.cmplibrary:cmplibrary:7.8.1"
implementation "com.sourcepoint.cmplibrary:cmplibrary:7.13.0"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "RNSourcepointCmp"
codegenJavaPackageName = "com.sourcepoint.reactnativecmp"
}
react {
jsRootDir = file("../src/")
libraryName = "ReactNativeCmp"
codegenJavaPackageName = "com.sourcepoint.reactnativecmp"
}
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SourcepointCmp_kotlinVersion=1.9.22
SourcepointCmp_minSdkVersion=23
SourcepointCmp_targetSdkVersion=34
SourcepointCmp_compileSdkVersion=34
SourcepointCmp_ndkversion=26.1.10909125
ReactNativeCmp_kotlinVersion=2.0.21
ReactNativeCmp_minSdkVersion=24
ReactNativeCmp_targetSdkVersion=34
ReactNativeCmp_compileSdkVersion=35
ReactNativeCmp_ndkVersion=27.1.12297006
Binary file removed android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 0 additions & 7 deletions android/gradle/wrapper/gradle-wrapper.properties

This file was deleted.

Loading
Loading