@moku-labs/native 0.3.12 → 0.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -821,7 +821,8 @@ function generateCapabilities(input) {
821
821
  //#region src/plugins/project/generators/cargo.ts
822
822
  /**
823
823
  * @file project plugin generator — Cargo.toml with registry-pinned crate dependencies, the
824
- * path dependency of every generated local crate, and the size profile of a release build.
824
+ * path dependency of every generated local crate, the iOS debug `devtools` feature, and the
825
+ * size profile of a release build.
825
826
  */
826
827
  /**
827
828
  * The `tauri` crate floor. The `back` capability calls `exit()` and grants
@@ -836,7 +837,7 @@ const TAURI_VERSION_FLOOR = "2.12";
836
837
  */
837
838
  const IOS_ONLY_DEPENDENCIES = [`[target.'cfg(target_os = "ios")'.dependencies]`, "objc2 = \"0.6\""];
838
839
  /**
839
- * The release profile, for every target and both build profiles: the debug build is a
840
+ * The release profile, for every target and every build profile: the debug build is a
840
841
  * release build too, so what a phone measures is what the store ships. It trades compile
841
842
  * time for a smaller library, and `panic = "abort"` drops the unwinding tables.
842
843
  */
@@ -849,6 +850,12 @@ const RELEASE_PROFILE = [
849
850
  "strip = true"
850
851
  ];
851
852
  /**
853
+ * The `tauri` feature an iOS debug build adds. The debug build is a release build, and a
854
+ * release build compiles the inspector only with it: the window's `devtools` flag alone does
855
+ * nothing there.
856
+ */
857
+ const IOS_DEBUG_FEATURE = "devtools";
858
+ /**
852
859
  * Derives a valid Cargo package name from the app's display name — lowercased,
853
860
  * non-alphanumeric runs collapsed to a single hyphen, and guaranteed to start with a
854
861
  * letter (Cargo package names must match `[a-z][a-z0-9_-]*`).
@@ -905,9 +912,9 @@ function dependencyLine(capability) {
905
912
  * every cargo feature the composed capabilities ask for (tray's `tray-icon`; without it
906
913
  * the tray API is not compiled in at all), plus one dependency line per resolved
907
914
  * capability that ships a crate: pinned for a published one, by path for the generated
908
- * shell crate. Feature-only and permission-only rows contribute no dependency line. The
909
- * `[profile.release]` table follows, and the iOS-only `objc2` table closes the file on
910
- * every target.
915
+ * shell crate. Feature-only and permission-only rows contribute no dependency line. An iOS
916
+ * debug build adds `devtools` to those features. The `[profile.release]` table follows, and
917
+ * the iOS-only `objc2` table closes the file on every target.
911
918
  *
912
919
  * @param input - Frozen global config + capabilities resolved for the target.
913
920
  * @returns A single-artifact array for `src-tauri/Cargo.toml`.
@@ -915,7 +922,9 @@ function dependencyLine(capability) {
915
922
  function generateCargo(input) {
916
923
  const packageName = sanitizePackageName(input.global.app.name);
917
924
  const pinnedDeps = input.capabilities.map((capability) => dependencyLine(capability)).filter((line) => line !== void 0).toSorted();
918
- const features = [...new Set(input.capabilities.flatMap((capability) => capability.cargoFeatures))].toSorted().map((feature) => `"${feature}"`).join(", ");
925
+ const iosDebug = input.target === "ios" && input.profile === "debug";
926
+ const requested = input.capabilities.flatMap((capability) => capability.cargoFeatures);
927
+ const features = [.../* @__PURE__ */ new Set([...requested, ...iosDebug ? [IOS_DEBUG_FEATURE] : []])].toSorted().map((feature) => `"${feature}"`).join(", ");
919
928
  return [{
920
929
  path: "src-tauri/Cargo.toml",
921
930
  content: [
@@ -1703,7 +1712,7 @@ class MokuShellPlugin(private val activity: Activity) : Plugin(activity) {
1703
1712
  `;
1704
1713
  /**
1705
1714
  * Renders `MokuShellProfile.kt`: the one per-profile file of the module. The debug profile
1706
- * turns on WebView debugging and `share`; the store profile turns both off.
1715
+ * turns on WebView debugging and `share`; the store and dev profiles turn both off.
1707
1716
  *
1708
1717
  * @param profile - The build profile the crate is generated for.
1709
1718
  * @returns The Kotlin source.
@@ -1946,8 +1955,8 @@ const CONTRACT_BODY = String.raw` var MAX_SHARE_BYTES = 32 * 1024 * 1024;
1946
1955
  }, noop);`;
1947
1956
  /**
1948
1957
  * Builds the page contract script for one app and profile. The build profile and id are
1949
- * baked in at generate time: the store profile reads `"release"` on the page, and the id is
1950
- * `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
1958
+ * baked in at generate time: the store and dev profiles read `"release"` on the page, and the
1959
+ * id is `"<app.version>+<app.buildNumber ?? 0>"`, with `"-debug"` in the debug profile. A second
1951
1960
  * run of the script in the same frame is a no-op.
1952
1961
  *
1953
1962
  * @param input - The generator input (target, app version and build number).
@@ -2127,11 +2136,14 @@ function escapeXml(text) {
2127
2136
  }
2128
2137
  //#endregion
2129
2138
  //#region src/plugins/project/generators/sidecar.ts
2130
- /**
2131
- * @file project plugin generator — Info.ios.plist sidecar (src-tauri root, outside gen/).
2132
- */
2133
2139
  /** One indentation step of the generated plist. */
2134
2140
  const PLIST_INDENT = " ";
2141
+ /** The key of the sentence iOS shows when it asks to reach the local network. */
2142
+ const LOCAL_NETWORK_USAGE_KEY = "NSLocalNetworkUsageDescription";
2143
+ /** The key of App Transport Security, which refuses `ws://` to the editor by default. */
2144
+ const APP_TRANSPORT_SECURITY_KEY = "NSAppTransportSecurity";
2145
+ /** The sentence iOS shows when an iOS debug build first reaches for the editor. */
2146
+ const LOCAL_NETWORK_USAGE = "This debug build talks to the editor on your local network.";
2135
2147
  /**
2136
2148
  * Tells a plist `<array>` from a `<dict>`: `Array.isArray` alone does not narrow a readonly
2137
2149
  * array.
@@ -2191,11 +2203,35 @@ function renderPlistValue(value, indent) {
2191
2203
  ];
2192
2204
  }
2193
2205
  /**
2206
+ * Lists what the debug profile needs to reach the editor from an iPhone: the local-network
2207
+ * sentence, and App Transport Security opened for the local network alone. Every other
2208
+ * profile adds nothing, and the iOS patch pass takes both keys out of a kept tree again
2209
+ * (`mobile/ios-plist.ts`).
2210
+ *
2211
+ * @param profile - The build profile being generated for.
2212
+ * @returns The two entries in the debug profile, otherwise none.
2213
+ * @example
2214
+ * ```ts
2215
+ * debugPlist("store"); // []
2216
+ * ```
2217
+ */
2218
+ function debugPlist(profile) {
2219
+ if (profile !== "debug") return [];
2220
+ return [{
2221
+ key: LOCAL_NETWORK_USAGE_KEY,
2222
+ value: LOCAL_NETWORK_USAGE
2223
+ }, {
2224
+ key: APP_TRANSPORT_SECURITY_KEY,
2225
+ value: { NSAllowsLocalNetworking: true }
2226
+ }];
2227
+ }
2228
+ /**
2194
2229
  * Generates the `Info.ios.plist` SIDECAR at the src-tauri root, which Tauri merges into the
2195
2230
  * app's Info.plist on every iOS build. Its entries are every resolved capability's
2196
- * `sidecarPlist`, then `ios.infoPlist`, then the orientation lock (`app.orientation`); on a
2197
- * duplicate key the later entry wins, so the app's keys beat a capability and orientation
2198
- * beats both.
2231
+ * `sidecarPlist`, then `ios.infoPlist`, then the debug profile's two keys, then the orientation
2232
+ * lock (`app.orientation`); on a duplicate key the later entry wins, so the app's keys beat a
2233
+ * capability, the debug keys beat a game's own in that profile only, and orientation beats
2234
+ * them all.
2199
2235
  *
2200
2236
  * On iOS the file is ALWAYS written, as an empty `<dict>` when nothing contributes a key:
2201
2237
  * the writer never deletes a file, and a portrait lock left in a stale sidecar would keep
@@ -2221,6 +2257,7 @@ function generateSidecar(input) {
2221
2257
  key,
2222
2258
  value
2223
2259
  })),
2260
+ ...debugPlist(input.profile),
2224
2261
  ...orientationPlist(input.global.app.orientation)
2225
2262
  ];
2226
2263
  for (const entry of contributed) entries.set(entry.key, entry.value);
@@ -2241,8 +2278,9 @@ function generateSidecar(input) {
2241
2278
  //#endregion
2242
2279
  //#region src/plugins/project/generators/tauri-conf.ts
2243
2280
  /**
2244
- * @file project plugin generator — tauri.conf.json (identity, build wiring, bundle
2245
- * metadata, Apple signing, the Android versionCode, plugin blocks).
2281
+ * @file project plugin generator — tauri.conf.json (identity, build wiring, the main
2282
+ * window with its iOS debug inspector, bundle metadata, Apple signing, the Android
2283
+ * versionCode, plugin blocks).
2246
2284
  */
2247
2285
  /**
2248
2286
  * The icon set `tauri icon` writes into `src-tauri/icons`. Tauri reads `bundle.icon` at
@@ -2377,9 +2415,11 @@ function buildPlugins(capabilities) {
2377
2415
  }
2378
2416
  /**
2379
2417
  * Generates `src-tauri/tauri.conf.json` — app identity, the web build/dev wiring, with
2380
- * `removeUnusedCommands` in the store profile only (a debug page may call what a store
2381
- * page does not), the main window (its title, plus `app.backgroundColor` when set), the
2382
- * bundle/signing metadata, and a `plugins.<name>` block per CONFIGURED capability (see
2418
+ * `removeUnusedCommands` in the store profile only (a debug or dev page may call what a
2419
+ * store page does not), the main window (its title, plus `app.backgroundColor` when set, and
2420
+ * `devtools` in an iOS debug build, so Safari Web Inspector can attach: the debug build is a
2421
+ * release build, where Tauri closes the inspector), the bundle/signing metadata, and a
2422
+ * `plugins.<name>` block per CONFIGURED capability (see
2383
2423
  * {@link buildPlugins}; this is where deep-link's scheme rides — per D-011/D-012 the whole
2384
2424
  * v1 mobile-permission story is conf-only). Both path-shaped fields are rebased onto
2385
2425
  * `src-tauri`, which is where Tauri resolves them from, and the before-commands carry an
@@ -2397,6 +2437,7 @@ function buildPlugins(capabilities) {
2397
2437
  function generateTauriConf(input) {
2398
2438
  const { global, capabilities } = input;
2399
2439
  const webRoot = node_path.default.resolve(global.web.cwd ?? ".");
2440
+ const inspectable = input.target === "ios" && input.profile === "debug";
2400
2441
  const conf = {
2401
2442
  productName: global.app.name,
2402
2443
  identifier: global.app.identifier,
@@ -2416,7 +2457,8 @@ function generateTauriConf(input) {
2416
2457
  },
2417
2458
  app: { windows: [{
2418
2459
  title: global.app.name,
2419
- ...compact([["backgroundColor", global.app.backgroundColor]])
2460
+ ...compact([["backgroundColor", global.app.backgroundColor]]),
2461
+ ...inspectable ? { devtools: true } : {}
2420
2462
  }] },
2421
2463
  bundle: buildBundle(input),
2422
2464
  plugins: buildPlugins(capabilities)
@@ -2725,9 +2767,9 @@ async function writeIfChanged(filePath, content, projectDirectory) {
2725
2767
  * the iOS project patches) reads the same list from here, so none can drift into a file the
2726
2768
  * others do not know about — and none ever descends into `gen/apple/build` or
2727
2769
  * `gen/android/build`, which belong to the toolchain. The privacy manifest's place in the
2728
- * tree is here too. The Android status bar patch finds its MainActivity.kt here, the profile
2729
- * patches their `strings.xml` and network security config, and the icon inset its adaptive
2730
- * icon directory.
2770
+ * tree is here too, and so is the app's `Info.plist`. The Android status bar patch finds its
2771
+ * MainActivity.kt here, the profile patches their `strings.xml` and network security config,
2772
+ * and the icon inset its adaptive icon directory.
2731
2773
  */
2732
2774
  /** Source extensions that can carry the Android runner command. */
2733
2775
  const ANDROID_SOURCE_EXTENSIONS = /* @__PURE__ */ new Set([
@@ -2759,6 +2801,10 @@ const SKIPPED_DIRECTORIES = /* @__PURE__ */ new Set([
2759
2801
  ]);
2760
2802
  /** The file name Apple reads a privacy manifest from, at the top of the app bundle. */
2761
2803
  const IOS_PRIVACY_MANIFEST_FILE = "PrivacyInfo.xcprivacy";
2804
+ /** How the directory of the app's own files ends in `gen/apple`: `<slug>_iOS`. */
2805
+ const IOS_APP_DIRECTORY_SUFFIX = "_iOS";
2806
+ /** The file name of the app's property list, in that directory. */
2807
+ const IOS_INFO_PLIST_FILE = "Info.plist";
2762
2808
  /**
2763
2809
  * Lists the generated iOS files a patch pass may rewrite: `project.yml` plus the
2764
2810
  * `project.pbxproj` of every generated Xcode project. `gen/apple/build` is never listed —
@@ -2783,6 +2829,22 @@ async function iosPatchFiles(genDirectory) {
2783
2829
  return files;
2784
2830
  }
2785
2831
  /**
2832
+ * Lists the `Info.plist` of the generated iOS app, the file `tauri ios build` merges the
2833
+ * sidecar into: in the `gen/apple` directory that ends in `_iOS`. A tree where tauri has not
2834
+ * written it yet lists nothing.
2835
+ *
2836
+ * @param genDirectory - The `src-tauri/gen/apple` directory.
2837
+ * @returns The existing files, possibly none.
2838
+ * @example
2839
+ * ```ts
2840
+ * await iosInfoPlistFiles("/repo/.moku/tauri/src-tauri/gen/apple");
2841
+ * // ["/repo/.moku/tauri/src-tauri/gen/apple/my-game_iOS/Info.plist"]
2842
+ * ```
2843
+ */
2844
+ async function iosInfoPlistFiles(genDirectory) {
2845
+ return (await (0, node_fs_promises.readdir)(genDirectory, { withFileTypes: true })).filter((entry) => entry.isDirectory() && entry.name.endsWith(IOS_APP_DIRECTORY_SUFFIX)).map((entry) => node_path.default.join(genDirectory, entry.name, IOS_INFO_PLIST_FILE)).filter((file) => (0, node_fs.existsSync)(file));
2846
+ }
2847
+ /**
2786
2848
  * Returns where the iOS patch pass keeps the privacy manifest: the top of `gen/apple`, the
2787
2849
  * directory `project.yml` and the pbxproj's root group resolve a relative path from.
2788
2850
  *
@@ -3768,6 +3830,118 @@ async function patchPrivacyManifest(projectDirectory, genDirectory, manifest) {
3768
3830
  };
3769
3831
  }
3770
3832
  //#endregion
3833
+ //#region src/plugins/project/mobile/ios-plist.ts
3834
+ /**
3835
+ * @file project plugin — the iOS `Info.plist` patch: takes the debug keys out of a kept tree.
3836
+ *
3837
+ * `tauri ios build` merges `Info.ios.plist` INTO `gen/apple/<slug>_iOS/Info.plist` for good
3838
+ * (measured with tauri-cli 2.11.4), so a key dropped from the sidecar stays in that file: a
3839
+ * store build of a tree that once built in debug would ship the loosened App Transport
3840
+ * Security. Outside the debug profile this pass removes both debug keys; the sidecar merge
3841
+ * after it restores whatever the game itself asked for.
3842
+ *
3843
+ * The transform is a pure text function over the shape the plist crate writes: line endings
3844
+ * and every neighbouring line survive byte for byte, and a file without the keys comes back
3845
+ * untouched. That crate escapes every value and writes no comment, so a `<` is always a tag.
3846
+ */
3847
+ /** The keys only a debug build may carry, the ones `generators/sidecar.ts` adds there. */
3848
+ const DEBUG_KEYS = [LOCAL_NETWORK_USAGE_KEY, APP_TRANSPORT_SECURITY_KEY];
3849
+ /** Every element tag of a plist. Group 1 marks a closing tag, group 2 a self-closed one. */
3850
+ const TAG_PATTERN = /<(\/?)[a-z][^<>]*?(\/?)>/gi;
3851
+ /**
3852
+ * Finds where the plist value that starts after `from` ends, walking its depth: a `<dict>`
3853
+ * may hold more of them, and a `<dict/>` opens nothing.
3854
+ *
3855
+ * @param text - The file content.
3856
+ * @param from - The index right after the value's `<key>` element.
3857
+ * @returns The index after the value, or undefined when no value follows.
3858
+ * @example
3859
+ * ```ts
3860
+ * valueEnd("<key>K</key><dict><dict/></dict>", 12); // 32
3861
+ * ```
3862
+ */
3863
+ function valueEnd(text, from) {
3864
+ let depth = 0;
3865
+ for (const match of text.slice(from).matchAll(TAG_PATTERN)) {
3866
+ const [tag, closing, selfClosed] = match;
3867
+ if (depth === 0 && tag === "<key>") return void 0;
3868
+ if (closing) depth -= 1;
3869
+ else if (!selfClosed) depth += 1;
3870
+ if (depth === 0) return from + match.index + tag.length;
3871
+ if (depth < 0) return void 0;
3872
+ }
3873
+ }
3874
+ /**
3875
+ * Cuts a range out of a text: the whole lines when the range is alone on them, so no blank
3876
+ * line stays behind and the file keeps its line endings, otherwise the range only.
3877
+ *
3878
+ * @param text - The file content.
3879
+ * @param start - The index of the range's first character.
3880
+ * @param end - The index after its last character.
3881
+ * @returns The text without the range.
3882
+ * @example
3883
+ * ```ts
3884
+ * cutRange("a\n\tb\nc\n", 3, 4); // "a\nc\n"
3885
+ * ```
3886
+ */
3887
+ function cutRange(text, start, end) {
3888
+ const lineStart = text.lastIndexOf("\n", start) + 1;
3889
+ const lineBreak = text.indexOf("\n", end);
3890
+ const lineEnd = lineBreak === -1 ? text.length : lineBreak + 1;
3891
+ return text.slice(lineStart, start).trim() === "" && text.slice(end, lineEnd).trim() === "" ? text.slice(0, lineStart) + text.slice(lineEnd) : text.slice(0, start) + text.slice(end);
3892
+ }
3893
+ /**
3894
+ * Removes keys and their values from the text of an XML property list. A value is whatever
3895
+ * element follows the `<key>`, however deep it nests. Content without the keys comes back
3896
+ * byte-identical, so the writer leaves the file alone.
3897
+ *
3898
+ * @param existing - The current `Info.plist` content.
3899
+ * @param keys - The keys to remove.
3900
+ * @returns The content without those keys.
3901
+ * @throws {Error} `[native]` when a key has no value after it: the file is broken, and a store
3902
+ * build must not go on with the key still in it.
3903
+ * @example
3904
+ * ```ts
3905
+ * removePlistKeys("<dict>\n\t<key>A</key>\n\t<dict/>\n\t<key>B</key>\n\t<true/>\n</dict>\n", ["A"]);
3906
+ * // "<dict>\n\t<key>B</key>\n\t<true/>\n</dict>\n"
3907
+ * ```
3908
+ */
3909
+ function removePlistKeys(existing, keys) {
3910
+ let text = existing;
3911
+ for (const key of keys) {
3912
+ const element = `<key>${key}</key>`;
3913
+ for (let start = text.indexOf(element); start !== -1; start = text.indexOf(element)) {
3914
+ const end = valueEnd(text, start + element.length);
3915
+ if (end === void 0) throw missingAnchorError(`the value of ${key}`, IOS_INFO_PLIST_FILE);
3916
+ text = cutRange(text, start, end);
3917
+ }
3918
+ }
3919
+ return text;
3920
+ }
3921
+ /**
3922
+ * Takes the debug keys out of the `Info.plist` of a kept iOS tree. Idempotent: a second pass
3923
+ * reports the file unchanged. A tree where tauri has not written the file reports nothing.
3924
+ *
3925
+ * @param projectDirectory - The Tauri project root.
3926
+ * @param genDirectory - The `src-tauri/gen/apple` directory.
3927
+ * @returns The paths patched vs. left unchanged.
3928
+ * @throws {Error} `[native]` when a debug key has no value after it.
3929
+ * @example
3930
+ * ```ts
3931
+ * await patchIosInfoPlist(projectDir, path.join(projectDir, "src-tauri/gen/apple"));
3932
+ * // { patched: [".../gen/apple/my-game_iOS/Info.plist"], unchanged: [] }
3933
+ * ```
3934
+ */
3935
+ async function patchIosInfoPlist(projectDirectory, genDirectory) {
3936
+ const patched = [];
3937
+ const unchanged = [];
3938
+ for (const file of await iosInfoPlistFiles(genDirectory)) (await writeIfChanged(file, removePlistKeys(await (0, node_fs_promises.readFile)(file, "utf8"), DEBUG_KEYS), projectDirectory) === "written" ? patched : unchanged).push(file);
3939
+ return {
3940
+ patched,
3941
+ unchanged
3942
+ };
3943
+ }
3944
+ //#endregion
3771
3945
  //#region src/plugins/project/mobile/manifest.ts
3772
3946
  /**
3773
3947
  * @file project plugin — the Android manifest patch. Tauri has no config key for what the
@@ -5625,8 +5799,9 @@ async function patchAndroidWindowBackground(projectDirectory, genDirectory, back
5625
5799
  * the orientation lock), `system-bars.ts` (the Android status bar icon style from
5626
5800
  * `app.backgroundColor`), `window-background.ts` (the Android window and icon-splash
5627
5801
  * background from the same colour), `runner.ts` (the Xcode / Android-Studio runner command),
5628
- * `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work)
5629
- * and `ios-project.ts` (the iOS deployment target and privacy manifest).
5802
+ * `xcode-settings.ts` (the iOS entitlements-modification setting that makes a REBUILD work),
5803
+ * `ios-project.ts` (the iOS deployment target and privacy manifest) and `ios-plist.ts` (the
5804
+ * debug keys a debug build left in the iOS `Info.plist`).
5630
5805
  */
5631
5806
  /** The profile of a pass whose caller names none: the store profile, warnings dropped. */
5632
5807
  const STORE_PROFILE = { profile: "store" };
@@ -5651,8 +5826,9 @@ function mergePatchResults(...results) {
5651
5826
  }
5652
5827
  /**
5653
5828
  * The iOS half of {@link patchMobile}: the Xcode entitlements-modification setting, the
5654
- * deployment target, the privacy manifest, then the runner command when the caller supplies
5655
- * a runner. A tree that was never initialised is left alone and reports nothing.
5829
+ * deployment target, the privacy manifest, outside the debug profile the removal of the debug
5830
+ * `Info.plist` keys, then the runner command when the caller supplies a runner. A tree that
5831
+ * was never initialised is left alone and reports nothing.
5656
5832
  *
5657
5833
  * @param options - What to patch.
5658
5834
  * @param options.projectDirectory - The Tauri project root.
@@ -5661,9 +5837,10 @@ function mergePatchResults(...results) {
5661
5837
  * @param options.minimumVersion - The iOS deployment target to write.
5662
5838
  * @param options.privacyManifest - `ios.privacyManifest`; unset removes one a previous pass
5663
5839
  * added.
5840
+ * @param options.profile - The build profile of this pass.
5664
5841
  * @returns The paths patched vs. left unchanged, merged over every patch.
5665
5842
  * @throws {Error} When the privacy manifest source is missing (before anything is written),
5666
- * or a project file lacks a line a patch needs.
5843
+ * a project file lacks a line a patch needs, or a debug key in `Info.plist` has no value.
5667
5844
  */
5668
5845
  async function patchIos(options) {
5669
5846
  const { projectDirectory, genDirectory, runner } = options;
@@ -5677,6 +5854,7 @@ async function patchIos(options) {
5677
5854
  await patchDeploymentTarget(projectDirectory, genDirectory, options.minimumVersion),
5678
5855
  await patchPrivacyManifest(projectDirectory, genDirectory, manifest)
5679
5856
  ];
5857
+ if (options.profile !== "debug") iosResults.push(await patchIosInfoPlist(projectDirectory, genDirectory));
5680
5858
  if (!runner) return mergePatchResults(...iosResults);
5681
5859
  const runnerResult = await patchRunner(projectDirectory, genDirectory, {
5682
5860
  target: "ios",
@@ -5735,20 +5913,23 @@ async function patchAndroid(options) {
5735
5913
  * byte, wherever the signing block sits. iOS gets the Xcode
5736
5914
  * entitlements-modification setting (without it the SECOND build of the same tree fails),
5737
5915
  * the deployment target and the privacy manifest (a kept tree never runs xcodegen again, so
5738
- * both land in `project.yml` AND `project.pbxproj`), then the runner command. The runner
5739
- * rewrite runs only when the caller supplies a `runner`. iOS takes no manifest entries, no
5740
- * background colour and no profile: its orientation lock and signing travel through the
5741
- * generated `Info.ios.plist` sidecar and tauri.conf.json, and its status bar adapts to the
5742
- * page on its own.
5916
+ * both land in `project.yml` AND `project.pbxproj`), outside the debug profile the removal of
5917
+ * the debug keys a debug build merged into `Info.plist`, then the runner command. The runner
5918
+ * rewrite runs only when the caller supplies a `runner`. iOS takes no manifest entries and no
5919
+ * background colour: its orientation lock and signing travel through the generated
5920
+ * `Info.ios.plist` sidecar and tauri.conf.json, and its status bar adapts to the page on its
5921
+ * own. Its profile is `opts.profile`, because `profile` below reads store for iOS.
5743
5922
  *
5744
5923
  * @param projectDirectory - The Tauri project root.
5745
- * @param opts - The mobile platform, and optionally the absolute Node/tauri.js runner pair.
5924
+ * @param opts - The mobile platform, optionally the absolute Node/tauri.js runner pair, and
5925
+ * the build profile, which iOS reads here; the store profile when omitted.
5746
5926
  * @param signing - The full signing config (`.android` on Android, the iOS minimum in
5747
5927
  * `.apple` on iOS).
5748
5928
  * @param manifest - Android manifest entries for the main activity (ignored on iOS).
5749
5929
  * @param backgroundColor - `app.backgroundColor`; the Android status bar icons, window
5750
5930
  * background and icon-splash background follow it (ignored on iOS).
5751
- * @param profile - The Android build profile; the store profile when omitted.
5931
+ * @param profile - The Android build profile, `dev` included as store; the store profile
5932
+ * when omitted (ignored on iOS).
5752
5933
  * @param privacyManifest - `ios.privacyManifest`, an absolute path; unset removes one a
5753
5934
  * previous pass added (ignored on Android).
5754
5935
  * @returns The paths patched vs. left unchanged, one merged report over every patch.
@@ -5757,8 +5938,8 @@ async function patchAndroid(options) {
5757
5938
  * written), manifest entries meet a missing manifest or an unclear main activity, a
5758
5939
  * background colour meets a tree without exactly one MainActivity.kt to style or without
5759
5940
  * the app theme to set the window background in; or when the iOS privacy manifest source
5760
- * is missing (before anything is written), or `project.yml` or `project.pbxproj` lacks a
5761
- * line a patch needs.
5941
+ * is missing (before anything is written), `project.yml` or `project.pbxproj` lacks a line
5942
+ * a patch needs, or a debug key in `Info.plist` has no value.
5762
5943
  */
5763
5944
  async function patchMobile(projectDirectory, opts, signing, manifest = [], backgroundColor, profile = STORE_PROFILE, privacyManifest) {
5764
5945
  const genDirectory = genDirectoryPath(projectDirectory, opts.target);
@@ -5767,7 +5948,8 @@ async function patchMobile(projectDirectory, opts, signing, manifest = [], backg
5767
5948
  genDirectory,
5768
5949
  runner: opts.runner,
5769
5950
  minimumVersion: signing.apple?.iosMinimumSystemVersion ?? "15.0",
5770
- privacyManifest
5951
+ privacyManifest,
5952
+ profile: opts.profile ?? "store"
5771
5953
  });
5772
5954
  return patchAndroid({
5773
5955
  projectDirectory,
@@ -6363,7 +6545,8 @@ function createProjectApi(ctx) {
6363
6545
  /**
6364
6546
  * Builds the Android profile one patch pass applies. The debug profile resolves the debug
6365
6547
  * keystore from `ctx.env` here (`HOME` ?? `USERPROFILE`), so the patch itself never reads
6366
- * the environment.
6548
+ * the environment. Every other case applies as store: the `dev` profile, and iOS, which reads
6549
+ * `opts.profile` itself.
6367
6550
  *
6368
6551
  * @param opts - See {@link Api.patchMobile}.
6369
6552
  * @returns The Android profile with its app name, keystore and log.
@@ -6383,7 +6566,7 @@ function createProjectApi(ctx) {
6383
6566
  /**
6384
6567
  * Implements {@link Api.patchMobile}: hands Android its build profile, its manifest
6385
6568
  * entries and `app.backgroundColor` (the status bar icons and the window background
6386
- * follow it), hands iOS `ios.privacyManifest`, then logs.
6569
+ * follow it), hands iOS `ios.privacyManifest` and its profile through `opts`, then logs.
6387
6570
  *
6388
6571
  * @param opts - See {@link Api.patchMobile}.
6389
6572
  * @returns See {@link Api.patchMobile}.
@@ -6394,7 +6577,7 @@ function createProjectApi(ctx) {
6394
6577
  const result = await patchMobile(ctx.global.projectDir, opts, ctx.global.signing, manifest, ctx.global.app.backgroundColor, profile, ctx.global.ios?.privacyManifest);
6395
6578
  ctx.log.info("project:patchMobile", {
6396
6579
  target: opts.target,
6397
- profile: profile.profile,
6580
+ profile: opts.profile ?? "store",
6398
6581
  patched: result.patched.length
6399
6582
  });
6400
6583
  return result;
@@ -8182,18 +8365,22 @@ const tauriPlugin = createPlugin$1("tauri", {
8182
8365
  //#endregion
8183
8366
  //#region src/plugins/build/phase.ts
8184
8367
  /**
8185
- * Picks the profile a build flavour asks for: `debug` set means the debug profile,
8186
- * anything else the store one.
8368
+ * Picks the profile a build flavour asks for: `debug` set means the debug profile, `dev` set
8369
+ * the dev one, anything else the store one. Both set name no profile and are refused here,
8370
+ * so every caller reads the refusal before its first phase.
8187
8371
  *
8188
8372
  * @param flavor - The build flavour of the run.
8189
- * @returns `"debug"` or `"store"`.
8373
+ * @returns `"debug"`, `"dev"` or `"store"`.
8374
+ * @throws {TypeError} `[native] debug and dev cannot be combined.` when both are set.
8190
8375
  * @example
8191
8376
  * ```ts
8192
- * profileOf({ debug: true }); // "debug"
8377
+ * profileOf({ dev: true }); // "dev"
8193
8378
  * ```
8194
8379
  */
8195
8380
  function profileOf(flavor) {
8196
- return flavor.debug === true ? "debug" : "store";
8381
+ if (flavor.debug === true && flavor.dev === true) throw new TypeError("[native] debug and dev cannot be combined.\n Build one profile: debug for the local app, dev for the store-signed test app.");
8382
+ if (flavor.debug === true) return "debug";
8383
+ return flavor.dev === true ? "dev" : "store";
8197
8384
  }
8198
8385
  /**
8199
8386
  * Emits one `native:phase` event, omitting `durationMs`/`detail` when absent rather than
@@ -8258,7 +8445,7 @@ function bundleRoot(projectDirectory, layout) {
8258
8445
  return node_path.default.join(projectDirectory, layout.root);
8259
8446
  }
8260
8447
  /**
8261
- * Names a build's delivery directory under `outDir`: the target for a store build,
8448
+ * Names a build's delivery directory under `outDir`: the target for a store or dev build,
8262
8449
  * `<target>-debug` for a debug one — so a debug installer never overwrites the store one.
8263
8450
  *
8264
8451
  * @param target - The packaging target being collected.
@@ -8490,8 +8677,9 @@ function storeAgentRefusal(dist, file) {
8490
8677
  /**
8491
8678
  * The checks at the end of compile/bundle, before anything is collected: on android the
8492
8679
  * shell link (the project plugin decides whether the profile composes the shell), then the
8493
- * page — a store build whose page carries the editor agent is refused. They run after the
8494
- * full compile because tauri runs the web build inside `tauri build`.
8680
+ * page — a store build whose page carries the editor agent is refused; a debug or dev build
8681
+ * may carry it. They run after the full compile because tauri runs the web build inside
8682
+ * `tauri build`.
8495
8683
  *
8496
8684
  * @param ctx - The build pipeline's domain context.
8497
8685
  * @param deps - The resolved project/tauri APIs.
@@ -8827,23 +9015,24 @@ function incompleteMobileTreeError(target, missing) {
8827
9015
  return /* @__PURE__ */ new Error(`[native] ${target} project tree is incomplete.\n Missing ${missing.join(", ")} — run \`native doctor\` to diagnose, or \`native clean --target ${target}\` to reset before rebuilding.`);
8828
9016
  }
8829
9017
  /**
8830
- * Refuses the debug profile for every target but android (Decision D2) — before any phase
8831
- * runs, and for ALL the targets of a run at once, so nothing is half-built.
9018
+ * Refuses the debug profile for every target but android and ios (Decision D2, widened to
9019
+ * iOS by F133) — before any phase runs, and for ALL the targets of a run at once, so nothing
9020
+ * is half-built.
8832
9021
  *
8833
9022
  * @param targets - Every target the run will build.
8834
9023
  * @param flavor - The build flavour of the run.
8835
- * @throws {Error} `[native] --debug builds Android only for now (asked for <target>).` for
8836
- * the first target that is not android, when `debug` is set.
9024
+ * @throws {Error} `[native] --debug builds Android and iOS only for now (asked for <target>).`
9025
+ * for the first target that is neither, when `debug` is set.
8837
9026
  * @example
8838
9027
  * ```ts
8839
- * assertDebugTargets(["android", "ios"], { debug: true }); // throws: asked for ios
9028
+ * assertDebugTargets(["android", "macos"], { debug: true }); // throws: asked for macos
8840
9029
  * ```
8841
9030
  */
8842
9031
  function assertDebugTargets(targets, flavor) {
8843
9032
  if (flavor.debug !== true) return;
8844
- const refused = targets.find((target) => target !== "android");
9033
+ const refused = targets.find((target) => !isMobileTarget(target));
8845
9034
  if (refused === void 0) return;
8846
- throw new Error(`[native] --debug builds Android only for now (asked for ${refused}).\n Build the debug profile for android, or drop debug to build ${refused}.`);
9035
+ throw new Error(`[native] --debug builds Android and iOS only for now (asked for ${refused}).\n Build the debug profile for android or ios, or drop debug to build ${refused}.`);
8847
9036
  }
8848
9037
  /**
8849
9038
  * Runs the `scaffold` phase: ensures `projectDir` exists. Nothing else — the mobile
@@ -8972,19 +9161,20 @@ async function runPrepare(ctx, deps, target, profile = "store") {
8972
9161
  * Runs the full `scaffold → codegen → icons → compile → bundle → collect` pipeline for
8973
9162
  * ONE target — sequential phases, each timed and reported via `native:phase`, stopping at
8974
9163
  * the first failing phase. Emits `native:complete` on success, with the run's profile. A
8975
- * debug run on any target but android is refused before the first phase.
9164
+ * debug run on any target but android and ios, and a run asking for `debug` and `dev`
9165
+ * together, are refused before the first phase.
8976
9166
  *
8977
9167
  * @param ctx - The build pipeline's domain context.
8978
9168
  * @param deps - The resolved project/tauri APIs.
8979
- * @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`).
9169
+ * @param opts - The target plus the platform build flags (`simulator`, `aab`, `debug`, `dev`).
8980
9170
  * @returns The completed pipeline's result, with all six phase timings and the profile.
8981
9171
  * @throws {Error} Whatever the failing phase throws (already reported via native:phase), or
8982
- * the debug-target refusal (before any phase event).
9172
+ * the debug-target or `debug` + `dev` refusal (before any phase event).
8983
9173
  */
8984
9174
  async function runPipeline(ctx, deps, opts) {
8985
9175
  const { target } = opts;
8986
- assertDebugTargets([target], opts);
8987
9176
  const profile = profileOf(opts);
9177
+ assertDebugTargets([target], opts);
8988
9178
  const startedAt = performance.now();
8989
9179
  const phases = [...await runPrepare(ctx, deps, target, profile)];
8990
9180
  const { compileDurationMs, bundleDurationMs } = await runCompileAndBundle(ctx, deps, opts);
@@ -8999,6 +9189,7 @@ async function runPipeline(ctx, deps, opts) {
8999
9189
  simulator: opts.simulator,
9000
9190
  aab: opts.aab,
9001
9191
  debug: opts.debug,
9192
+ dev: opts.dev,
9002
9193
  resolvePath: deps.project.resolveDerivedPath
9003
9194
  }));
9004
9195
  phases.push({
@@ -9071,13 +9262,15 @@ function createBuildApi(ctx, deps) {
9071
9262
  */
9072
9263
  async runAll(opts = {}) {
9073
9264
  const targets = opts.targets ?? ctx.global.targets;
9265
+ profileOf(opts);
9074
9266
  assertDebugTargets(targets, opts);
9075
9267
  const results = [];
9076
9268
  for (const target of targets) results.push(await runPipeline(ctx, deps, {
9077
9269
  target,
9078
9270
  simulator: opts.simulator,
9079
9271
  aab: opts.aab,
9080
- debug: opts.debug
9272
+ debug: opts.debug,
9273
+ dev: opts.dev
9081
9274
  }));
9082
9275
  return results;
9083
9276
  }
@@ -10978,13 +11171,14 @@ function createCliApi(ctx, deps) {
10978
11171
  * @returns See {@link Api.build}.
10979
11172
  */
10980
11173
  async build(opts = {}) {
10981
- const { simulator, aab, debug } = opts;
11174
+ const { simulator, aab, debug, dev } = opts;
10982
11175
  try {
10983
11176
  if (opts.all) {
10984
11177
  await build.runAll({
10985
11178
  simulator,
10986
11179
  aab,
10987
- debug
11180
+ debug,
11181
+ dev
10988
11182
  });
10989
11183
  return;
10990
11184
  }
@@ -10992,7 +11186,8 @@ function createCliApi(ctx, deps) {
10992
11186
  target: opts.target ?? hostTarget(),
10993
11187
  simulator,
10994
11188
  aab,
10995
- debug
11189
+ debug,
11190
+ dev
10996
11191
  });
10997
11192
  } catch (error) {
10998
11193
  renderBuildFailure(ui, error);