Skip to content

Migrate to Kotlin #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 4, 2024
Merged
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -80,6 +80,9 @@ openBrowser("https://swan.io", {
});
```

> [!IMPORTANT]
> On Android, the Chrome app must be opened at least once for this to work — a step often overlooked when using emulators in development.

## Handle deeplinks

In order to receive deeplink on browser close event, you have to setup them first. We **highly** recommand defining a custom schema + url for this specific task. For example, `com.company.myapp://close`.
12 changes: 7 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet("kotlinVersion", "1.8.0")}")
classpath("com.android.tools.build:gradle:7.3.1")
}
}
@@ -16,14 +17,15 @@ def isNewArchitectureEnabled() {
}

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

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

android {
buildToolsVersion safeExtGet("buildToolsVersion", "33.0.0")
compileSdkVersion safeExtGet("compileSdkVersion", 33)
buildToolsVersion safeExtGet("buildToolsVersion", "34.0.0")
compileSdkVersion safeExtGet("compileSdkVersion", 34)

if (project.android.hasProperty("namespace")) {
namespace "io.swan.rnbrowser"
@@ -39,8 +41,8 @@ android {
}
defaultConfig {
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 33)
minSdkVersion safeExtGet("minSdkVersion", 23)
targetSdkVersion safeExtGet("targetSdkVersion", 34)
}
lintOptions {
abortOnError false
@@ -68,5 +70,5 @@ repositories {
dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.browser:browser:${safeExtGet("androidXBrowserVersion", "1.5.0")}"
implementation "androidx.browser:browser:${safeExtGet("androidXBrowserVersion", "1.8.0")}"
}

This file was deleted.

105 changes: 105 additions & 0 deletions android/src/main/java/io/swan/rnbrowser/RNSwanBrowserModuleImpl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package io.swan.rnbrowser

import android.content.Intent
import android.net.Uri

import androidx.annotation.ColorInt
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.content.ContextCompat
import androidx.core.graphics.ColorUtils

import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter

import io.swan.rnbrowser.helpers.CustomTabActivityHelper

object RNSwanBrowserModuleImpl {
const val NAME = "RNSwanBrowser"
private var browserVisible = false

internal fun onHostResume(reactContext: ReactApplicationContext) {
if (browserVisible && reactContext.hasActiveReactInstance()) {
browserVisible = false

reactContext
.getJSModule(RCTDeviceEventEmitter::class.java)
.emit("swanBrowserDidClose", null)
}
}

internal fun open(
reactContext: ReactApplicationContext,
url: String,
options: ReadableMap,
promise: Promise
) {
if (browserVisible) {
return promise.reject(
"swan_browser_visible",
"An instance of the swan browser is already visible"
)
}

val activity = reactContext.currentActivity
?: return promise.reject(
"no_current_activity",
"Couldn't call open() when the app is in background"
)

browserVisible = true

val intentBuilder = CustomTabsIntent.Builder().apply {
setBookmarksButtonEnabled(false)
setDownloadButtonEnabled(false)
setInstantAppsEnabled(false)
setSendToExternalDefaultHandlerEnabled(false)
setShowTitle(false)

if (options.getString("animationType") == "fade") {
setStartAnimations(activity, com.facebook.react.R.anim.catalyst_fade_in, R.anim.inert)
setExitAnimations(activity, R.anim.inert, com.facebook.react.R.anim.catalyst_fade_out)
} else {
setStartAnimations(activity, com.facebook.react.R.anim.catalyst_slide_up, R.anim.inert)
setExitAnimations(activity, R.anim.inert, com.facebook.react.R.anim.catalyst_slide_down)
}
}

@ColorInt val blackColor = ContextCompat.getColor(activity ,android.R.color.black)

val paramsBuilder = CustomTabColorSchemeParams.Builder().apply {
setNavigationBarColor(blackColor)

if (options.hasKey("barTintColor")) {
@ColorInt val barTintColor = options.getInt("barTintColor")

setToolbarColor(barTintColor)
setSecondaryToolbarColor(barTintColor)

intentBuilder.setColorScheme(
when (ColorUtils.calculateLuminance(barTintColor) > 0.5) {
true -> CustomTabsIntent.COLOR_SCHEME_LIGHT
false -> CustomTabsIntent.COLOR_SCHEME_DARK
}
)
}
}

intentBuilder.setDefaultColorSchemeParams(paramsBuilder.build())

val customTabsIntent = intentBuilder.build().apply {
intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
}

CustomTabActivityHelper.openCustomTab(
activity, customTabsIntent, Uri.parse(url)
) { currentActivity, uri ->
currentActivity.startActivity(Intent(Intent.ACTION_VIEW, uri))
}

promise.resolve(null)
}
}
47 changes: 0 additions & 47 deletions android/src/main/java/io/swan/rnbrowser/RNSwanBrowserPackage.java

This file was deleted.

37 changes: 37 additions & 0 deletions android/src/main/java/io/swan/rnbrowser/RNSwanBrowserPackage.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.swan.rnbrowser

import com.facebook.react.TurboReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider

class RNSwanBrowserPackage : TurboReactPackage() {

override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return when (name) {
RNSwanBrowserModuleImpl.NAME -> RNSwanBrowserModule(reactContext)
else -> null
}
}

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
return ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED

val moduleInfo = ReactModuleInfo(
RNSwanBrowserModuleImpl.NAME,
RNSwanBrowserModuleImpl.NAME,
false,
false,
true,
false,
isTurboModule
)

moduleInfos[RNSwanBrowserModuleImpl.NAME] = moduleInfo
moduleInfos
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/GoogleChrome/android-browser-helper/blob/master/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/CustomTabActivityHelper.java
// https://github.com/GoogleChrome/android-browser-helper/blob/main/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/CustomTabActivityHelper.java
//
// Copyright 2015 Google Inc. All Rights Reserved.
//
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/GoogleChrome/android-browser-helper/blob/master/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/CustomTabsHelper.java
// https://github.com/GoogleChrome/android-browser-helper/blob/main/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/CustomTabsHelper.java
//
// Copyright 2015 Google Inc. All Rights Reserved.
//
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/GoogleChrome/android-browser-helper/blob/master/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnection.java
// https://github.com/GoogleChrome/android-browser-helper/blob/main/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnection.java
//
// Copyright 2015 Google Inc. All Rights Reserved.
//
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/GoogleChrome/android-browser-helper/blob/master/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionCallback.java
// https://github.com/GoogleChrome/android-browser-helper/blob/main/demos/custom-tabs-example-app/src/main/java/org/chromium/customtabsdemos/ServiceConnectionCallback.java
//
// Copyright 2015 Google Inc. All Rights Reserved.
//
83 changes: 0 additions & 83 deletions android/src/newarch/io/swan/rnbrowser/RNSwanBrowserModule.java

This file was deleted.

49 changes: 49 additions & 0 deletions android/src/newarch/io/swan/rnbrowser/RNSwanBrowserModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.swan.rnbrowser

import com.facebook.react.bridge.LifecycleEventListener
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.module.annotations.ReactModule

@ReactModule(name = RNSwanBrowserModuleImpl.NAME)
class RNSwanBrowserModule(reactContext: ReactApplicationContext) :
NativeRNSwanBrowserSpec(reactContext),
LifecycleEventListener {

init {
reactApplicationContext.addLifecycleEventListener(this)
}

override fun invalidate() {
reactApplicationContext.removeLifecycleEventListener(this)
}

override fun getName(): String {
return RNSwanBrowserModuleImpl.NAME
}

override fun onHostResume() {
RNSwanBrowserModuleImpl.onHostResume(reactApplicationContext)
}

override fun onHostPause() {}

override fun onHostDestroy() {}

override fun open(url: String, options: ReadableMap, promise: Promise) {
RNSwanBrowserModuleImpl.open(reactApplicationContext, url, options, promise)
}

override fun close() {
// noop on Android since the modal is closed by deep-link
}

override fun addListener(eventName: String) {
// iOS only
}

override fun removeListeners(count: Double) {
// iOS only
}
}
85 changes: 0 additions & 85 deletions android/src/oldarch/io/swan/rnbrowser/RNSwanBrowserModule.java

This file was deleted.

55 changes: 55 additions & 0 deletions android/src/oldarch/io/swan/rnbrowser/RNSwanBrowserModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package io.swan.rnbrowser

import com.facebook.react.bridge.LifecycleEventListener
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.module.annotations.ReactModule

@ReactModule(name = RNSwanBrowserModuleImpl.NAME)
class RNSwanBrowserModule(reactContext: ReactApplicationContext) :
ReactContextBaseJavaModule(reactContext),
LifecycleEventListener {

init {
reactApplicationContext.addLifecycleEventListener(this)
}

override fun invalidate() {
reactApplicationContext.removeLifecycleEventListener(this)
}

override fun getName(): String {
return RNSwanBrowserModuleImpl.NAME
}

override fun onHostResume() {
RNSwanBrowserModuleImpl.onHostResume(reactApplicationContext)
}

override fun onHostPause() {}

override fun onHostDestroy() {}

@ReactMethod
fun open(url: String, options: ReadableMap, promise: Promise) {
RNSwanBrowserModuleImpl.open(reactApplicationContext, url, options, promise)
}

@ReactMethod
fun close() {
// noop on Android since the modal is closed by deep-link
}

@ReactMethod
fun addListener(eventName: String) {
// iOS only
}

@ReactMethod
fun removeListeners(count: Double) {
// iOS only
}
}
8 changes: 4 additions & 4 deletions example/Gemfile
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem 'cocoapods', '>= 1.13', '< 1.15'
gem 'activesupport', '>= 6.1.7.5', '< 7.1.0'
# Exclude problematic versions of cocoapods and activesupport that causes build failures.
gem 'cocoapods', '>= 1.13', '!= 1.15.0', '!= 1.15.1'
gem 'activesupport', '>= 6.1.7.5', '!= 7.1.0'
gem 'xcodeproj', '< 1.26.0'
48 changes: 30 additions & 18 deletions example/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -5,23 +5,32 @@ GEM
base64
nkf
rexml
activesupport (7.0.8.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
activesupport (7.2.2)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
benchmark (0.3.0)
bigdecimal (3.1.8)
claide (1.1.0)
cocoapods (1.14.3)
cocoapods (1.15.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.14.3)
cocoapods-core (= 1.15.2)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 2.1, < 3.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
@@ -36,7 +45,7 @@ GEM
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.14.3)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
@@ -56,7 +65,9 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
@@ -65,41 +76,42 @@ GEM
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.5)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
json (2.7.2)
minitest (5.24.1)
json (2.7.5)
logger (1.6.1)
minitest (5.25.1)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.2.9)
strscan
rexml (3.3.9)
ruby-macho (2.5.1)
strscan (3.1.0)
securerandom (0.3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.24.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.6, < 4.0)

