Skip to content
Closed
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
15 changes: 14 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def isNewArchitectureEnabled() {
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I was adding support for 0.71 this caused errors regarding duplicate symbols and caused conflicts with other libraries, is this correct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see anything like this to be honest, and if I removed it, it seems like the codegen does not generate specs, so it is necessary 😅 You can see this step here too: https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/back-turbomodule-070#turbomodule-set-up-buildgradle

}

def SQLITE_FLAGS = rootProject.properties['quickSqliteFlags']

apply plugin: 'com.android.library'
Expand Down Expand Up @@ -102,11 +106,20 @@ android {
path "CMakeLists.txt"
}
}


sourceSets.main {
java {
if (!isNewArchitectureEnabled()) {
srcDirs += 'src/paper/java'
}
}
}
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-android:+'
implementation 'com.facebook.react:react-native:+'
}

// Resolves "LOCAL_SRC_FILES points to a missing file, Check that libfb.so exists or that its path is correct".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import androidx.annotation.NonNull;
import android.util.Log;

import com.facebook.jni.HybridData;
import com.facebook.jni.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
import com.facebook.react.module.annotations.ReactModule;

class SequelModule extends ReactContextBaseJavaModule {
@ReactModule(name = SequelModule.NAME)
class SequelModule extends NativeQuickSQLiteModuleSpec {
public static final String NAME = "QuickSQLite";

public SequelModule(ReactApplicationContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,89 @@
import androidx.annotation.NonNull;

import com.facebook.react.ReactPackage;
import com.facebook.react.TurboReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfo;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import com.facebook.react.uimanager.ViewManager;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Nonnull;

public class SequelPackage implements ReactPackage {

@ReactModuleList(
nativeModules = {
SequelModule.class,
})
public class SequelPackage extends TurboReactPackage {
@NonNull
@Override
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactContext) {
return Collections.singletonList(new SequelModule(reactContext));
}

@Override
public NativeModule getModule(String name, @Nonnull ReactApplicationContext reactContext) {
switch (name) {
case SequelModule.NAME:
return new SequelModule(reactContext);
default:
return null;
}
}

@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks complex, I guess it is necessary to register the turbomodule, can you explain a bit what it does? It looks like some kind of description

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look deeper into that method, it is a kind of a description of the module. I didn't debug where it is used exactly though.

try {
Class<?> reactModuleInfoProviderClass =
Class.forName("com.reactnativequicksqlite.SequelPackage$$ReactModuleInfoProvider");
return (ReactModuleInfoProvider) reactModuleInfoProviderClass.newInstance();
} catch (ClassNotFoundException e) {
// ReactModuleSpecProcessor does not run at build-time. Create this ReactModuleInfoProvider by
// hand.
return new ReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();

Class<? extends NativeModule>[] moduleList =
new Class[] {
SequelModule.class,
};

for (Class<? extends NativeModule> moduleClass : moduleList) {
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);

reactModuleInfoMap.put(
reactModule.name(),
new ReactModuleInfo(
reactModule.name(),
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
}

return reactModuleInfoMap;
}
};
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(
"No ReactModuleInfoProvider for com.reactnativequicksqlite.SequelPackage$$ReactModuleInfoProvider", e);
}
}

@NonNull
@Override
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJavaSpec.js
*
* @nolint
*/

package com.reactnativequicksqlite;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReactModuleWithSpec;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;

public abstract class NativeQuickSQLiteModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
public NativeQuickSQLiteModuleSpec(ReactApplicationContext reactContext) {
super(reactContext);
}

@ReactMethod(isBlockingSynchronousMethod = true)
@DoNotStrip
public abstract boolean install();
}
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ FLIPPER_VERSION=0.125.0

reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

newArchEnabled=false
newArchEnabled=true
hermesEnabled=true
2 changes: 2 additions & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, min_ios_version_supported
prepare_react_native_project!

ENV['RCT_NEW_ARCH_ENABLED'] = '1'

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
Expand Down
Loading