diff --git a/packages/cli/src/link/ios/getTargets.js b/packages/cli/src/link/ios/getTargets.js index f837fedcc..45a7d647d 100644 --- a/packages/cli/src/link/ios/getTargets.js +++ b/packages/cli/src/link/ios/getTargets.js @@ -15,25 +15,29 @@ export default function getTargets(project) { firstProject: { targets }, } = project.getFirstProject(); const nativeTargetSection = project.pbxNativeTargetSection(); - return targets.map(target => { - const key = target.value; - const configurationListId = project.pbxNativeTargetSection()[key] - .buildConfigurationList; - const configurationList = project.pbxXCConfigurationList()[ - configurationListId - ]; - const buildConfigurationId = configurationList.buildConfigurations[0].value; - const buildConfiguration = project.pbxXCBuildConfigurationSection()[ - buildConfigurationId - ]; - return { - uuid: key, - target: nativeTargetSection[key], - name: nativeTargetSection[key].productReference_comment, - isTVOS: - (buildConfiguration.buildSettings.SDKROOT && - buildConfiguration.buildSettings.SDKROOT.indexOf('appletv') !== -1) || - false, - }; - }); -} + return targets + .filter(target => nativeTargetSection[target.value] !== undefined) + .map(target => { + const key = target.value; + const configurationListId = + nativeTargetSection[key].buildConfigurationList; + const configurationList = project.pbxXCConfigurationList()[ + configurationListId + ]; + const buildConfigurationId = + configurationList.buildConfigurations[0].value; + const buildConfiguration = project.pbxXCBuildConfigurationSection()[ + buildConfigurationId + ]; + return { + uuid: key, + target: nativeTargetSection[key], + name: nativeTargetSection[key].productReference_comment, + isTVOS: + (buildConfiguration.buildSettings.SDKROOT && + buildConfiguration.buildSettings.SDKROOT.indexOf('appletv') !== + -1) || + false, + }; + }); +};