import type { ExpoConfig } from '@expo/config-types' ; import type { JSONObject , JSONValue } from '@expo/json-file' ; import type { XcodeProject } from 'xcode' ; import type { ConfigPlugin , Mod } from '../Plugin.types' ; import type { ExpoPlist , InfoPlist } from '../ios/IosConfig.types' ; import type { AppDelegateProjectFile } from '../ios/Paths' ; import { withMod } from './withMod' ; type MutateInfoPlistAction = ( expo : ExpoConfig , infoPlist : InfoPlist ) => InfoPlist ; param action export function createInfoPlistPlugin ( action , name ? ) { const withUnknown = config => withInfoPlist ( config , async ( config ) => { config . modResults = await action ( config , config . modResults ) ; return config ; } ) ; if ( name ) { Object . defineProperty ( withUnknown , 'name' , { value : name } ) ; } return withUnknown ; } type MutateEntitlementsPlistAction = ( expo : ExpoConfig , entitlements : JSONObject ) => JSONObject ; param action export function createEntitlementsPlugin ( action , name ) { const withUnknown = config => withEntitlementsPlist ( config , async ( config ) => { config . modResults = await action ( config , config . modResults ) ; return config ; } ) ; if ( name ) { Object . defineProperty ( withUnknown , 'name' , { value : name } ) ; } return withUnknown ; } param config param action export const withAppDelegate = ( config , action ) => { return withMod ( config , { platform : 'ios' , mod : 'appDelegate' , action } ) ; } ; param config param action export const withInfoPlist = ( config , action ) => { return withMod < InfoPlist > ( config , { platform : 'ios' , mod : 'infoPlist' , async action ( config ) { config = await action ( config ) ; if ( ! config . ios ) { config . ios = { } ; } config . ios . infoPlist = config . modResults ; return config ; } } ) ; } ; param config param action export const withEntitlementsPlist = ( config , action ) => { return withMod < JSONObject > ( config , { platform : 'ios' , mod : 'entitlements' , async action ( config ) { config = await action ( config ) ; if ( ! config . ios ) { config . ios = { } ; } config . ios . entitlements = config . modResults ; return config ; } } ) ; } ; param config param action export const withExpoPlist = ( config , action ) => { return withMod ( config , { platform : 'ios' , mod : 'expoPlist' , action } ) ; } ; param config param action export const withXcodeProject = ( config , action ) => { return withMod ( config , { platform : 'ios' , mod : 'xcodeproj' , action } ) ; } ; param config param action export const withPodfileProperties = ( config , action ) => { return withMod ( config , { platform : 'ios' , mod : 'podfileProperties' , action } ) ; } ;