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

Function buildHostApp

scripts/experimental/swiftui-preview.mjs:160–221  ·  view source on GitHub ↗
(context, rebuildHost)

Source from the content-addressed store, hash-verified

158}
159
160function buildHostApp(context, rebuildHost) {
161 const appPath = path.join(context.buildRoot, "SimDeckPreviewHost.app");
162 const executable = "SimDeckPreviewHost";
163 const executablePath = path.join(appPath, executable);
164 if (!rebuildHost && fs.existsSync(executablePath)) {
165 return { appPath, rebuilt: false };
166 }
167
168 fs.rmSync(appPath, { recursive: true, force: true });
169 fs.mkdirSync(appPath, { recursive: true });
170 fs.writeFileSync(
171 path.join(appPath, "Info.plist"),
172 `<?xml version="1.0" encoding="UTF-8"?>
173<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
174<plist version="1.0">
175<dict>
176 <key>CFBundleDevelopmentRegion</key><string>en</string>
177 <key>CFBundleExecutable</key><string>${executable}</string>
178 <key>CFBundleIdentifier</key><string>${context.bundleId}</string>
179 <key>CFBundleInfoDictionaryVersion</key><string>6.0</string>
180 <key>CFBundleName</key><string>SimDeckPreview</string>
181 <key>CFBundlePackageType</key><string>APPL</string>
182 <key>CFBundleShortVersionString</key><string>1.0</string>
183 <key>CFBundleVersion</key><string>1</string>
184 <key>LSRequiresIPhoneOS</key><true/>
185 <key>MinimumOSVersion</key><string>${context.minIos}</string>
186 <key>UIDeviceFamily</key><array><integer>1</integer><integer>2</integer></array>
187 <key>CFBundleURLTypes</key>
188 <array>
189 <dict>
190 <key>CFBundleURLName</key><string>SimDeckPreview</string>
191 <key>CFBundleURLSchemes</key><array><string>simdeck-preview</string></array>
192 </dict>
193 </array>
194</dict>
195</plist>
196`,
197 );
198
199 const mainPath = path.join(context.buildRoot, "SimDeckPreviewHost.swift");
200 fs.writeFileSync(mainPath, hostSource());
201 run("xcrun", [
202 "--sdk",
203 "iphonesimulator",
204 "swiftc",
205 "-target",
206 context.target,
207 "-sdk",
208 context.sdkPath,
209 "-parse-as-library",
210 "-Onone",
211 "-framework",
212 "SwiftUI",
213 "-framework",
214 "UIKit",
215 mainPath,
216 "-o",
217 executablePath,

Callers 1

mainFunction · 0.85

Calls 3

hostSourceFunction · 0.85
logMethod · 0.80
runFunction · 0.70

Tested by

no test coverage detected