MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / resolveXcodeContext

Function resolveXcodeContext

scripts/experimental/swiftui-preview.mjs:609–661  ·  view source on GitHub ↗
(args, context)

Source from the content-addressed store, hash-verified

607}
608
609function resolveXcodeContext(args, context) {
610 if (!args.workspace && !args.project && !args.scheme) {
611 return null;
612 }
613 if (!args.scheme) {
614 throw new Error(
615 "--scheme is required when using --workspace or --project.",
616 );
617 }
618
619 const derivedDataPath = path.resolve(
620 String(args.derivedDataPath ?? path.join(context.buildRoot, "DerivedData")),
621 );
622 const cacheIdentity = xcodeCacheIdentity(args, derivedDataPath);
623 if (args.skipXcodeBuild) {
624 const cached = readCachedXcodeContext(context, cacheIdentity);
625 if (cached) {
626 return cached;
627 }
628 }
629 const buildArgs = xcodebuildBaseArgs(args, derivedDataPath);
630 if (!args.skipXcodeBuild) {
631 const started = Date.now();
632 run("xcodebuild", [
633 ...buildArgs,
634 "build",
635 "CODE_SIGNING_ALLOWED=NO",
636 "ENABLE_TESTABILITY=YES",
637 ]);
638 console.log(
639 `[simdeck-preview] xcodebuild warm build completed in ${Date.now() - started}ms`,
640 );
641 }
642
643 const settings = readXcodeBuildSettings(buildArgs, args.target);
644 const buildSettings = settings.buildSettings ?? settings;
645 const arch = context.target.split("-")[0];
646 const appPath = findBuiltAppPath(buildSettings);
647 const debugDylibPath = findXcodeDebugDylib(appPath, buildSettings);
648 const xcode = {
649 appPath,
650 arch,
651 buildSettings,
652 debugDylibPath,
653 moduleName:
654 buildSettings.PRODUCT_MODULE_NAME || buildSettings.SWIFT_MODULE_NAME,
655 objectFiles: debugDylibPath
656 ? []
657 : collectXcodeObjectFiles(buildSettings, arch),
658 };
659 writeCachedXcodeContext(context, cacheIdentity, xcode);
660 return xcode;
661}
662
663function xcodeContextCachePath(context) {
664 return path.join(context.buildRoot, "xcode-context-cache.json");

Callers 1

mainFunction · 0.85

Calls 10

xcodeCacheIdentityFunction · 0.85
readCachedXcodeContextFunction · 0.85
xcodebuildBaseArgsFunction · 0.85
readXcodeBuildSettingsFunction · 0.85
findBuiltAppPathFunction · 0.85
findXcodeDebugDylibFunction · 0.85
collectXcodeObjectFilesFunction · 0.85
writeCachedXcodeContextFunction · 0.85
logMethod · 0.80
runFunction · 0.70

Tested by

no test coverage detected