import { ExpoConfig } from '@expo/config-types' ; import { XcodeProject } from 'xcode' ; import { ConfigPlugin } from '../Plugin.types' ; import { withXcodeProject } from '../plugins/ios-plugins' ; import { addWarningIOS } from '../utils/warnings' ; export const withDeviceFamily = config => { return withXcodeProject ( config , async ( config ) => { config . modResults = await setDeviceFamily ( config , { project : config . modResults } ) ; return config ; } ) ; } ; export function getSupportsTablet ( config ) { return ! ! config . ios ?. supportsTablet ; } export function getIsTabletOnly ( config ) { return ! ! config ?. ios ?. isTabletOnly ; } export function getDeviceFamilies ( config ) { const supportsTablet = getSupportsTablet ( config ) ; const isTabletOnly = getIsTabletOnly ( config ) ; if ( isTabletOnly && config . ios ?. supportsTablet === false ) { addWarningIOS ( 'ios.supportsTablet' , `Found contradictory values: \`{ ios: { isTabletOnly: true, supportsTablet: false } }\`. Using \`{ isTabletOnly: true }\`.` ) ; } if ( isTabletOnly ) { return [ 2 ] ; } else if ( supportsTablet ) { return [ 1 , 2 ] ; } else { return [ 1 ] ; } } param deviceFamilies export function formatDeviceFamilies ( deviceFamilies ) { return `"${ deviceFamilies . join ( ',' ) }"` ; } /**
 * Add to pbxproj under TARGETED_DEVICE_FAMILY
 */ export function setDeviceFamily ( config , { project } ) { const deviceFamilies = formatDeviceFamilies ( getDeviceFamilies ( config ) ) ; const configurations = project . pbxXCBuildConfigurationSection ( ) ; for ( const { buildSettings } of Object . values ( configurations || { } ) ) { if ( typeof buildSettings ?. PRODUCT_NAME !== 'undefined' ) { buildSettings . TARGETED_DEVICE_FAMILY = deviceFamilies ; } } return project ; }