MCPcopy Index your code
hub / github.com/ionic-team/capacitor / buildCSettingsText

Function buildCSettingsText

cli/src/ios/update.ts:199–251  ·  view source on GitHub ↗
(p: Plugin, sourceFiles: any[])

Source from the content-addressed store, hash-verified

197}
198
199function buildCSettingsText(p: Plugin, sourceFiles: any[]): string {
200 const pluginId = p.id;
201 const allFlags = new Set<string>();
202 for (const sourceFile of sourceFiles) {
203 const flags = sourceFile.$?.['compiler-flags'];
204 if (flags) {
205 flags
206 .split(/\s+/)
207 .map((f: string) => f.trim())
208 .filter((f: string) => f.length > 0)
209 .forEach((f: string) => allFlags.add(f));
210 }
211 }
212
213 if (allFlags.size === 0) {
214 return '';
215 }
216
217 const entries: string[] = [];
218 const unsupportedFlags: string[] = [];
219
220 for (const flag of allFlags) {
221 if (flag.startsWith('-D')) {
222 const definition = flag.slice(2);
223 const eqIndex = definition.indexOf('=');
224 if (eqIndex !== -1) {
225 const name = definition.slice(0, eqIndex);
226 const value = definition.slice(eqIndex + 1);
227 entries.push(` .define("${name}", to: "${value}")`);
228 } else {
229 entries.push(` .define("${definition}")`);
230 }
231 } else {
232 unsupportedFlags.push(flag);
233 }
234 }
235
236 if (unsupportedFlags.length > 0) {
237 logger.warn(
238 `${pluginId}: the following compiler flags are not supported in SPM and were ignored: ${unsupportedFlags.join(', ')}. ` +
239 `This might cause the plugin to fail to compile.`,
240 );
241 }
242
243 if (entries.length === 0) {
244 return '';
245 }
246
247 return `,
248 cSettings: [
249${entries.join(',\n')}
250 ]`;
251}
252
253async function writeGeneratedPackageSwift(p: Plugin, config: Config, iosPlatformVersion: string) {
254 const iosVersion = getMajoriOSVersion(config);

Callers 1

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected