(args, context)
| 607 | } |
| 608 | |
| 609 | function 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 | |
| 663 | function xcodeContextCachePath(context) { |
| 664 | return path.join(context.buildRoot, "xcode-context-cache.json"); |
no test coverage detected