rork-xcode 0.4.0 → 0.6.0

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.js CHANGED
@@ -808,20 +808,26 @@ function buildPbxproj(root) {
808
808
  */
809
809
  const Isa = {
810
810
  aggregateTarget: "PBXAggregateTarget",
811
+ appleScriptBuildPhase: "PBXAppleScriptBuildPhase",
811
812
  buildFile: "PBXBuildFile",
812
813
  buildRule: "PBXBuildRule",
814
+ buildStyle: "PBXBuildStyle",
813
815
  containerItemProxy: "PBXContainerItemProxy",
814
816
  copyFilesBuildPhase: "PBXCopyFilesBuildPhase",
815
817
  fileReference: "PBXFileReference",
816
818
  fileSystemSynchronizedBuildFileExceptionSet: "PBXFileSystemSynchronizedBuildFileExceptionSet",
819
+ fileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet: "PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet",
817
820
  fileSystemSynchronizedRootGroup: "PBXFileSystemSynchronizedRootGroup",
818
821
  frameworksBuildPhase: "PBXFrameworksBuildPhase",
819
822
  group: "PBXGroup",
823
+ headersBuildPhase: "PBXHeadersBuildPhase",
820
824
  legacyTarget: "PBXLegacyTarget",
821
825
  nativeTarget: "PBXNativeTarget",
822
826
  project: "PBXProject",
823
827
  referenceProxy: "PBXReferenceProxy",
824
828
  resourcesBuildPhase: "PBXResourcesBuildPhase",
829
+ rezBuildPhase: "PBXRezBuildPhase",
830
+ shellScriptBuildPhase: "PBXShellScriptBuildPhase",
825
831
  sourcesBuildPhase: "PBXSourcesBuildPhase",
826
832
  targetDependency: "PBXTargetDependency",
827
833
  variantGroup: "PBXVariantGroup",
@@ -1025,6 +1031,15 @@ function stringItems(value) {
1025
1031
  * itself always reads through the narrowing accessors.
1026
1032
  */
1027
1033
  var XcodeObject = class {
1034
+ /**
1035
+ * The `isa` name this view class models. Each concrete view declares
1036
+ * its own, the factory registry routes objects of that isa to the
1037
+ * class, and the model tests keep the registry and these declarations
1038
+ * in agreement. Classes that only share behavior, like this base class
1039
+ * and the abstract target and phase bases, declare `null` and never
1040
+ * route.
1041
+ */
1042
+ static isa = null;
1028
1043
  /** The project this object belongs to. */
1029
1044
  project;
1030
1045
  /** The object's 24-character identifier (its key in `objects`). */
@@ -1135,11 +1150,11 @@ var XcodeObject = class {
1135
1150
  */
1136
1151
  /**
1137
1152
  * A `PBXGroup` is a folder in Xcode's navigator, holding references to
1138
- * files and other groups. Variant groups (`PBXVariantGroup`) share this
1139
- * view. The type parameter lets subclasses carry a more specific property
1140
- * shape.
1153
+ * files and other groups. The type parameter lets subclasses carry a more
1154
+ * specific property shape.
1141
1155
  */
1142
1156
  var Group = class Group extends XcodeObject {
1157
+ static isa = Isa.group;
1143
1158
  /**
1144
1159
  * Ids of the group's children, in navigator order. Non-string entries of
1145
1160
  * a malformed document are skipped.
@@ -1211,8 +1226,18 @@ var Group = class Group extends XcodeObject {
1211
1226
  }
1212
1227
  };
1213
1228
  /**
1229
+ * A `PBXVariantGroup` holds the localized variants of one file, one child
1230
+ * per language. Everything else behaves like a plain group.
1231
+ */
1232
+ var VariantGroup = class extends Group {
1233
+ static isa = Isa.variantGroup;
1234
+ };
1235
+ /**
1214
1236
  * A build phase is an ordered list of build files processed by one step
1215
- * of a target's build. Every `PBX*BuildPhase` kind shares this view.
1237
+ * of a target's build. Every `PBX*BuildPhase` kind extends this view, and
1238
+ * kinds without a class of their own still map here through the factory's
1239
+ * suffix fallback. The type parameter lets subclasses carry a more
1240
+ * specific property shape.
1216
1241
  */
1217
1242
  var BuildPhase = class extends XcodeObject {
1218
1243
  /**
@@ -1268,7 +1293,7 @@ var BuildPhase = class extends XcodeObject {
1268
1293
  const referenceKey = options.referenceKey ?? "fileRef";
1269
1294
  for (const buildFileId of this.buildFileIds) {
1270
1295
  const existing = this.project.get(buildFileId);
1271
- if (existing?.getString(referenceKey) === reference.id) return existing;
1296
+ if (BuildFile.is(existing) && existing.getString(referenceKey) === reference.id) return existing;
1272
1297
  }
1273
1298
  const buildFile = this.project.add(Isa.buildFile, {
1274
1299
  [referenceKey]: reference.id,
@@ -1279,10 +1304,110 @@ var BuildPhase = class extends XcodeObject {
1279
1304
  }
1280
1305
  };
1281
1306
  /**
1307
+ * A `PBXSourcesBuildPhase` compiles the target's source files.
1308
+ */
1309
+ var SourcesBuildPhase = class extends BuildPhase {
1310
+ static isa = Isa.sourcesBuildPhase;
1311
+ };
1312
+ /**
1313
+ * A `PBXFrameworksBuildPhase` links the target against frameworks,
1314
+ * libraries, and Swift package products.
1315
+ */
1316
+ var FrameworksBuildPhase = class extends BuildPhase {
1317
+ static isa = Isa.frameworksBuildPhase;
1318
+ };
1319
+ /**
1320
+ * A `PBXResourcesBuildPhase` copies the target's resources into the
1321
+ * built product.
1322
+ */
1323
+ var ResourcesBuildPhase = class extends BuildPhase {
1324
+ static isa = Isa.resourcesBuildPhase;
1325
+ };
1326
+ /**
1327
+ * A `PBXHeadersBuildPhase` installs a framework target's headers with
1328
+ * their public, private, or project visibility.
1329
+ */
1330
+ var HeadersBuildPhase = class extends BuildPhase {
1331
+ static isa = Isa.headersBuildPhase;
1332
+ };
1333
+ /**
1334
+ * A `PBXCopyFilesBuildPhase` copies its build files to a destination
1335
+ * inside the built product, which is how extensions and watch apps embed.
1336
+ */
1337
+ var CopyFilesBuildPhase = class extends BuildPhase {
1338
+ static isa = Isa.copyFilesBuildPhase;
1339
+ /**
1340
+ * The destination path inside the folder `dstSubfolderSpec` selects,
1341
+ * when present.
1342
+ */
1343
+ get dstPath() {
1344
+ return this.getString("dstPath");
1345
+ }
1346
+ };
1347
+ /**
1348
+ * A `PBXShellScriptBuildPhase` runs a script during the build.
1349
+ */
1350
+ var ShellScriptBuildPhase = class extends BuildPhase {
1351
+ static isa = Isa.shellScriptBuildPhase;
1352
+ /**
1353
+ * The script's source text, when present.
1354
+ */
1355
+ get shellScript() {
1356
+ return this.getString("shellScript");
1357
+ }
1358
+ /**
1359
+ * The interpreter the script runs under, when present. Xcode's default
1360
+ * is `/bin/sh`.
1361
+ */
1362
+ get shellPath() {
1363
+ return this.getString("shellPath");
1364
+ }
1365
+ };
1366
+ /**
1367
+ * A `PBXRezBuildPhase` runs Rez, the classic Mac OS resource compiler,
1368
+ * over `.r` files. Xcode's UI called it "Build Carbon Resources".
1369
+ * Current Xcode no longer creates these phases, but old documents still
1370
+ * carry them.
1371
+ */
1372
+ var RezBuildPhase = class extends BuildPhase {
1373
+ static isa = Isa.rezBuildPhase;
1374
+ };
1375
+ /**
1376
+ * A `PBXAppleScriptBuildPhase` compiles AppleScript sources. Current
1377
+ * Xcode no longer creates these, but old documents still carry them.
1378
+ */
1379
+ var AppleScriptBuildPhase = class extends BuildPhase {
1380
+ static isa = Isa.appleScriptBuildPhase;
1381
+ };
1382
+ /**
1383
+ * A `PBXBuildFile` places one file reference or package product inside
1384
+ * one build phase, optionally with per-file settings.
1385
+ */
1386
+ var BuildFile = class extends XcodeObject {
1387
+ static isa = Isa.buildFile;
1388
+ /**
1389
+ * The view of the file reference the build file points at, when it
1390
+ * points at one. Build files for Swift package products carry a
1391
+ * `productRef` instead; see {@link productDependency}.
1392
+ */
1393
+ fileReference() {
1394
+ return this.project.get(this.getString("fileRef"));
1395
+ }
1396
+ /**
1397
+ * The view of the Swift package product dependency the build file
1398
+ * points at, when it points at one.
1399
+ */
1400
+ productDependency() {
1401
+ const view = this.project.get(this.getString("productRef"));
1402
+ return SwiftPackageProductDependency.is(view) ? view : void 0;
1403
+ }
1404
+ };
1405
+ /**
1282
1406
  * A `PBXFileSystemSynchronizedRootGroup` is an Xcode 16 folder whose
1283
1407
  * members are synchronized from disk instead of listed individually.
1284
1408
  */
1285
1409
  var SyncRootGroup = class extends XcodeObject {
1410
+ static isa = Isa.fileSystemSynchronizedRootGroup;
1286
1411
  /**
1287
1412
  * The group's on-disk folder path, when present.
1288
1413
  */
@@ -1310,7 +1435,7 @@ var SyncRootGroup = class extends XcodeObject {
1310
1435
  addMembershipExceptions(target, membershipExceptions) {
1311
1436
  for (const id of stringItems(this.properties["exceptions"])) {
1312
1437
  const existing = this.project.get(id);
1313
- if (existing?.isa === Isa.fileSystemSynchronizedBuildFileExceptionSet && existing.getString("target") === target.id) {
1438
+ if (BuildFileExceptionSet.is(existing) && existing.getString("target") === target.id) {
1314
1439
  const names = ensureArray(existing.properties, "membershipExceptions");
1315
1440
  for (const name of membershipExceptions) if (!names.includes(name)) names.push(name);
1316
1441
  return existing;
@@ -1325,10 +1450,55 @@ var SyncRootGroup = class extends XcodeObject {
1325
1450
  }
1326
1451
  };
1327
1452
  /**
1453
+ * Behavior shared by the synchronized-folder exception set kinds, which
1454
+ * carve files out of a folder's automatic membership for one target. The
1455
+ * type parameter lets subclasses carry a more specific property shape.
1456
+ */
1457
+ var ExceptionSet = class extends XcodeObject {
1458
+ /**
1459
+ * The file names the set excludes, in declaration order. Non-string
1460
+ * entries of a malformed document are skipped.
1461
+ */
1462
+ get membershipExceptions() {
1463
+ return stringItems(this.properties["membershipExceptions"]);
1464
+ }
1465
+ /**
1466
+ * The view of the target whose membership the set restricts, when the
1467
+ * reference resolves.
1468
+ */
1469
+ target() {
1470
+ return this.project.get(this.getString("target"));
1471
+ }
1472
+ };
1473
+ /**
1474
+ * A `PBXFileSystemSynchronizedBuildFileExceptionSet` excludes files from
1475
+ * a synchronized folder's automatic target membership.
1476
+ */
1477
+ var BuildFileExceptionSet = class extends ExceptionSet {
1478
+ static isa = Isa.fileSystemSynchronizedBuildFileExceptionSet;
1479
+ };
1480
+ /**
1481
+ * A `PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet`
1482
+ * assigns some of a synchronized folder's files to a different build
1483
+ * phase than the automatic one.
1484
+ */
1485
+ var BuildPhaseMembershipExceptionSet = class extends ExceptionSet {
1486
+ static isa = Isa.fileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet;
1487
+ /**
1488
+ * The view of the build phase the listed files belong to, when the
1489
+ * reference resolves.
1490
+ */
1491
+ buildPhase() {
1492
+ const view = this.project.get(this.getString("buildPhase"));
1493
+ return BuildPhase.is(view) ? view : void 0;
1494
+ }
1495
+ };
1496
+ /**
1328
1497
  * A `PBXBuildRule` tells a target which compiler or script processes a
1329
1498
  * kind of file.
1330
1499
  */
1331
1500
  var BuildRule = class extends XcodeObject {
1501
+ static isa = Isa.buildRule;
1332
1502
  /**
1333
1503
  * The rule's script, when it is a script rule rather than a reference
1334
1504
  * to a compiler specification.
@@ -1343,6 +1513,7 @@ var BuildRule = class extends XcodeObject {
1343
1513
  * `currentVersion` names the active one.
1344
1514
  */
1345
1515
  var VersionGroup = class extends Group {
1516
+ static isa = Isa.versionGroup;
1346
1517
  /**
1347
1518
  * The view of the active model version's file reference, when the group
1348
1519
  * names one.
@@ -1365,6 +1536,7 @@ var VersionGroup = class extends Group {
1365
1536
  * target or of the project, for example Debug or Release.
1366
1537
  */
1367
1538
  var BuildConfiguration = class extends XcodeObject {
1539
+ static isa = Isa.buildConfiguration;
1368
1540
  /**
1369
1541
  * The configuration's name, when present.
1370
1542
  */
@@ -1382,10 +1554,33 @@ var BuildConfiguration = class extends XcodeObject {
1382
1554
  }
1383
1555
  };
1384
1556
  /**
1557
+ * A `PBXBuildStyle` is the pre-Xcode-2 predecessor of
1558
+ * `XCBuildConfiguration`. Current Xcode neither creates nor reads them,
1559
+ * but old documents still carry them.
1560
+ */
1561
+ var BuildStyle = class extends XcodeObject {
1562
+ static isa = Isa.buildStyle;
1563
+ /**
1564
+ * The style's name, when present.
1565
+ */
1566
+ get name() {
1567
+ return this.getString("name");
1568
+ }
1569
+ /**
1570
+ * The style's settings dictionary, or `undefined` when the style
1571
+ * carries none. The dictionary is live. Writes through it land in the
1572
+ * document.
1573
+ */
1574
+ get buildSettings() {
1575
+ return asDictionary(this.properties["buildSettings"]);
1576
+ }
1577
+ };
1578
+ /**
1385
1579
  * A `PBXFileReference` names one file on disk, from source files to the
1386
1580
  * built products themselves.
1387
1581
  */
1388
1582
  var FileReference = class extends XcodeObject {
1583
+ static isa = Isa.fileReference;
1389
1584
  /**
1390
1585
  * The reference's path, relative to its `sourceTree`, when present.
1391
1586
  */
@@ -1405,6 +1600,7 @@ var FileReference = class extends XcodeObject {
1405
1600
  * target dependency and the target it points at.
1406
1601
  */
1407
1602
  var ContainerItemProxy = class extends XcodeObject {
1603
+ static isa = Isa.containerItemProxy;
1408
1604
  /**
1409
1605
  * The display name of the object the proxy points at, when present.
1410
1606
  * For target dependencies this is the target's name.
@@ -1414,10 +1610,111 @@ var ContainerItemProxy = class extends XcodeObject {
1414
1610
  }
1415
1611
  };
1416
1612
  /**
1613
+ * A `PBXTargetDependency` records that one target must build before
1614
+ * another, through a container item proxy naming the prerequisite.
1615
+ */
1616
+ var TargetDependency = class extends XcodeObject {
1617
+ static isa = Isa.targetDependency;
1618
+ /**
1619
+ * The view of the target this dependency points at, when the reference
1620
+ * resolves to one inside this document.
1621
+ */
1622
+ target() {
1623
+ return this.project.get(this.getString("target"));
1624
+ }
1625
+ /**
1626
+ * The view of the dependency's container item proxy, when the reference
1627
+ * resolves.
1628
+ */
1629
+ targetProxy() {
1630
+ const view = this.project.get(this.getString("targetProxy"));
1631
+ return ContainerItemProxy.is(view) ? view : void 0;
1632
+ }
1633
+ };
1634
+ /**
1635
+ * An `XCConfigurationList` owns the named build configurations of one
1636
+ * target or of the project, plus the default configuration choice.
1637
+ */
1638
+ var ConfigurationList = class extends XcodeObject {
1639
+ static isa = Isa.configurationList;
1640
+ /**
1641
+ * The name of the configuration builds use when none is specified, when
1642
+ * present.
1643
+ */
1644
+ get defaultConfigurationName() {
1645
+ return this.getString("defaultConfigurationName");
1646
+ }
1647
+ /**
1648
+ * The views of the list's build configurations, in list order. Dangling
1649
+ * ids and objects of other kinds are skipped.
1650
+ */
1651
+ configurations() {
1652
+ const configurations = [];
1653
+ for (const id of stringItems(this.properties["buildConfigurations"])) {
1654
+ const view = this.project.get(id);
1655
+ if (BuildConfiguration.is(view)) configurations.push(view);
1656
+ }
1657
+ return configurations;
1658
+ }
1659
+ };
1660
+ /**
1661
+ * Behavior shared by the Swift package reference kinds. The type
1662
+ * parameter lets subclasses carry a more specific property shape.
1663
+ */
1664
+ var SwiftPackageReference = class extends XcodeObject {};
1665
+ /**
1666
+ * An `XCRemoteSwiftPackageReference` names a package repository and a
1667
+ * version requirement.
1668
+ */
1669
+ var RemoteSwiftPackageReference = class extends SwiftPackageReference {
1670
+ static isa = Isa.remoteSwiftPackageReference;
1671
+ /**
1672
+ * The package's repository URL, when present.
1673
+ */
1674
+ get repositoryURL() {
1675
+ return this.getString("repositoryURL");
1676
+ }
1677
+ };
1678
+ /**
1679
+ * An `XCLocalSwiftPackageReference` names a package directory relative
1680
+ * to the project.
1681
+ */
1682
+ var LocalSwiftPackageReference = class extends SwiftPackageReference {
1683
+ static isa = Isa.localSwiftPackageReference;
1684
+ /**
1685
+ * The package's path relative to the project, when present.
1686
+ */
1687
+ get relativePath() {
1688
+ return this.getString("relativePath");
1689
+ }
1690
+ };
1691
+ /**
1692
+ * An `XCSwiftPackageProductDependency` links one product of a Swift
1693
+ * package to the target that consumes it.
1694
+ */
1695
+ var SwiftPackageProductDependency = class extends XcodeObject {
1696
+ static isa = Isa.swiftPackageProductDependency;
1697
+ /**
1698
+ * The product's name as the package manifest declares it, when present.
1699
+ */
1700
+ get productName() {
1701
+ return this.getString("productName");
1702
+ }
1703
+ /**
1704
+ * The view of the package reference the product comes from, when the
1705
+ * reference resolves. Products of local packages can omit it.
1706
+ */
1707
+ packageReference() {
1708
+ const view = this.project.get(this.getString("package"));
1709
+ return SwiftPackageReference.is(view) ? view : void 0;
1710
+ }
1711
+ };
1712
+ /**
1417
1713
  * A `PBXReferenceProxy` stands in for a product built by a target of
1418
1714
  * another project referenced from this one.
1419
1715
  */
1420
1716
  var ReferenceProxy = class extends XcodeObject {
1717
+ static isa = Isa.referenceProxy;
1421
1718
  /**
1422
1719
  * The proxy's product path inside the other project's build directory,
1423
1720
  * when present.
@@ -1430,8 +1727,8 @@ var ReferenceProxy = class extends XcodeObject {
1430
1727
  * when the reference resolves.
1431
1728
  */
1432
1729
  remoteReference() {
1433
- const id = this.getString("remoteRef");
1434
- return id == null ? void 0 : this.project.get(id);
1730
+ const view = this.project.get(this.getString("remoteRef"));
1731
+ return ContainerItemProxy.is(view) ? view : void 0;
1435
1732
  }
1436
1733
  };
1437
1734
  //#endregion
@@ -2408,6 +2705,7 @@ const LIST_REFERENCE_PROPERTIES = [
2408
2705
  "buildConfigurations",
2409
2706
  "buildPhases",
2410
2707
  "buildRules",
2708
+ "buildStyles",
2411
2709
  "children",
2412
2710
  "dependencies",
2413
2711
  "exceptions",
@@ -2534,7 +2832,7 @@ function pruneOrphanObjects(project) {
2534
2832
  */
2535
2833
  /**
2536
2834
  * The views of a configuration list's build configurations, in list order.
2537
- * Dangling ids and non-dictionary entries of malformed documents are
2835
+ * Dangling ids and objects of other kinds in malformed documents are
2538
2836
  * skipped.
2539
2837
  */
2540
2838
  function configurationsOf(project, configurationListId) {
@@ -2542,7 +2840,7 @@ function configurationsOf(project, configurationListId) {
2542
2840
  const configurations = [];
2543
2841
  for (const id of stringItems(list?.["buildConfigurations"])) {
2544
2842
  const configuration = project.get(id);
2545
- if (configuration != null) configurations.push(configuration);
2843
+ if (BuildConfiguration.is(configuration)) configurations.push(configuration);
2546
2844
  }
2547
2845
  return configurations;
2548
2846
  }
@@ -2588,16 +2886,24 @@ var Target = class extends XcodeObject {
2588
2886
  return this.getString("name");
2589
2887
  }
2590
2888
  /**
2889
+ * The view of the target's configuration list, when the reference
2890
+ * resolves.
2891
+ */
2892
+ configurationList() {
2893
+ const view = this.project.get(this.getString("buildConfigurationList"));
2894
+ return ConfigurationList.is(view) ? view : void 0;
2895
+ }
2896
+ /**
2591
2897
  * The views of the target's build configurations, in list order.
2592
2898
  */
2593
2899
  buildConfigurations() {
2594
2900
  return configurationsOf(this.project, this.getString("buildConfigurationList"));
2595
2901
  }
2596
2902
  /**
2597
- * The settings dictionary of the target's default configuration: the one
2598
- * named by the list's `defaultConfigurationName`, falling back to the
2599
- * first configuration. Returns `undefined` when the target has no
2600
- * configurations or the default carries no settings dictionary.
2903
+ * The settings dictionary of the target's default configuration, which
2904
+ * is the one named by the list's `defaultConfigurationName`, falling
2905
+ * back to the first configuration. Returns `undefined` when the target
2906
+ * has no configurations or the default carries no settings dictionary.
2601
2907
  */
2602
2908
  defaultConfigurationSettings() {
2603
2909
  return defaultConfigurationSettingsOf(this.project, this.getString("buildConfigurationList"));
@@ -2623,8 +2929,8 @@ var Target = class extends XcodeObject {
2623
2929
  */
2624
2930
  setBuildSetting(key, value) {
2625
2931
  for (const configuration of this.buildConfigurations()) {
2626
- const settings = asDictionary(configuration.properties["buildSettings"]);
2627
- if (settings == null) configuration.properties["buildSettings"] = { [key]: value };
2932
+ const settings = configuration.buildSettings;
2933
+ if (settings == null) configuration.properties.buildSettings = { [key]: value };
2628
2934
  else settings[key] = value;
2629
2935
  }
2630
2936
  }
@@ -2633,17 +2939,16 @@ var Target = class extends XcodeObject {
2633
2939
  */
2634
2940
  removeBuildSetting(key) {
2635
2941
  for (const configuration of this.buildConfigurations()) {
2636
- const settings = asDictionary(configuration.properties["buildSettings"]);
2942
+ const settings = configuration.buildSettings;
2637
2943
  if (settings != null) delete settings[key];
2638
2944
  }
2639
2945
  }
2640
2946
  /**
2641
- * The views of the target's dependency objects
2642
- * (`PBXTargetDependency`), in declaration order. Resolve a dependency's
2643
- * target through its `target` property.
2947
+ * The views of the target's dependencies, in declaration order. Resolve
2948
+ * a dependency's target through {@link TargetDependency.target}.
2644
2949
  */
2645
2950
  dependencies() {
2646
- return this.referencedViews("dependencies");
2951
+ return this.referencedViews("dependencies").filter((view) => TargetDependency.is(view));
2647
2952
  }
2648
2953
  /**
2649
2954
  * The views of the target's build phases, in build order.
@@ -2658,7 +2963,9 @@ var Target = class extends XcodeObject {
2658
2963
  }
2659
2964
  /**
2660
2965
  * Finds the target's first build phase with the given isa, and, when
2661
- * `name` is provided, the given display name.
2966
+ * `name` is provided, the given display name. An isa literal of the
2967
+ * vocabulary types the result, so `findBuildPhase(Isa.copyFilesBuildPhase)`
2968
+ * gives a `CopyFilesBuildPhase | undefined`.
2662
2969
  */
2663
2970
  findBuildPhase(isa, name) {
2664
2971
  return this.buildPhases().find((phase) => phase.isa === isa && (name == null || phase.name === name));
@@ -2666,7 +2973,8 @@ var Target = class extends XcodeObject {
2666
2973
  /**
2667
2974
  * Returns the target's build phase with the given isa and properties,
2668
2975
  * creating and appending it when missing. The properties apply only on
2669
- * creation; an existing phase is returned as is.
2976
+ * creation. An existing phase is returned as is, already typed as the
2977
+ * phase class the isa names.
2670
2978
  *
2671
2979
  * The match key is the isa plus the `name` property when one is given,
2672
2980
  * so differently named copy-files phases coexist.
@@ -2694,7 +3002,7 @@ var Target = class extends XcodeObject {
2694
3002
  * @param properties Phase properties, most usefully `shellScript`.
2695
3003
  */
2696
3004
  ensureShellScriptPhase(name, properties = {}) {
2697
- return this.ensureBuildPhase("PBXShellScriptBuildPhase", {
3005
+ return this.ensureBuildPhase(Isa.shellScriptBuildPhase, {
2698
3006
  inputFileListPaths: [],
2699
3007
  inputPaths: [],
2700
3008
  name,
@@ -2713,10 +3021,7 @@ var Target = class extends XcodeObject {
2713
3021
  * @returns The view of the target dependency object.
2714
3022
  */
2715
3023
  addDependency(dependency) {
2716
- for (const id of stringItems(this.properties["dependencies"])) {
2717
- const existing = this.project.get(id);
2718
- if (existing?.getString("target") === dependency.id) return existing;
2719
- }
3024
+ for (const dependencyView of this.dependencies()) if (dependencyView.getString("target") === dependency.id) return dependencyView;
2720
3025
  const proxy = this.project.add(Isa.containerItemProxy, {
2721
3026
  containerPortal: this.project.rootProject.id,
2722
3027
  proxyType: 1,
@@ -2736,6 +3041,7 @@ var Target = class extends XcodeObject {
2736
3041
  * itself, such as an application or an app extension.
2737
3042
  */
2738
3043
  var NativeTarget = class extends Target {
3044
+ static isa = Isa.nativeTarget;
2739
3045
  /**
2740
3046
  * The target's product type identifier, for example
2741
3047
  * `com.apple.product-type.application`.
@@ -2755,8 +3061,8 @@ var NativeTarget = class extends Target {
2755
3061
  * one.
2756
3062
  */
2757
3063
  get productReference() {
2758
- const id = this.getString("productReference");
2759
- return id == null ? void 0 : this.project.get(id);
3064
+ const view = this.project.get(this.getString("productReference"));
3065
+ return FileReference.is(view) ? view : void 0;
2760
3066
  }
2761
3067
  /**
2762
3068
  * Whether the target builds for watchOS, decided by its product type or
@@ -2772,21 +3078,21 @@ var NativeTarget = class extends Target {
2772
3078
  * declaration order.
2773
3079
  */
2774
3080
  packageProductDependencies() {
2775
- return this.referencedViews("packageProductDependencies");
3081
+ return this.referencedViews("packageProductDependencies").filter((view) => SwiftPackageProductDependency.is(view));
2776
3082
  }
2777
3083
  /**
2778
3084
  * The views of the target's file-system-synchronized folders, in
2779
3085
  * declaration order.
2780
3086
  */
2781
3087
  syncGroups() {
2782
- return this.referencedViews("fileSystemSynchronizedGroups").filter((view) => view instanceof SyncRootGroup);
3088
+ return this.referencedViews("fileSystemSynchronizedGroups").filter((view) => SyncRootGroup.is(view));
2783
3089
  }
2784
3090
  /**
2785
3091
  * The views of the target's build rules, in evaluation order. Empty for
2786
3092
  * targets without custom rules, which is nearly all of them.
2787
3093
  */
2788
3094
  buildRules() {
2789
- return this.referencedViews("buildRules").filter((view) => view instanceof BuildRule);
3095
+ return this.referencedViews("buildRules").filter((view) => BuildRule.is(view));
2790
3096
  }
2791
3097
  /**
2792
3098
  * The target's sources phase, created when missing.
@@ -2836,9 +3142,8 @@ var NativeTarget = class extends Target {
2836
3142
  */
2837
3143
  syncGroupPaths() {
2838
3144
  const paths = [];
2839
- for (const id of stringItems(this.properties["fileSystemSynchronizedGroups"])) {
2840
- const group = this.project.get(id);
2841
- const path = group instanceof SyncRootGroup ? group.path : void 0;
3145
+ for (const group of this.syncGroups()) {
3146
+ const path = group.path;
2842
3147
  if (path != null) paths.push(path);
2843
3148
  }
2844
3149
  return paths;
@@ -2855,10 +3160,7 @@ var NativeTarget = class extends Target {
2855
3160
  * @returns The view of the target's synchronized folder for the path.
2856
3161
  */
2857
3162
  addSyncGroup(path) {
2858
- for (const id of stringItems(this.properties["fileSystemSynchronizedGroups"])) {
2859
- const existing = this.project.get(id);
2860
- if (existing instanceof SyncRootGroup && existing.path === path) return existing;
2861
- }
3163
+ for (const existing of this.syncGroups()) if (existing.path === path) return existing;
2862
3164
  const group = this.project.add(Isa.fileSystemSynchronizedRootGroup, {
2863
3165
  path,
2864
3166
  sourceTree: "<group>"
@@ -2881,10 +3183,7 @@ var NativeTarget = class extends Target {
2881
3183
  * @returns The view of the product dependency.
2882
3184
  */
2883
3185
  addSwiftPackageProduct(options) {
2884
- for (const id of stringItems(this.properties["packageProductDependencies"])) {
2885
- const existing = this.project.get(id);
2886
- if (existing?.getString("productName") === options.productName && existing.getString("package") === options.packageReference.id) return existing;
2887
- }
3186
+ for (const existing of this.packageProductDependencies()) if (existing.productName === options.productName && existing.getString("package") === options.packageReference.id) return existing;
2888
3187
  const productDependency = this.project.add(Isa.swiftPackageProductDependency, {
2889
3188
  package: options.packageReference.id,
2890
3189
  productName: options.productName
@@ -2905,7 +3204,7 @@ var NativeTarget = class extends Target {
2905
3204
  addSystemFramework(name) {
2906
3205
  const path = `System/Library/Frameworks/${name}.framework`;
2907
3206
  let reference;
2908
- for (const [, view] of this.project.objects()) if (view.isa === Isa.fileReference && view.getString("path") === path) {
3207
+ for (const [, view] of this.project.objects()) if (FileReference.is(view) && view.path === path) {
2909
3208
  reference = view;
2910
3209
  break;
2911
3210
  }
@@ -2924,12 +3223,15 @@ var NativeTarget = class extends Target {
2924
3223
  * targets through its dependencies and to run script or copy-files
2925
3224
  * phases, and the shared target surface covers everything it carries.
2926
3225
  */
2927
- var AggregateTarget = class extends Target {};
3226
+ var AggregateTarget = class extends Target {
3227
+ static isa = Isa.aggregateTarget;
3228
+ };
2928
3229
  /**
2929
3230
  * A legacy target shells out to an external build tool such as make
2930
3231
  * instead of using Xcode's build system.
2931
3232
  */
2932
3233
  var LegacyTarget = class extends Target {
3234
+ static isa = Isa.legacyTarget;
2933
3235
  /**
2934
3236
  * The build tool the target invokes, as an absolute path.
2935
3237
  */
@@ -2970,6 +3272,7 @@ var LegacyTarget = class extends Target {
2970
3272
  * the main group, and the project-level configurations.
2971
3273
  */
2972
3274
  var RootProject = class extends XcodeObject {
3275
+ static isa = Isa.project;
2973
3276
  /**
2974
3277
  * Ids of the project's targets, in project order.
2975
3278
  */
@@ -2982,7 +3285,7 @@ var RootProject = class extends XcodeObject {
2982
3285
  */
2983
3286
  mainGroup() {
2984
3287
  const group = this.project.get(this.getString("mainGroup"));
2985
- return group instanceof Group ? group : void 0;
3288
+ return Group.is(group) ? group : void 0;
2986
3289
  }
2987
3290
  /**
2988
3291
  * The settings dictionary of the project-level default configuration.
@@ -2997,7 +3300,7 @@ var RootProject = class extends XcodeObject {
2997
3300
  * in declaration order.
2998
3301
  */
2999
3302
  packageReferences() {
3000
- return this.referencedViews("packageReferences");
3303
+ return this.referencedViews("packageReferences").filter((view) => SwiftPackageReference.is(view));
3001
3304
  }
3002
3305
  /**
3003
3306
  * The group product references live in, creating it (and registering it
@@ -3005,7 +3308,7 @@ var RootProject = class extends XcodeObject {
3005
3308
  */
3006
3309
  ensureProductsGroup() {
3007
3310
  const existing = this.project.get(this.getString("productRefGroup"));
3008
- if (existing instanceof Group) return existing;
3311
+ if (Group.is(existing)) return existing;
3009
3312
  const group = this.project.add(Isa.group, {
3010
3313
  children: [],
3011
3314
  name: "Products",
@@ -3120,13 +3423,16 @@ var XcodeProject = class XcodeProject {
3120
3423
  return generateObjectId(seed, new Set(Object.keys(this.objectsDictionary)));
3121
3424
  }
3122
3425
  /**
3123
- * Adds an object to the document and returns its view.
3426
+ * Adds an object to the document and returns its view. When the isa is
3427
+ * a literal of the vocabulary, the returned view is already the exact
3428
+ * class for it, so `add(Isa.fileReference, ...)` gives a `FileReference`
3429
+ * with no cast at the call site.
3124
3430
  *
3125
- * @param isa The object's kind; written as the `isa` property.
3431
+ * @param isa The object's kind, written as the `isa` property.
3126
3432
  * @param properties The object's remaining properties. The dictionary is
3127
3433
  * stored as passed (not copied), with `isa` written first so the
3128
3434
  * serialized entry leads with it.
3129
- * @param seed Seed for the deterministic id; defaults to the isa, which
3435
+ * @param seed Seed for the deterministic id. Defaults to the isa, which
3130
3436
  * is only sensible for singleton objects.
3131
3437
  * @returns The view of the created object.
3132
3438
  */
@@ -3229,20 +3535,16 @@ var XcodeProject = class XcodeProject {
3229
3535
  productType: options.productType
3230
3536
  }, `${Isa.nativeTarget} ${options.name}`);
3231
3537
  ensureArray(this.rootProject.properties, "targets").push(target.id);
3232
- const nativeTarget = target;
3233
- nativeTarget.ensureSourcesPhase();
3234
- nativeTarget.ensureFrameworksPhase();
3235
- nativeTarget.ensureResourcesPhase();
3236
- return nativeTarget;
3538
+ target.ensureSourcesPhase();
3539
+ target.ensureFrameworksPhase();
3540
+ target.ensureResourcesPhase();
3541
+ return target;
3237
3542
  }
3238
3543
  /**
3239
3544
  * Finds the remote Swift package reference for a repository URL.
3240
3545
  */
3241
3546
  findSwiftPackage(repositoryUrl) {
3242
- for (const id of stringItems(this.rootProject.properties["packageReferences"])) {
3243
- const reference = this.get(id);
3244
- if (reference?.getString("repositoryURL") === repositoryUrl) return reference;
3245
- }
3547
+ return this.rootProject.packageReferences().filter((reference) => RemoteSwiftPackageReference.is(reference)).find((reference) => reference.repositoryURL === repositoryUrl);
3246
3548
  }
3247
3549
  /**
3248
3550
  * Adds a remote Swift package reference and registers it on the project.
@@ -3271,7 +3573,7 @@ var XcodeProject = class XcodeProject {
3271
3573
  * Finds the local Swift package reference for a directory path.
3272
3574
  */
3273
3575
  findLocalSwiftPackage(relativePath) {
3274
- return this.rootProject.packageReferences().find((reference) => reference.isa === Isa.localSwiftPackageReference && reference.getString("relativePath") === relativePath);
3576
+ return this.rootProject.packageReferences().filter((reference) => LocalSwiftPackageReference.is(reference)).find((reference) => reference.relativePath === relativePath);
3275
3577
  }
3276
3578
  /**
3277
3579
  * Adds a local (path-based) Swift package reference and registers it on
@@ -3296,7 +3598,7 @@ var XcodeProject = class XcodeProject {
3296
3598
  */
3297
3599
  buildFilesReferencing(reference) {
3298
3600
  const buildFiles = [];
3299
- for (const [, view] of this.objects()) if (view.isa === Isa.buildFile && (view.getString("fileRef") === reference.id || view.getString("productRef") === reference.id)) buildFiles.push(view);
3601
+ for (const [, view] of this.objects()) if (BuildFile.is(view) && (view.getString("fileRef") === reference.id || view.getString("productRef") === reference.id)) buildFiles.push(view);
3300
3602
  return buildFiles;
3301
3603
  }
3302
3604
  /**
@@ -3428,29 +3730,62 @@ var XcodeProject = class XcodeProject {
3428
3730
  return search(mainGroup, "");
3429
3731
  }
3430
3732
  /**
3431
- * Creates the typed view for an object, dispatching on its isa. Objects
3432
- * outside the typed vocabulary get the generic base view.
3733
+ * Creates the typed view for an object, dispatching on the isa each
3734
+ * view class declares. Unknown `PBX*BuildPhase` kinds still map to
3735
+ * {@link BuildPhase}, and everything else outside the vocabulary gets
3736
+ * the generic base view.
3433
3737
  */
3434
3738
  createView(id, isa) {
3435
- switch (isa) {
3436
- case Isa.nativeTarget: return new NativeTarget(this, id);
3437
- case Isa.aggregateTarget: return new AggregateTarget(this, id);
3438
- case Isa.legacyTarget: return new LegacyTarget(this, id);
3439
- case Isa.project: return new RootProject(this, id);
3440
- case Isa.group:
3441
- case Isa.variantGroup: return new Group(this, id);
3442
- case Isa.versionGroup: return new VersionGroup(this, id);
3443
- case Isa.fileSystemSynchronizedRootGroup: return new SyncRootGroup(this, id);
3444
- case Isa.buildRule: return new BuildRule(this, id);
3445
- case Isa.buildConfiguration: return new BuildConfiguration(this, id);
3446
- case Isa.fileReference: return new FileReference(this, id);
3447
- case Isa.containerItemProxy: return new ContainerItemProxy(this, id);
3448
- case Isa.referenceProxy: return new ReferenceProxy(this, id);
3449
- default: return isa.endsWith("BuildPhase") ? new BuildPhase(this, id) : new XcodeObject(this, id);
3450
- }
3739
+ const View = VIEW_BY_ISA.get(isa);
3740
+ if (View != null) return new View(this, id);
3741
+ return isa.endsWith("BuildPhase") ? new BuildPhase(this, id) : new XcodeObject(this, id);
3451
3742
  }
3452
3743
  };
3453
3744
  /**
3745
+ * The view class for every isa of the vocabulary. The runtime registry
3746
+ * and the {@link ViewByIsa} type are both derived from this one object,
3747
+ * so the class an object routes to and the class its isa literal promises
3748
+ * are always the same. The `satisfies` clause keeps the object covering
3749
+ * the whole vocabulary, and the model tests check that every entry agrees
3750
+ * with its class's own `isa` declaration.
3751
+ */
3752
+ const VIEWS = {
3753
+ [Isa.aggregateTarget]: AggregateTarget,
3754
+ [Isa.appleScriptBuildPhase]: AppleScriptBuildPhase,
3755
+ [Isa.buildConfiguration]: BuildConfiguration,
3756
+ [Isa.buildFile]: BuildFile,
3757
+ [Isa.buildRule]: BuildRule,
3758
+ [Isa.buildStyle]: BuildStyle,
3759
+ [Isa.configurationList]: ConfigurationList,
3760
+ [Isa.containerItemProxy]: ContainerItemProxy,
3761
+ [Isa.copyFilesBuildPhase]: CopyFilesBuildPhase,
3762
+ [Isa.fileReference]: FileReference,
3763
+ [Isa.fileSystemSynchronizedBuildFileExceptionSet]: BuildFileExceptionSet,
3764
+ [Isa.fileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet]: BuildPhaseMembershipExceptionSet,
3765
+ [Isa.fileSystemSynchronizedRootGroup]: SyncRootGroup,
3766
+ [Isa.frameworksBuildPhase]: FrameworksBuildPhase,
3767
+ [Isa.group]: Group,
3768
+ [Isa.headersBuildPhase]: HeadersBuildPhase,
3769
+ [Isa.legacyTarget]: LegacyTarget,
3770
+ [Isa.localSwiftPackageReference]: LocalSwiftPackageReference,
3771
+ [Isa.nativeTarget]: NativeTarget,
3772
+ [Isa.project]: RootProject,
3773
+ [Isa.referenceProxy]: ReferenceProxy,
3774
+ [Isa.remoteSwiftPackageReference]: RemoteSwiftPackageReference,
3775
+ [Isa.resourcesBuildPhase]: ResourcesBuildPhase,
3776
+ [Isa.rezBuildPhase]: RezBuildPhase,
3777
+ [Isa.shellScriptBuildPhase]: ShellScriptBuildPhase,
3778
+ [Isa.sourcesBuildPhase]: SourcesBuildPhase,
3779
+ [Isa.swiftPackageProductDependency]: SwiftPackageProductDependency,
3780
+ [Isa.targetDependency]: TargetDependency,
3781
+ [Isa.variantGroup]: VariantGroup,
3782
+ [Isa.versionGroup]: VersionGroup
3783
+ };
3784
+ /**
3785
+ * View constructors by the isa they model, in `Map` form for the factory.
3786
+ */
3787
+ const VIEW_BY_ISA = new Map(Object.entries(VIEWS));
3788
+ /**
3454
3789
  * Joins two path segments with a `/`, treating an empty prefix as the
3455
3790
  * project root.
3456
3791
  */
@@ -4161,4 +4496,4 @@ function createXcscheme(options) {
4161
4496
  };
4162
4497
  }
4163
4498
  //#endregion
4164
- export { AggregateTarget, BuildConfiguration, BuildPhase, BuildRule, BuildableReference, ContainerItemProxy, CopyFilesDestination, FileReference, Group, Isa, LegacyTarget, NativeTarget, PbxprojBuildError, PbxprojParseError, ProductType, ReferenceProxy, RootProject, SyncRootGroup, Target, VersionGroup, XcodeModelError, XcodeObject, XcodeProject, Xcscheme, XcschemeBuildError, XcschemeParseError, buildPbxproj, buildXcscheme, createXcscheme, generateObjectId, isXcschemeElement, parsePbxproj, parseXcscheme, xcschemeElements };
4499
+ export { AggregateTarget, AppleScriptBuildPhase, BuildConfiguration, BuildFile, BuildFileExceptionSet, BuildPhase, BuildPhaseMembershipExceptionSet, BuildRule, BuildStyle, BuildableReference, ConfigurationList, ContainerItemProxy, CopyFilesBuildPhase, CopyFilesDestination, ExceptionSet, FileReference, FrameworksBuildPhase, Group, HeadersBuildPhase, Isa, LegacyTarget, LocalSwiftPackageReference, NativeTarget, PbxprojBuildError, PbxprojParseError, ProductType, ReferenceProxy, RemoteSwiftPackageReference, ResourcesBuildPhase, RezBuildPhase, RootProject, ShellScriptBuildPhase, SourcesBuildPhase, SwiftPackageProductDependency, SwiftPackageReference, SyncRootGroup, Target, TargetDependency, VariantGroup, VersionGroup, XcodeModelError, XcodeObject, XcodeProject, Xcscheme, XcschemeBuildError, XcschemeParseError, buildPbxproj, buildXcscheme, createXcscheme, generateObjectId, isXcschemeElement, parsePbxproj, parseXcscheme, xcschemeElements };