PLATFORMS
ruby

DEPENDENCIES
activesupport (>= 6.1.7.5, < 7.1.0)
cocoapods (>= 1.13, < 1.15)
activesupport (>= 6.1.7.5, != 7.1.0)
cocoapods (>= 1.13, != 1.15.1, != 1.15.0)
xcodeproj (< 1.26.0)

RUBY VERSION
ruby 3.3.4p94

BUNDLED WITH
2.5.14
2.5.18
21 changes: 11 additions & 10 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -8,14 +8,14 @@ apply plugin: "com.facebook.react"
*/
react {
/* 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 cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
// 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 cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")

/* Variants */
// The list of variants to that are debuggable. For those we're going to
@@ -49,6 +49,9 @@ 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()
}

/**
@@ -114,5 +117,3 @@ dependencies {
implementation jscFlavor
}
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:supportsRtl="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader

class MainApplication : Application(), ReactApplication {
@@ -34,7 +35,7 @@ class MainApplication : Application(), ReactApplication {

override fun onCreate() {
super.onCreate()
SoLoader.init(this, false)
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
8 changes: 4 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext {
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
kotlinVersion = "1.9.24"
}
repositories {
google()
4 changes: 1 addition & 3 deletions example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -21,8 +21,6 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=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
@@ -34,7 +32,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.
Binary file modified example/android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
7 changes: 5 additions & 2 deletions example/android/gradlew
Original file line number Diff line number Diff line change
@@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
@@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,8 @@ 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
2 changes: 2 additions & 0 deletions example/android/gradlew.bat
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
4 changes: 3 additions & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
rootProject.name = 'RNSwanBrowserExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
988 changes: 694 additions & 294 deletions example/ios/Podfile.lock

Large diffs are not rendered by default.

37 changes: 13 additions & 24 deletions example/ios/RNSwanBrowserExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
8F983DC716006D6B741C5711 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = BA3AA277F4F3F63D43863DAB /* PrivacyInfo.xcprivacy */; };
C9E7E9882C1A138B397FDFE8 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
@@ -22,11 +22,11 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = RNSwanBrowserExample/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = RNSwanBrowserExample/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RNSwanBrowserExample/main.m; sourceTree = "<group>"; };
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = RNSwanBrowserExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
3B4392A12AC88292D35C810B /* Pods-RNSwanBrowserExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSwanBrowserExample.debug.xcconfig"; path = "Target Support Files/Pods-RNSwanBrowserExample/Pods-RNSwanBrowserExample.debug.xcconfig"; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-RNSwanBrowserExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNSwanBrowserExample.release.xcconfig"; path = "Target Support Files/Pods-RNSwanBrowserExample/Pods-RNSwanBrowserExample.release.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-RNSwanBrowserExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNSwanBrowserExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = RNSwanBrowserExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
BA3AA277F4F3F63D43863DAB /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; name = PrivacyInfo.xcprivacy; path = RNSwanBrowserExample/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */

@@ -51,7 +51,7 @@
13B07FB61A68108700A75B9A /* Info.plist */,
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
13B07FB71A68108700A75B9A /* main.m */,
BA3AA277F4F3F63D43863DAB /* PrivacyInfo.xcprivacy */,
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
);
name = RNSwanBrowserExample;
sourceTree = "<group>";
@@ -165,7 +165,7 @@
files = (
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
8F983DC716006D6B741C5711 /* PrivacyInfo.xcprivacy in Resources */,
C9E7E9882C1A138B397FDFE8 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -266,9 +266,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 96LKQQBWG7;
DEVELOPMENT_TEAM = 96N32AGSJN;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = RNSwanBrowserExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -294,8 +295,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 96LKQQBWG7;
DEVELOPMENT_TEAM = 96N32AGSJN;
INFOPLIST_FILE = RNSwanBrowserExample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -317,7 +319,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CC = "";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
@@ -345,7 +346,6 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
CXX = "";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
@@ -364,9 +364,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
LD = "";
LDPLUSPLUS = "";
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
@@ -386,12 +384,10 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
};
name = Debug;
@@ -400,7 +396,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CC = "";
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "c++20";
CLANG_CXX_LIBRARY = "libc++";
@@ -428,7 +423,6 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
CXX = "";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
@@ -440,9 +434,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
LD = "";
LDPLUSPLUS = "";
IPHONEOS_DEPLOYMENT_TARGET = 15.1;
LD_RUNPATH_SEARCH_PATHS = (
/usr/lib/swift,
"$(inherited)",
@@ -461,10 +453,7 @@
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
);
OTHER_LDFLAGS = (
"$(inherited)",
" ",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = true;
23 changes: 13 additions & 10 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -14,20 +14,23 @@
},
"dependencies": {
"@swan-io/react-native-browser": "link:../",
"react": "18.2.0",
"react-native": "0.74.3",
"react": "18.3.1",
"react-native": "0.76.1",
"url-parse": "1.5.10"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.74.85",
"@react-native/metro-config": "0.74.85",
"@types/react": "^18.2.60",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "15.0.0",
"@react-native-community/cli-platform-android": "15.0.0",
"@react-native-community/cli-platform-ios": "15.0.0",
"@react-native/babel-preset": "0.76.1",
"@react-native/metro-config": "0.76.1",
"@types/react": "^18.2.6",
"@types/url-parse": "^1.4.11",
"babel-plugin-module-resolver": "^5.0.2",
"serve": "^14.2.3",
"typescript": "^5.5.3"
"serve": "^14.2.4",
"typescript": "^5.6.3"
}
}
3,102 changes: 1,630 additions & 1,472 deletions example/yarn.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swan-io/react-native-browser",
"version": "0.3.1",
"version": "0.4.0",
"license": "MIT",
"description": "An easy-to-use in-app browser module for React Native.",
"author": "Mathieu Acthernoene <mathieu.acthernoene@swan.io>",
@@ -65,14 +65,14 @@
"react-native": ">=0.70.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@types/react": "^18.2.60",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@types/react": "^18.2.6",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"react": "18.2.0",
"react-native": "0.74.3",
"react-native-builder-bob": "^0.26.0",
"typescript": "^5.5.3"
"prettier-plugin-organize-imports": "^4.1.0",
"react": "18.3.1",
"react-native": "0.76.1",
"react-native-builder-bob": "^0.30.3",
"typescript": "^5.6.3"
}
}
3,748 changes: 1,728 additions & 2,020 deletions yarn.lock

Large diffs are not rendered by default.