how can i integrate third party ios libraries into react native app?

Just implement a custom Native Module for iOS. Copy-paste working code and wrap it with RCT_EXPORT_METHOD and use resolvers to return a value.

And you need to name module somehow, so you’ll get something like:

@implementation UnTar


RCT_EXPORT_METHOD((untarFileAtPath:(NSDictionary *)fields
    NSString *tarFilePath = [RCTConvert NSString:fields[@"tarFilePath"]];
    NSString *destinationPath = [RCTConvert NSString:fields[@"destinationPath"]];
    NSFileManager *manager = [NSFileManager defaultManager];
    if([manager fileExistsAtPath:tarFilePath]) {
        NSDictionary *attributes = [manager attributesOfItemAtPath:tarFilePath error:nil];
        unsigned long long size = [attributes[NSFileSize] longLongValue];
        NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:tarFilePath];
        resolve([self untarObject:fileHandle size:size toPath:path error:error]);
        *error = [self errorWithDetail:@"tar file not found" code:-2];


In React-Native:

import { NativeModules } from 'react-native'
NativeModules.UnTar.untarFileAtPath({ tarFilePath, destinationPath })

I didn’t run a code, so use it as a guide ) I’ll try to 100% working code later, but I need to get all libraries in a place.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top