1import { ConfigPlugin, WarningAggregator, withEntitlementsPlist } from '@expo/config-plugins'; 2import { ExpoConfig } from '@expo/config-types'; 3 4export const withDocumentPickerIOS: ConfigPlugin<{ appleTeamId?: string }> = ( 5 config, 6 { appleTeamId } 7) => { 8 return withEntitlementsPlist(config, (config) => { 9 if (appleTeamId) { 10 config.modResults = setICloudEntitlments(config, appleTeamId, config.modResults); 11 } else { 12 WarningAggregator.addWarningIOS( 13 'expo-document-picker', 14 'Cannot configure iOS entitlements because neither the appleTeamId property, nor the environment variable EXPO_APPLE_TEAM_ID were defined.' 15 ); 16 } 17 return config; 18 }); 19}; 20 21export function setICloudEntitlments( 22 config: Pick<ExpoConfig, 'ios'>, 23 appleTeamId: string, 24 entitlements: Record<string, any> 25): Record<string, any> { 26 if (config.ios?.usesIcloudStorage) { 27 entitlements['com.apple.developer.icloud-container-identifiers'] = [ 28 'iCloud.' + config.ios.bundleIdentifier, 29 ]; 30 entitlements['com.apple.developer.ubiquity-container-identifiers'] = [ 31 'iCloud.' + config.ios.bundleIdentifier, 32 ]; 33 entitlements['com.apple.developer.ubiquity-kvstore-identifier'] = 34 appleTeamId + '.' + config.ios.bundleIdentifier; 35 entitlements['com.apple.developer.icloud-services'] = ['CloudDocuments']; 36 } 37 return entitlements; 38} 39