1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4  value: true
5});
6exports.getName = getName;
7exports.setDisplayName = setDisplayName;
8exports.setName = setName;
9exports.setProductName = setProductName;
10exports.withProductName = exports.withName = exports.withDisplayName = void 0;
11
12function _iosPlugins() {
13  const data = require("../plugins/ios-plugins");
14
15  _iosPlugins = function () {
16    return data;
17  };
18
19  return data;
20}
21
22function _Target() {
23  const data = require("./Target");
24
25  _Target = function () {
26    return data;
27  };
28
29  return data;
30}
31
32function _Xcodeproj() {
33  const data = require("./utils/Xcodeproj");
34
35  _Xcodeproj = function () {
36    return data;
37  };
38
39  return data;
40}
41
42const withDisplayName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setDisplayName, {
43  infoPlistProperty: 'CFBundleDisplayName',
44  expoConfigProperty: 'name'
45}, 'withDisplayName');
46exports.withDisplayName = withDisplayName;
47const withName = (0, _iosPlugins().createInfoPlistPluginWithPropertyGuard)(setName, {
48  infoPlistProperty: 'CFBundleName',
49  expoConfigProperty: 'name'
50}, 'withName');
51/** Set the PRODUCT_NAME variable in the xcproj file based on the app.json name property. */
52
53exports.withName = withName;
54
55const withProductName = config => {
56  return (0, _iosPlugins().withXcodeProject)(config, config => {
57    config.modResults = setProductName(config, config.modResults);
58    return config;
59  });
60};
61
62exports.withProductName = withProductName;
63
64function getName(config) {
65  return typeof config.name === 'string' ? config.name : null;
66}
67/**
68 * CFBundleDisplayName is used for most things: the name on the home screen, in
69 * notifications, and others.
70 */
71
72
73function setDisplayName(configOrName, {
74  CFBundleDisplayName,
75  ...infoPlist
76}) {
77  let name = null;
78
79  if (typeof configOrName === 'string') {
80    name = configOrName;
81  } else {
82    name = getName(configOrName);
83  }
84
85  if (!name) {
86    return infoPlist;
87  }
88
89  return { ...infoPlist,
90    CFBundleDisplayName: name
91  };
92}
93/**
94 * CFBundleName is recommended to be 16 chars or less and is used in lists, eg:
95 * sometimes on the App Store
96 */
97
98
99function setName(config, {
100  CFBundleName,
101  ...infoPlist
102}) {
103  const name = getName(config);
104
105  if (!name) {
106    return infoPlist;
107  }
108
109  return { ...infoPlist,
110    CFBundleName: name
111  };
112}
113
114function setProductName(config, project) {
115  var _getName;
116
117  const name = (0, _Xcodeproj().sanitizedName)((_getName = getName(config)) !== null && _getName !== void 0 ? _getName : '');
118
119  if (!name) {
120    return project;
121  }
122
123  const quotedName = ensureQuotes(name);
124  const [, nativeTarget] = (0, _Target().findFirstNativeTarget)(project);
125  (0, _Xcodeproj().getBuildConfigurationsForListId)(project, nativeTarget.buildConfigurationList).forEach(([, item]) => {
126    item.buildSettings.PRODUCT_NAME = quotedName;
127  });
128  return project;
129}
130
131const ensureQuotes = value => {
132  if (!value.match(/^['"]/)) {
133    return `"${value}"`;
134  }
135
136  return value;
137};
138//# sourceMappingURL=Name.js.map