diff --git a/ios/DetectFrida.mm b/ios/DetectFrida.mm index f442080..4157a2e 100644 --- a/ios/DetectFrida.mm +++ b/ios/DetectFrida.mm @@ -2,6 +2,8 @@ #import "JailBrokenHelper.h" @implementation DetectFrida + + RCT_EXPORT_MODULE() // Example method @@ -47,6 +49,18 @@ - (BOOL)isJailBroken { RCT_REMAP_METHOD(isJailBroken, isJailBrokenWithResolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + [self isJailBroken: resolve reject:reject]; +} + +RCT_EXPORT_METHOD(closeAppAfterDelay:(double)delay) { + [self closeApp:delay]; +} + +- (void)detectRoot:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject { + reject(@"-1", @"This function is only for Android", nil); +} + +- (void)isJailBroken:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject { @try { BOOL isJailBroken = [self isJailBroken]; resolve(@{@"isRooted": @(isJailBroken)}); @@ -57,10 +71,11 @@ - (BOOL)isJailBroken { } } -RCT_EXPORT_METHOD(closeAppAfterDelay:(double)delay) { - [self closeApp:delay]; -} - +#ifdef RCT_NEW_ARCH_ENABLED +- (std::shared_ptr)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params { + return std::make_shared(params); +} +#endif @end diff --git a/package.json b/package.json index 5d9bdd8..2ba4113 100644 --- a/package.json +++ b/package.json @@ -166,13 +166,13 @@ "name": "RNDetectFridaSpec", "type": "modules", "jsSrcsDir": "src", - "outputDir": { - "ios": "ios/generated", - "android": "android/generated" - }, - "includesGeneratedCode": true, "android": { "javaPackageName": "com.detectfrida" + }, + "ios": { + "modulesProvider": { + "DetectFrida": "DetectFrida" + } } } } diff --git a/react-native-detect-frida.podspec b/react-native-detect-frida.podspec index df153b1..7b8c3be 100644 --- a/react-native-detect-frida.podspec +++ b/react-native-detect-frida.podspec @@ -15,7 +15,6 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/imanshul/react-native-detect-frida.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm,cpp}" - s.private_header_files = "ios/generated/**/*.h" # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0. # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79. diff --git a/src/NativeDetectFrida.ts b/src/NativeDetectFrida.ts index c08592b..8485851 100644 --- a/src/NativeDetectFrida.ts +++ b/src/NativeDetectFrida.ts @@ -1,4 +1,4 @@ -import type { TurboModule } from 'react-native'; +import { type TurboModule } from 'react-native'; import { TurboModuleRegistry } from 'react-native'; export interface Spec extends TurboModule { @@ -21,4 +21,4 @@ export interface Spec extends TurboModule { closeAppAfterDelay?(delay: number): void; } -export default TurboModuleRegistry.getEnforcing('DetectFrida'); +export default TurboModuleRegistry.get('DetectFrida'); diff --git a/src/index.tsx b/src/index.tsx index 9078e1c..fb74b5b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,22 +1,10 @@ import { NativeModules, Platform } from 'react-native'; import type { RootCheckResult } from './ValueTypes'; +import NativeDetectFrida from './NativeDetectFrida'; -const LINKING_ERROR = - `The package 'react-native-detect-frida' doesn't seem to be linked. Make sure: \n\n` + - Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) + - '- You rebuilt the app after installing the package\n' + - '- You are not using Expo Go\n'; - -const DetectFrida = NativeModules.DetectFrida - ? NativeModules.DetectFrida - : new Proxy( - {}, - { - get() { - throw new Error(LINKING_ERROR); - }, - } - ); +const DetectFrida = NativeDetectFrida + ? NativeDetectFrida + : NativeModules.DetectFrida; const isAndroid = () => { return Platform.OS === 'android';