UNPKG

expo-srcpush

Version:

Expo module for Source Push, a service for over-the-air updates in React Native applications.

31 lines (26 loc) 1.04 kB
import { ConfigPlugin, withAppDelegate } from 'expo/config-plugins' import { PluginConfigType } from '../pluginConfig' function applyImplementation(appDelegate: string, find: string, add: string, replace?: boolean) { // Make sure the project does not have the settings already if (!appDelegate.includes(add)) { if (replace) return appDelegate.replace(find, add) else return appDelegate.replace(find, `${find}\n${add}`) } return appDelegate } export const withIosAppDelegateDependency: ConfigPlugin<PluginConfigType> = (config: any, props: any) => { return withAppDelegate(config, (confi: any) => { config.modResults.contents = applyImplementation( config.modResults.contents, `#import "AppDelegate.h"`, `#import <CodePush/CodePush.h>` ) config.modResults.contents = applyImplementation( config.modResults.contents, `return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];`, `return [CodePush bundleURL];`, true ) return config }) }