Skip to content

Instantly share code, notes, and snippets.

@joeporpeglia
Created September 14, 2023 21:05
Show Gist options
  • Save joeporpeglia/05fafd2328a54bc5eb71ce1bea37a9ce to your computer and use it in GitHub Desktop.
Save joeporpeglia/05fafd2328a54bc5eb71ce1bea37a9ce to your computer and use it in GitHub Desktop.
Expo config plugin for LiveKit
function withLivekit(config: ExpoConfig): ExpoConfig {
config = withLivekitAndroid(config);
config = withLivekitIOS(config);
return config;
}
function withLivekitAndroid(expoConfig: ExpoConfig): ExpoConfig {
return withMainApplication(expoConfig, (config) => {
let contents = config.modResults.contents;
// Replace com.example with your package name
contents = contents.replace(
'package com.example;',
'package com.example;\nimport com.livekit.reactnative.LiveKitReactNative;'
);
contents = contents.replace(
'super.onCreate();',
'super.onCreate();\nLiveKitReactNative.setup(this);'
);
config.modResults.contents = contents;
return config;
});
}
function withLivekitIOS(expoConfig: ExpoConfig): ExpoConfig {
return withAppDelegate(expoConfig, (config) => {
let contents = config.modResults.contents;
contents = contents.replace(
'#import "AppDelegate.h"',
'#import "AppDelegate.h"\n#import "LivekitReactNative.h"'
);
contents = contents.replace(
'self.moduleName = @"main";',
'self.moduleName = @"main";\n[LivekitReactNative setup];'
);
config.modResults.contents = contents;
return config;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment