1import { IOSConfig } from '@expo/config-plugins'; 2import plist from '@expo/plist'; 3import fs from 'fs'; 4 5const debug = require('debug')('expo:run:ios:codeSigning:simulator'); 6 7// NOTE(EvanBacon): These are entitlements that work in a simulator 8// but still require the project to have development code signing setup. 9// There may be more, but this is fine for now. 10const ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING = [ 11 'com.apple.developer.associated-domains', 12 'com.apple.developer.applesignin', 13]; 14 15function getEntitlements(projectRoot: string): Record<string, any> | null { 16 try { 17 const entitlementsPath = IOSConfig.Entitlements.getEntitlementsPath(projectRoot); 18 if (!entitlementsPath || !fs.existsSync(entitlementsPath)) { 19 return null; 20 } 21 22 const entitlementsContents = fs.readFileSync(entitlementsPath, 'utf8'); 23 const entitlements = plist.parse(entitlementsContents); 24 return entitlements; 25 } catch (error) { 26 debug('Failed to read entitlements', error); 27 } 28 return null; 29} 30 31/** @returns true if the simulator build should be code signed for development. */ 32export function simulatorBuildRequiresCodeSigning(projectRoot: string): boolean { 33 const entitlements = getEntitlements(projectRoot); 34 if (!entitlements) { 35 return false; 36 } 37 return ENTITLEMENTS_THAT_REQUIRE_CODE_SIGNING.some((entitlement) => entitlement in entitlements); 38} 39