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

Function readCachedXcodeContext

scripts/experimental/swiftui-preview.mjs:679–700  ·  view source on GitHub ↗
(context, identity)

Source from the content-addressed store, hash-verified

677}
678
679function readCachedXcodeContext(context, identity) {
680 const cachePath = xcodeContextCachePath(context);
681 if (!fs.existsSync(cachePath)) {
682 return null;
683 }
684 try {
685 const cached = JSON.parse(fs.readFileSync(cachePath, "utf8"));
686 if (JSON.stringify(cached.identity) !== JSON.stringify(identity)) {
687 return null;
688 }
689 const xcode = cached.xcode;
690 if (!xcode?.appPath || !fs.existsSync(xcode.appPath)) {
691 return null;
692 }
693 if (xcode.debugDylibPath && !fs.existsSync(xcode.debugDylibPath)) {
694 return null;
695 }
696 return xcode;
697 } catch {
698 return null;
699 }
700}
701
702function writeCachedXcodeContext(context, identity, xcode) {
703 fs.writeFileSync(

Callers 1

resolveXcodeContextFunction · 0.85

Calls 2

xcodeContextCachePathFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected