peachsim 0.1.2429 → 0.1.2431

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.
Files changed (104) hide show
  1. package/cli/commands/preview.ts +2 -1
  2. package/cli/outbound-endpoints.ts +10 -2
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/bundle-channel.cjs +15792 -5999
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/config.mjs +1 -1
  26. package/dist-lib/detox/index.cjs +1 -1
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/expo-swift-bundle.cjs +14638 -4887
  29. package/dist-lib/expo-swift-metadata.cjs +1 -1
  30. package/dist-lib/expo-swift-metadata.mjs +1 -1
  31. package/dist-lib/home-paths.cjs +1 -1
  32. package/dist-lib/host/bridge-host.cjs +15465 -5754
  33. package/dist-lib/host/fetch-proxy-handler.cjs +3205 -54
  34. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  36. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  37. package/dist-lib/host/websocket-proxy.cjs +1 -1
  38. package/dist-lib/index.cjs +3542 -391
  39. package/dist-lib/jump-to-source-babel.cjs +1 -1
  40. package/dist-lib/jump-to-source-native.cjs +1 -1
  41. package/dist-lib/kotlin-host.cjs +1 -1
  42. package/dist-lib/menu.cjs +1 -1
  43. package/dist-lib/menu.mjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  46. package/dist-lib/metro-production-bundle.cjs +1 -1
  47. package/dist-lib/metro-production-bundle.mjs +1 -1
  48. package/dist-lib/metro.cjs +3438 -287
  49. package/dist-lib/native-app-identity-project.cjs +2 -2
  50. package/dist-lib/native-app-identity-project.mjs +2 -2
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/pdfium-raster.cjs +1 -1
  56. package/dist-lib/pdfium-raster.mjs +1 -1
  57. package/dist-lib/plist.cjs +1 -1
  58. package/dist-lib/plist.mjs +1 -1
  59. package/dist-lib/profiles.cjs +1 -1
  60. package/dist-lib/public-brand.cjs +1 -1
  61. package/dist-lib/public-origins-lib-esm.json +24 -24
  62. package/dist-lib/public-origins-lib.json +174 -81
  63. package/dist-lib/react-native-host-modules.cjs +1 -1
  64. package/dist-lib/react-native-host-modules.mjs +1 -1
  65. package/dist-lib/reap-browser.cjs +1 -1
  66. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  67. package/dist-lib/sdk.cjs +1 -1
  68. package/dist-lib/sdk.mjs +1 -1
  69. package/dist-lib/skills.cjs +16783 -6989
  70. package/dist-lib/swift-compile.cjs +2 -2
  71. package/dist-lib/swift-compile.mjs +2 -2
  72. package/dist-lib/swift-package.cjs +1 -1
  73. package/dist-lib/swift-package.mjs +1 -1
  74. package/dist-lib/swift-submit.cjs +1 -1
  75. package/dist-lib/swift-submit.mjs +1 -1
  76. package/dist-lib/swift-toolchain.cjs +1 -1
  77. package/dist-lib/swift.cjs +1 -1
  78. package/dist-lib/vite-swift.cjs +95 -27
  79. package/dist-lib/vite.cjs +3331 -180
  80. package/dist-lib/worklet-executable.cjs +1 -1
  81. package/dist-lib/worklet-executable.mjs +1 -1
  82. package/package.json +1 -1
  83. package/src/expo-native-workspace.ts +23 -63
  84. package/src/pbx-table.ts +200 -0
  85. package/src/pod-sources.ts +628 -0
  86. package/src/podfile-cocoapods.ts +40 -3
  87. package/src/pods-analysis.ts +488 -0
  88. package/src/pods-build-settings.ts +1015 -0
  89. package/src/pods-files.ts +478 -0
  90. package/src/pods-install.ts +475 -0
  91. package/src/pods-integration.ts +778 -0
  92. package/src/pods-post-install.ts +1811 -0
  93. package/src/pods-project.ts +2416 -0
  94. package/src/pods-scripts.ts +409 -0
  95. package/src/pods-targets.ts +757 -0
  96. package/src/pods-xcconfig.ts +198 -0
  97. package/src/podspec-cocoapods.ts +29 -3
  98. package/src/podspec-ruby-stdlib.ts +111 -10
  99. package/src/podspec-ruby.ts +52 -8
  100. package/src/swift-catalog-png.ts +75 -0
  101. package/src/swift-host.ts +4 -3
  102. package/src/swift-root-lock.ts +0 -10
  103. package/src/swift-source-pods.ts +29 -73
  104. package/src/turbo-source.ts +16 -37
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2429 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2431 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -294,7 +294,7 @@ var STANDIN_SOURCE_DIGEST;
294
294
  var init_swift_standin_digest = __esm({
295
295
  "src/swift-standin-digest.ts"() {
296
296
  "use strict";
297
- STANDIN_SOURCE_DIGEST = true ? "3238b362649e49ccf332149bb0b343bb7ed657c3c8287e0a231bc7316974eb6e" : standinSourceDigest();
297
+ STANDIN_SOURCE_DIGEST = true ? "3475ca483b1e5005a2c76ec887310c0d0f44c91ea427496b33acbb5bf6188684" : standinSourceDigest();
298
298
  }
299
299
  });
300
300
 
@@ -1460,6 +1460,56 @@ var init_swiftContract = __esm({
1460
1460
  }
1461
1461
  });
1462
1462
 
1463
+ // src/openstep-plist.ts
1464
+ var init_openstep_plist = __esm({
1465
+ "src/openstep-plist.ts"() {
1466
+ "use strict";
1467
+ }
1468
+ });
1469
+
1470
+ // src/pod-sources.ts
1471
+ var COCOAPODS_VERSION, USER_AGENT, HEADER_EXTENSIONS, SOURCE_EXTENSIONS, SOURCE_FILES_PATTERN;
1472
+ var init_pod_sources = __esm({
1473
+ "src/pod-sources.ts"() {
1474
+ "use strict";
1475
+ init_home_paths();
1476
+ COCOAPODS_VERSION = "1.17.0";
1477
+ USER_AGENT = `'CocoaPods/${COCOAPODS_VERSION} cocoapods-downloader/2.1'`;
1478
+ HEADER_EXTENSIONS = [
1479
+ ".h",
1480
+ ".hh",
1481
+ ".hpp",
1482
+ ".ipp",
1483
+ ".tpp",
1484
+ ".hxx",
1485
+ ".def",
1486
+ ".inl",
1487
+ ".inc"
1488
+ ];
1489
+ SOURCE_EXTENSIONS = [
1490
+ ".m",
1491
+ ".mm",
1492
+ ".i",
1493
+ ".c",
1494
+ ".cc",
1495
+ ".cxx",
1496
+ ".cpp",
1497
+ ".c++",
1498
+ ".swift",
1499
+ ...HEADER_EXTENSIONS
1500
+ ];
1501
+ SOURCE_FILES_PATTERN = `*{${SOURCE_EXTENSIONS.join(",")}}`;
1502
+ }
1503
+ });
1504
+
1505
+ // src/cocoapods-trunk.ts
1506
+ var init_cocoapods_trunk = __esm({
1507
+ "src/cocoapods-trunk.ts"() {
1508
+ "use strict";
1509
+ init_home_paths();
1510
+ }
1511
+ });
1512
+
1463
1513
  // src/podspec-prism.ts
1464
1514
  var import_parsePrism;
1465
1515
  var init_podspec_prism = __esm({
@@ -2337,8 +2387,16 @@ module Pod
2337
2387
  end
2338
2388
 
2339
2389
  def module_name
2340
- attributes_hash['module_name'] || name.split('/').first.gsub(/^([0-9])/, '_\1').gsub(/[^a-zA-Z0-9_]/, '_').gsub(/_+/, '_')
2390
+ attributes_hash['module_name'] ||
2391
+ c99ext_identifier(attributes_hash['header_dir']) ||
2392
+ c99ext_identifier(attributes_hash['name'])
2393
+ end
2394
+
2395
+ def c99ext_identifier(name)
2396
+ return nil if name.nil?
2397
+ name.gsub(/^([0-9])/, '_\1').gsub(/[^a-zA-Z0-9_]/, '_').gsub(/_+/, '_')
2341
2398
  end
2399
+ private :c99ext_identifier
2342
2400
 
2343
2401
  def homepage
2344
2402
  attributes_hash['homepage']
@@ -2641,11 +2699,32 @@ end
2641
2699
  `],
2642
2700
  ["xcodebuild -version", `Xcode ${NATIVE_GRAPH_SDK_VERSION}
2643
2701
  `],
2644
- ["/usr/sbin/sysctl -n hw.optional.arm64 2>&1", "1\n"]
2702
+ ["/usr/sbin/sysctl -n hw.optional.arm64 2>&1", "1\n"],
2703
+ // peach compiles without ccache
2704
+ ["command -v ccache", ""]
2645
2705
  ]);
2646
2706
  }
2647
2707
  });
2648
2708
 
2709
+ // src/plist.ts
2710
+ var import_plist;
2711
+ var init_plist = __esm({
2712
+ "src/plist.ts"() {
2713
+ "use strict";
2714
+ import_plist = __toESM(require("plist"), 1);
2715
+ }
2716
+ });
2717
+
2718
+ // src/plist-bytes.ts
2719
+ var import_bplist_parser;
2720
+ var init_plist_bytes = __esm({
2721
+ "src/plist-bytes.ts"() {
2722
+ "use strict";
2723
+ import_bplist_parser = __toESM(require("bplist-parser"), 1);
2724
+ init_plist();
2725
+ }
2726
+ });
2727
+
2649
2728
  // src/workspace-root.ts
2650
2729
  var init_workspace_root = __esm({
2651
2730
  "src/workspace-root.ts"() {
@@ -2693,22 +2772,13 @@ var init_podspec_sources = __esm({
2693
2772
  }
2694
2773
  });
2695
2774
 
2696
- // src/plist.ts
2697
- var import_plist;
2698
- var init_plist = __esm({
2699
- "src/plist.ts"() {
2700
- "use strict";
2701
- import_plist = __toESM(require("plist"), 1);
2702
- }
2703
- });
2704
-
2705
2775
  // src/bazel-project.ts
2706
- var import_node_path2, import_plist2, PRODUCTS;
2776
+ var import_node_path2, import_plist3, PRODUCTS;
2707
2777
  var init_bazel_project = __esm({
2708
2778
  "src/bazel-project.ts"() {
2709
2779
  "use strict";
2710
2780
  import_node_path2 = __toESM(require("node:path"), 1);
2711
- import_plist2 = __toESM(require("plist"), 1);
2781
+ import_plist3 = __toESM(require("plist"), 1);
2712
2782
  init_is_record();
2713
2783
  PRODUCTS = import_node_path2.default.join(".build", "peach-bazel", "Products");
2714
2784
  }
@@ -3042,13 +3112,6 @@ var init_nativeAppIconContract = __esm({
3042
3112
  }
3043
3113
  });
3044
3114
 
3045
- // src/openstep-plist.ts
3046
- var init_openstep_plist = __esm({
3047
- "src/openstep-plist.ts"() {
3048
- "use strict";
3049
- }
3050
- });
3051
-
3052
3115
  // src/xcode-target-members.ts
3053
3116
  var init_xcode_target_members = __esm({
3054
3117
  "src/xcode-target-members.ts"() {
@@ -4031,7 +4094,7 @@ var init_swift_compile = __esm({
4031
4094
  FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
4032
4095
  (module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
4033
4096
  ).join("");
4034
- compilerSourceDigest = true ? "5ed6ce65e80a661269e2ae1a70eb7df501b75d5c5fd45c3cfc87cf1db220d611" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
4097
+ compilerSourceDigest = true ? "da253e49615973dfc65a40000574546cbf7dc4c9d44a36295773bd33442d8c1d" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
4035
4098
  C_WORDS = new Set(
4036
4099
  "auto bool break case char const continue default do double else enum extern false float for goto if inline int long register restrict return short signed sizeof static struct switch true typedef union unsigned void volatile while YES NO NULL nil Nil id self super instancetype".split(
4037
4100
  " "
@@ -4260,11 +4323,11 @@ var init_xcode_json_project = __esm({
4260
4323
  });
4261
4324
 
4262
4325
  // src/xcode-project.ts
4263
- var import_plist3, runScriptTimeoutMs;
4326
+ var import_plist4, runScriptTimeoutMs;
4264
4327
  var init_xcode_project = __esm({
4265
4328
  "src/xcode-project.ts"() {
4266
4329
  "use strict";
4267
- import_plist3 = __toESM(require("plist"), 1);
4330
+ import_plist4 = __toESM(require("plist"), 1);
4268
4331
  init_bazel_project();
4269
4332
  init_is_record();
4270
4333
  init_native_app_identity();
@@ -4484,16 +4547,6 @@ var init_public_brand = __esm({
4484
4547
  }
4485
4548
  });
4486
4549
 
4487
- // src/plist-bytes.ts
4488
- var import_bplist_parser;
4489
- var init_plist_bytes = __esm({
4490
- "src/plist-bytes.ts"() {
4491
- "use strict";
4492
- import_bplist_parser = __toESM(require("bplist-parser"), 1);
4493
- init_plist();
4494
- }
4495
- });
4496
-
4497
4550
  // src/swift-xcframework.ts
4498
4551
  var init_swift_xcframework = __esm({
4499
4552
  "src/swift-xcframework.ts"() {
@@ -4747,7 +4800,7 @@ var init_react_native_core = __esm({
4747
4800
  init_swift_distribution();
4748
4801
  init_swift_package();
4749
4802
  init_swiftContract();
4750
- recipe = true ? "ebfb6e514f6a2873b73852f067f1db2c2033490a337d8a2f95a46a922e095bf5" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
4803
+ recipe = true ? "f850b012b3ddd1d19a158d194b24b05cb032a23ccf2e459caa45620c0a5a823a" : reactNativeCoreDigest2(__sootsim_import_meta_dirname);
4751
4804
  }
4752
4805
  });
4753
4806
 
@@ -4757,6 +4810,7 @@ var init_bundleAssets = __esm({
4757
4810
  "../sootsim-swift/src/bundleAssets.ts"() {
4758
4811
  "use strict";
4759
4812
  import_svgpath = __toESM(require("svgpath"), 1);
4813
+ init_mapLimit();
4760
4814
  init_assetCatalogContract();
4761
4815
  init_swiftContract();
4762
4816
  SYMBOL_CAP_HEIGHT_EM = 1443 / 2048;
@@ -4791,6 +4845,16 @@ var init_core_data_model = __esm({
4791
4845
  }
4792
4846
  });
4793
4847
 
4848
+ // src/swift-catalog-png.ts
4849
+ var import_pngjs, pngSignature;
4850
+ var init_swift_catalog_png = __esm({
4851
+ "src/swift-catalog-png.ts"() {
4852
+ "use strict";
4853
+ import_pngjs = require("pngjs");
4854
+ pngSignature = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
4855
+ }
4856
+ });
4857
+
4794
4858
  // src/swift-cxx-reachable.ts
4795
4859
  var init_swift_cxx_reachable = __esm({
4796
4860
  "src/swift-cxx-reachable.ts"() {
@@ -4865,6 +4929,7 @@ var init_swift_host = __esm({
4865
4929
  init_plist();
4866
4930
  init_prepared_xcode_phases();
4867
4931
  init_swift_binary_modules();
4932
+ init_swift_catalog_png();
4868
4933
  init_swift_compile();
4869
4934
  init_xcode_assets();
4870
4935
  init_swift_cxx_reachable();
@@ -4890,14 +4955,6 @@ var init_swift_host = __esm({
4890
4955
  }
4891
4956
  });
4892
4957
 
4893
- // src/cocoapods-trunk.ts
4894
- var init_cocoapods_trunk = __esm({
4895
- "src/cocoapods-trunk.ts"() {
4896
- "use strict";
4897
- init_home_paths();
4898
- }
4899
- });
4900
-
4901
4958
  // src/installed-native-libraries.ts
4902
4959
  var init_installed_native_libraries = __esm({
4903
4960
  "src/installed-native-libraries.ts"() {
@@ -4926,15 +4983,12 @@ var init_turbo_codegen_intake = __esm({
4926
4983
  });
4927
4984
 
4928
4985
  // src/turbo-source.ts
4929
- var import_node_child_process8, import_node_util8, execFileAsync3;
4930
4986
  var init_turbo_source = __esm({
4931
4987
  "src/turbo-source.ts"() {
4932
4988
  "use strict";
4933
- import_node_child_process8 = require("node:child_process");
4934
- import_node_util8 = require("node:util");
4935
4989
  init_cocoapods_trunk();
4936
- init_home_paths();
4937
4990
  init_installed_native_libraries();
4991
+ init_pod_sources();
4938
4992
  init_answeredNativePackages();
4939
4993
  init_expo_autolinking();
4940
4994
  init_nitro_dependencies();
@@ -4945,7 +4999,6 @@ var init_turbo_source = __esm({
4945
4999
  init_swiftContract();
4946
5000
  init_turbo_codegen_intake();
4947
5001
  init_xcode_project();
4948
- execFileAsync3 = (0, import_node_util8.promisify)(import_node_child_process8.execFile);
4949
5002
  }
4950
5003
  });
4951
5004
 
@@ -5134,7 +5187,7 @@ init_answeredNativePackages();
5134
5187
  init_expo_autolinking();
5135
5188
 
5136
5189
  // src/expo-native-prebuilt.ts
5137
- var import_plist6 = __toESM(require("plist"), 1);
5190
+ var import_plist7 = __toESM(require("plist"), 1);
5138
5191
  init_answeredNativePackages();
5139
5192
 
5140
5193
  // src/expo-native-compiler-digest.ts
@@ -7461,6 +7514,3105 @@ init_bundle_global_footer();
7461
7514
  init_is_record();
7462
7515
  init_swiftContract();
7463
7516
 
7517
+ // src/pods-install.ts
7518
+ init_openstep_plist();
7519
+
7520
+ // src/pbx-table.ts
7521
+ init_openstep_plist();
7522
+ var ARRAY_SETTINGS = /* @__PURE__ */ new Set([
7523
+ "ALTERNATE_PERMISSIONS_FILES",
7524
+ "ARCHS",
7525
+ "BUILD_VARIANTS",
7526
+ "EXCLUDED_SOURCE_FILE_NAMES",
7527
+ "FRAMEWORK_SEARCH_PATHS",
7528
+ "GCC_PREPROCESSOR_DEFINITIONS",
7529
+ "GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS",
7530
+ "HEADER_SEARCH_PATHS",
7531
+ "INCLUDED_SOURCE_FILE_NAMES",
7532
+ "INFOPLIST_PREPROCESSOR_DEFINITIONS",
7533
+ "LD_RUNPATH_SEARCH_PATHS",
7534
+ "LIBRARY_SEARCH_PATHS",
7535
+ "LOCALIZED_STRING_MACRO_NAMES",
7536
+ "OTHER_CFLAGS",
7537
+ "OTHER_CPLUSPLUSFLAGS",
7538
+ "OTHER_LDFLAGS",
7539
+ "REZ_SEARCH_PATHS",
7540
+ "SECTORDER_FLAGS",
7541
+ "SYSTEM_FRAMEWORK_SEARCH_PATHS",
7542
+ "SYSTEM_HEADER_SEARCH_PATHS",
7543
+ "USER_HEADER_SEARCH_PATHS",
7544
+ "WARNING_CFLAGS",
7545
+ "WARNING_LDFLAGS"
7546
+ ]);
7547
+ var LEGACY_ARRAY_SETTINGS = new Set(
7548
+ [...ARRAY_SETTINGS].filter(
7549
+ (key) => ![
7550
+ "INCLUDED_SOURCE_FILE_NAMES",
7551
+ "LD_RUNPATH_SEARCH_PATHS",
7552
+ "LOCALIZED_STRING_MACRO_NAMES",
7553
+ "SYSTEM_FRAMEWORK_SEARCH_PATHS",
7554
+ "SYSTEM_HEADER_SEARCH_PATHS",
7555
+ "USER_HEADER_SEARCH_PATHS"
7556
+ ].includes(key)
7557
+ )
7558
+ );
7559
+
7560
+ // src/pods-install.ts
7561
+ init_pod_sources();
7562
+
7563
+ // src/podfile-cocoapods.ts
7564
+ init_cocoapods_trunk();
7565
+ init_podspec_cocoapods();
7566
+ init_podspec_ruby();
7567
+ init_podspec_ruby_stdlib();
7568
+ var PODFILE = String.raw`
7569
+ module Pod
7570
+ class BuildType
7571
+ KNOWN_PACKAGING_OPTIONS = { :library => [:static, :dynamic], :framework => [:static, :dynamic] }.freeze
7572
+ attr_reader :packaging, :linkage
7573
+ def initialize(linkage: :static, packaging: :library)
7574
+ raise ArgumentError, "Invalid linkage option #{linkage.inspect}, valid options are #{KNOWN_PACKAGING_OPTIONS[packaging].inspect}" unless KNOWN_PACKAGING_OPTIONS[packaging].include?(linkage)
7575
+ @packaging = packaging
7576
+ @linkage = linkage
7577
+ end
7578
+ def self.dynamic_library; new(:linkage => :dynamic, :packaging => :library); end
7579
+ def self.static_library; new(:linkage => :static, :packaging => :library); end
7580
+ def self.dynamic_framework; new(:linkage => :dynamic, :packaging => :framework); end
7581
+ def self.static_framework; new(:linkage => :static, :packaging => :framework); end
7582
+ def dynamic?; linkage == :dynamic; end
7583
+ def static?; linkage == :static; end
7584
+ def framework?; packaging == :framework; end
7585
+ def library?; packaging == :library; end
7586
+ def dynamic_framework?; dynamic? && framework?; end
7587
+ def dynamic_library?; dynamic? && library?; end
7588
+ def static_framework?; static? && framework?; end
7589
+ def static_library?; static? && library?; end
7590
+ def to_s
7591
+ "#{linkage} #{packaging}"
7592
+ end
7593
+ def to_hash
7594
+ { :linkage => linkage, :packaging => packaging }
7595
+ end
7596
+ def ==(other)
7597
+ linkage == other.linkage && packaging == other.packaging
7598
+ end
7599
+ end
7600
+
7601
+ class Sandbox
7602
+ attr_reader :root, :stored_podspecs
7603
+ def initialize(root)
7604
+ @root = Pathname.new(root)
7605
+ @stored_podspecs = {}
7606
+ @local_paths = {}
7607
+ end
7608
+ def specifications_root
7609
+ root + 'Local Podspecs'
7610
+ end
7611
+ def specification(name)
7612
+ @stored_podspecs[Specification.root_name(name)]
7613
+ end
7614
+ def store_local_path(name, path, was_absolute = false)
7615
+ @local_paths[Specification.root_name(name)] = [path.dirname, was_absolute]
7616
+ end
7617
+ def local_path(name)
7618
+ @local_paths[Specification.root_name(name)]&.first
7619
+ end
7620
+ def local?(name)
7621
+ @local_paths.key?(Specification.root_name(name))
7622
+ end
7623
+ def development_pods
7624
+ @local_paths.transform_values(&:first)
7625
+ end
7626
+ def store_podspec(name, podspec, _external_source = false, json = false)
7627
+ file_name = json ? "#{name}.podspec.json" : "#{name}.podspec"
7628
+ output_path = specifications_root + file_name
7629
+ spec = case podspec
7630
+ when Specification
7631
+ raise ArgumentError, 'can only store Specification objects as json' unless json
7632
+ # the checksum of the JSON CocoaPods writes to output_path
7633
+ podspec.dup.tap { |stored| stored.instance_variable_set(:@checksum, Digest::SHA1.hexdigest(podspec.to_pretty_json)) }
7634
+ else
7635
+ raise ArgumentError, "Peach stores only evaluated podspecs, not #{podspec.inspect}"
7636
+ end
7637
+ spec.defined_in_file = output_path
7638
+ unless spec.name == name
7639
+ raise Informative, "The name of the given podspec '#{spec.name}' doesn't match the expected one '#{name}'"
7640
+ end
7641
+ @stored_podspecs[spec.name] = spec
7642
+ end
7643
+ end
7644
+
7645
+ class Installer
7646
+ attr_reader :sandbox, :podfile, :lockfile
7647
+ attr_accessor :pod_targets, :aggregate_targets
7648
+ def initialize(sandbox, podfile, lockfile = nil)
7649
+ @sandbox = sandbox
7650
+ @podfile = podfile
7651
+ @lockfile = lockfile
7652
+ @pod_targets = []
7653
+ @aggregate_targets = []
7654
+ end
7655
+
7656
+ private
7657
+
7658
+ def run_podfile_pre_install_hooks
7659
+ podfile.pre_install!(self)
7660
+ end
7661
+
7662
+ def run_podfile_post_install_hooks
7663
+ podfile.post_install!(self)
7664
+ end
7665
+
7666
+ def run_podfile_post_integrate_hooks
7667
+ podfile.post_integrate!(self)
7668
+ end
7669
+
7670
+ # upstream runs plugin hooks and prints warnings here; Peach loads no plugins
7671
+ def perform_post_install_actions
7672
+ end
7673
+
7674
+ # the workspace, deintegration of targets the Podfile dropped and the
7675
+ # override warnings are left out: Peach builds from the projects in memory
7676
+ class UserProjectIntegrator
7677
+ attr_reader :podfile, :sandbox, :installation_root, :targets, :targets_to_integrate, :use_input_output_paths
7678
+ alias use_input_output_paths? use_input_output_paths
7679
+
7680
+ def initialize(podfile, sandbox, installation_root, targets, targets_to_integrate, use_input_output_paths: true)
7681
+ @podfile = podfile
7682
+ @sandbox = sandbox
7683
+ @installation_root = installation_root
7684
+ @targets = targets
7685
+ @targets_to_integrate = targets_to_integrate
7686
+ @use_input_output_paths = use_input_output_paths
7687
+ end
7688
+
7689
+ def integrate!
7690
+ integrate_user_targets
7691
+ save_projects(user_projects_to_integrate)
7692
+ end
7693
+
7694
+ private
7695
+
7696
+ def integrate_user_targets
7697
+ Peach::Pods.integrate_user_targets(targets_to_integrate.sort_by(&:name).map(&:label))
7698
+ end
7699
+
7700
+ def user_projects_to_integrate
7701
+ targets_to_integrate.map(&:user_project).compact.uniq
7702
+ end
7703
+
7704
+ def save_projects(projects)
7705
+ projects.each(&:save)
7706
+ end
7707
+ end
7708
+ end
7709
+
7710
+ class Specification
7711
+ SCRIPT_PHASE_REQUIRED_KEYS = [:name, :script].freeze
7712
+ SCRIPT_PHASE_OPTIONAL_KEYS = [:shell_path, :input_files, :output_files, :input_file_lists, :output_file_lists,
7713
+ :show_env_vars_in_log, :execution_position, :dependency_file, :always_out_of_date].freeze
7714
+ EXECUTION_POSITION_KEYS = [:before_compile, :after_compile, :before_headers, :after_headers, :any].freeze
7715
+ ALL_SCRIPT_PHASE_KEYS = (SCRIPT_PHASE_REQUIRED_KEYS + SCRIPT_PHASE_OPTIONAL_KEYS).freeze
7716
+
7717
+ def defined_in_file
7718
+ root? ? @defined_in_file : root.defined_in_file
7719
+ end
7720
+
7721
+ def defined_in_file=(file)
7722
+ raise StandardError, 'Defined in file can be set only for root specs.' unless root?
7723
+ @defined_in_file = file
7724
+ end
7725
+
7726
+ def self.root_name(full_name)
7727
+ if full_name[0] == '/'
7728
+ full_name.split('/', 3).first(2).join('/')
7729
+ else
7730
+ full_name.split('/', 2).first
7731
+ end
7732
+ end
7733
+
7734
+ def self.from_json(json, path = nil)
7735
+ from_hash(JSON.parse(json)).tap { |spec| spec.defined_in_file = path }
7736
+ end
7737
+
7738
+ def ==(other)
7739
+ other.is_a?(self.class) && name == other.name && version == other.version
7740
+ end
7741
+ alias_method :eql?, :==
7742
+
7743
+ def hash
7744
+ (name.hash * 53) ^ version.hash
7745
+ end
7746
+
7747
+ def test_specs
7748
+ subspecs.select(&:test_specification?)
7749
+ end
7750
+
7751
+ def app_specs
7752
+ subspecs.select(&:app_specification?)
7753
+ end
7754
+
7755
+ def recursive_subspecs
7756
+ mapper = lambda do |spec|
7757
+ spec.subspecs.map do |subspec|
7758
+ [subspec, *mapper.call(subspec)]
7759
+ end.flatten
7760
+ end
7761
+ mapper.call(self)
7762
+ end
7763
+
7764
+ def all_dependencies(platform = nil)
7765
+ dependencies(platform) + subspec_dependencies(platform)
7766
+ end
7767
+
7768
+ def subspec_dependencies(platform = nil)
7769
+ specs = if default_subspecs.empty?
7770
+ subspecs.compact.reject(&:non_library_specification?)
7771
+ else
7772
+ default_subspecs.map do |subspec_name|
7773
+ root.subspec_by_name("#{name}/#{subspec_name}")
7774
+ end
7775
+ end
7776
+ if platform
7777
+ specs = specs.select { |s| s.supported_on_platform?(platform) }
7778
+ end
7779
+ specs.map { |s| Dependency.new(s.name, version) }
7780
+ end
7781
+
7782
+ def supported_on_platform?(platform, target = nil)
7783
+ platform = Platform.new(platform, target) unless platform.is_a?(Platform)
7784
+ available_platforms.any? { |available| platform.supports?(available) }
7785
+ end
7786
+
7787
+ def to_pretty_json(*a)
7788
+ JSON.pretty_generate(to_hash, *a) << "\n"
7789
+ end
7790
+
7791
+ def checksum
7792
+ @checksum ||= begin
7793
+ if root?
7794
+ unless defined_in_file.nil?
7795
+ require 'digest'
7796
+ checksum = Digest::SHA1.hexdigest(File.read(defined_in_file))
7797
+ checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
7798
+ checksum
7799
+ end
7800
+ else
7801
+ root.checksum
7802
+ end
7803
+ end
7804
+ end
7805
+ end
7806
+
7807
+ class Podfile
7808
+ class StandardError < ::StandardError; end
7809
+
7810
+ module DSL
7811
+ def install!(installation_method, options = {})
7812
+ unless current_target_definition.root?
7813
+ raise Informative, 'The installation method can only be set at the root level of the Podfile.'
7814
+ end
7815
+ set_hash_value('installation_method', 'name' => installation_method, 'options' => options)
7816
+ end
7817
+
7818
+ # checks the Bundler running CocoaPods; Peach runs neither
7819
+ def ensure_bundler!(version = '>= 0')
7820
+ end
7821
+
7822
+ def pod(name = nil, *requirements)
7823
+ unless name
7824
+ raise StandardError, 'A dependency requires a name.'
7825
+ end
7826
+ if block_given?
7827
+ raise StandardError, "A block was passed to pod #{name}, which is not supported."
7828
+ end
7829
+ current_target_definition.store_pod(name, *requirements)
7830
+ end
7831
+
7832
+ def podspec(options = nil)
7833
+ current_target_definition.store_podspec(options)
7834
+ end
7835
+
7836
+ def target(name, options = nil)
7837
+ if options
7838
+ raise Informative, "Unsupported options #{options} for target #{name}."
7839
+ end
7840
+ parent = current_target_definition
7841
+ definition = TargetDefinition.new(name, parent)
7842
+ self.current_target_definition = definition
7843
+ yield if block_given?
7844
+ ensure
7845
+ self.current_target_definition = parent
7846
+ end
7847
+
7848
+ def script_phase(options)
7849
+ raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?
7850
+ raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?
7851
+ current_target_definition.store_script_phase(options)
7852
+ end
7853
+
7854
+ def abstract_target(name)
7855
+ target(name) do
7856
+ abstract!
7857
+ yield if block_given?
7858
+ end
7859
+ end
7860
+
7861
+ def abstract!(abstract = true)
7862
+ current_target_definition.abstract = abstract
7863
+ end
7864
+
7865
+ def inherit!(inheritance)
7866
+ current_target_definition.inheritance = inheritance
7867
+ end
7868
+
7869
+ def platform(name, target = nil)
7870
+ current_target_definition.set_platform!(name, target)
7871
+ end
7872
+
7873
+ def project(path, build_configurations = {})
7874
+ current_target_definition.user_project_path = path
7875
+ current_target_definition.build_configurations = build_configurations
7876
+ end
7877
+
7878
+ def inhibit_all_warnings!
7879
+ current_target_definition.inhibit_all_warnings = true
7880
+ end
7881
+
7882
+ def use_modular_headers!
7883
+ current_target_definition.use_modular_headers_for_all_pods = true
7884
+ end
7885
+
7886
+ def use_frameworks!(option = true)
7887
+ current_target_definition.use_frameworks!(option)
7888
+ end
7889
+
7890
+ def supports_swift_versions(*requirements)
7891
+ current_target_definition.store_swift_version_requirements(*requirements)
7892
+ end
7893
+
7894
+ def workspace(path)
7895
+ set_hash_value('workspace', path)
7896
+ end
7897
+
7898
+ def generate_bridge_support!
7899
+ set_hash_value('generate_bridge_support', true)
7900
+ end
7901
+
7902
+ def set_arc_compatibility_flag!
7903
+ set_hash_value('set_arc_compatibility_flag', true)
7904
+ end
7905
+
7906
+ def source(source)
7907
+ hash_sources = get_hash_value('sources') || []
7908
+ hash_sources << source
7909
+ set_hash_value('sources', hash_sources.uniq)
7910
+ end
7911
+
7912
+ def plugin(name, options = {})
7913
+ hash_plugins = get_hash_value('plugins') || {}
7914
+ (hash_plugins[name] ||= {}).merge!(options)
7915
+ set_hash_value('plugins', hash_plugins)
7916
+ end
7917
+
7918
+ def pre_install(&block)
7919
+ @pre_install_callback = block
7920
+ end
7921
+
7922
+ def pre_integrate(&block)
7923
+ @pre_integrate_callback = block
7924
+ end
7925
+
7926
+ def post_install(&block)
7927
+ @post_install_callback = block
7928
+ end
7929
+
7930
+ def post_integrate(&block)
7931
+ @post_integrate_callback = block
7932
+ end
7933
+ end
7934
+
7935
+ include DSL
7936
+
7937
+ HASH_KEYS = %w(installation_method workspace sources plugins set_arc_compatibility_flag generate_bridge_support target_definitions).freeze
7938
+
7939
+ attr_accessor :defined_in_file
7940
+ attr_accessor :current_target_definition
7941
+ attr_reader :internal_hash
7942
+
7943
+ def initialize(defined_in_file = nil, internal_hash = {})
7944
+ @defined_in_file = defined_in_file
7945
+ @internal_hash = internal_hash
7946
+ default_target_def = TargetDefinition.new('Pods', self)
7947
+ default_target_def.abstract = true
7948
+ @root_target_definitions = [default_target_def]
7949
+ @current_target_definition = default_target_def
7950
+ end
7951
+
7952
+ def to_s
7953
+ 'Podfile'
7954
+ end
7955
+
7956
+ def target_definitions
7957
+ Hash[target_definition_list.map { |td| [td.name, td] }]
7958
+ end
7959
+
7960
+ def target_definition_list
7961
+ root_target_definitions.map { |td| [td, td.recursive_children] }.flatten
7962
+ end
7963
+
7964
+ attr_accessor :root_target_definitions
7965
+
7966
+ def dependencies
7967
+ target_definition_list.map(&:dependencies).flatten.uniq
7968
+ end
7969
+
7970
+ def checksum
7971
+ @checksum ||= Digest::SHA1.hexdigest(File.read(defined_in_file)) unless defined_in_file.nil?
7972
+ end
7973
+
7974
+ def workspace_path
7975
+ path = get_hash_value('workspace')
7976
+ if path
7977
+ if File.extname(path) == '.xcworkspace'
7978
+ path
7979
+ else
7980
+ "#{path}.xcworkspace"
7981
+ end
7982
+ end
7983
+ end
7984
+
7985
+ def generate_bridge_support?
7986
+ get_hash_value('generate_bridge_support')
7987
+ end
7988
+
7989
+ def set_arc_compatibility_flag?
7990
+ get_hash_value('set_arc_compatibility_flag')
7991
+ end
7992
+
7993
+ def installation_method
7994
+ get_hash_value('installation_method', 'name' => 'cocoapods', 'options' => {}).values_at('name', 'options')
7995
+ end
7996
+
7997
+ def sources
7998
+ get_hash_value('sources') || []
7999
+ end
8000
+
8001
+ def plugins
8002
+ get_hash_value('plugins') || {}
8003
+ end
8004
+
8005
+ def to_hash
8006
+ hash = {}
8007
+ hash['target_definitions'] = root_target_definitions.map(&:to_hash)
8008
+ hash.merge!(internal_hash)
8009
+ hash
8010
+ end
8011
+
8012
+ def pre_install!(installer)
8013
+ @pre_install_callback ? @pre_install_callback.call(installer) || true : false
8014
+ end
8015
+
8016
+ def post_install!(installer)
8017
+ @post_install_callback ? @post_install_callback.call(installer) || true : false
8018
+ end
8019
+
8020
+ def post_integrate!(installer)
8021
+ @post_integrate_callback ? @post_integrate_callback.call(installer) || true : false
8022
+ end
8023
+
8024
+ def set_hash_value(key, value)
8025
+ raise StandardError, "Unsupported hash key '#{key}'" unless HASH_KEYS.include?(key)
8026
+ internal_hash[key] = value
8027
+ end
8028
+
8029
+ def get_hash_value(key, default = nil)
8030
+ raise StandardError, "Unsupported hash key '#{key}'" unless HASH_KEYS.include?(key)
8031
+ internal_hash.fetch(key, default)
8032
+ end
8033
+
8034
+ class TargetDefinition
8035
+ attr_reader :parent
8036
+ attr_reader :internal_hash
8037
+ attr_accessor :children
8038
+
8039
+ HASH_KEYS = %w(
8040
+ name platform podspecs exclusive link_with link_with_first_target inhibit_warnings use_modular_headers
8041
+ user_project_path build_configurations project_names dependencies script_phases children
8042
+ configuration_pod_whitelist uses_frameworks swift_version_requirements inheritance abstract swift_version
8043
+ ).freeze
8044
+
8045
+ def initialize(name, parent, internal_hash = nil)
8046
+ @internal_hash = internal_hash || {}
8047
+ @parent = parent
8048
+ @children = []
8049
+ @label = nil
8050
+ self.name ||= name
8051
+ if parent.is_a?(TargetDefinition)
8052
+ parent.children << self
8053
+ end
8054
+ end
8055
+
8056
+ def recursive_children
8057
+ (children + children.map(&:recursive_children)).flatten
8058
+ end
8059
+
8060
+ def root?
8061
+ parent.is_a?(Podfile) || parent.nil?
8062
+ end
8063
+
8064
+ def root
8065
+ if root?
8066
+ self
8067
+ else
8068
+ parent.root
8069
+ end
8070
+ end
8071
+
8072
+ def podfile
8073
+ root.parent
8074
+ end
8075
+
8076
+ def dependencies
8077
+ if exclusive?
8078
+ non_inherited_dependencies
8079
+ else
8080
+ non_inherited_dependencies + parent.dependencies
8081
+ end
8082
+ end
8083
+
8084
+ def targets_to_inherit_search_paths
8085
+ return [] unless inheritance == 'search_paths'
8086
+ if root? || !matches_platform?(parent)
8087
+ raise StandardError, "Non-root target definitions (#{label}) need a parent target definition with the same platform."
8088
+ elsif parent.inheritance == 'search_paths'
8089
+ parent.targets_to_inherit_search_paths << parent
8090
+ else
8091
+ [parent]
8092
+ end
8093
+ end
8094
+
8095
+ def non_inherited_dependencies
8096
+ pod_dependencies.concat(podspec_dependencies)
8097
+ end
8098
+
8099
+ def empty?
8100
+ non_inherited_dependencies.empty?
8101
+ end
8102
+
8103
+ def label
8104
+ @label ||= if root? && name == 'Pods'
8105
+ 'Pods'
8106
+ elsif exclusive? || parent.nil?
8107
+ "Pods-#{name}"
8108
+ else
8109
+ "#{parent.label}-#{name}"
8110
+ end
8111
+ end
8112
+
8113
+ alias_method :to_s, :label
8114
+
8115
+ def inspect
8116
+ "#<#{self.class} label=#{label}>"
8117
+ end
8118
+
8119
+ def name
8120
+ get_hash_value('name')
8121
+ end
8122
+
8123
+ def name=(name)
8124
+ @label = nil
8125
+ set_hash_value('name', name)
8126
+ end
8127
+
8128
+ def abstract?
8129
+ get_hash_value('abstract', root?)
8130
+ end
8131
+
8132
+ def abstract=(abstract)
8133
+ set_hash_value('abstract', abstract)
8134
+ end
8135
+
8136
+ def swift_version
8137
+ get_hash_value('swift_version')
8138
+ end
8139
+
8140
+ def swift_version=(version)
8141
+ set_hash_value('swift_version', version)
8142
+ end
8143
+
8144
+ def swift_version_requirements
8145
+ get_hash_value('swift_version_requirements')
8146
+ end
8147
+
8148
+ def store_swift_version_requirements(*requirements)
8149
+ set_hash_value('swift_version_requirements', requirements.flatten.map(&:to_s))
8150
+ end
8151
+
8152
+ def inheritance
8153
+ get_hash_value('inheritance', 'complete')
8154
+ end
8155
+
8156
+ def inheritance=(inheritance)
8157
+ inheritance = inheritance.to_s
8158
+ unless %w(none search_paths complete).include?(inheritance)
8159
+ raise Informative, "Unrecognized inheritance option '#{inheritance}' specified for target '#{name}'."
8160
+ end
8161
+ if root?
8162
+ raise Informative, 'Cannot set inheritance for the root target definition.'
8163
+ end
8164
+ if abstract?
8165
+ raise Informative, 'Cannot set inheritance for abstract target definition.'
8166
+ end
8167
+ set_hash_value('inheritance', inheritance)
8168
+ end
8169
+
8170
+ def exclusive?
8171
+ if root?
8172
+ true
8173
+ else
8174
+ !matches_platform?(parent) || (inheritance != 'complete')
8175
+ end
8176
+ end
8177
+
8178
+ def matches_platform?(target_definition)
8179
+ return false unless target_definition
8180
+ return true if target_definition.platform == platform
8181
+ !target_definition.platform && target_definition.abstract?
8182
+ end
8183
+
8184
+ def user_project_path
8185
+ path = get_hash_value('user_project_path')
8186
+ if path
8187
+ Pathname(path).sub_ext('.xcodeproj').to_path
8188
+ else
8189
+ parent.user_project_path unless root?
8190
+ end
8191
+ end
8192
+
8193
+ def user_project_path=(path)
8194
+ set_hash_value('user_project_path', path)
8195
+ end
8196
+
8197
+ def build_configurations
8198
+ if root?
8199
+ get_hash_value('build_configurations')
8200
+ else
8201
+ get_hash_value('build_configurations') || parent.build_configurations
8202
+ end
8203
+ end
8204
+
8205
+ def build_configurations=(hash)
8206
+ set_hash_value('build_configurations', hash) unless hash.empty?
8207
+ end
8208
+
8209
+ def script_phases
8210
+ script_phases_hashes = get_hash_value('script_phases', [])
8211
+ script_phases_hashes.map do |script_phase_hash|
8212
+ Specification.convert_keys_to_symbol(script_phase_hash)
8213
+ end
8214
+ end
8215
+
8216
+ def project_name_for_pod(pod_name)
8217
+ if root?
8218
+ raw_project_names_hash[pod_name]
8219
+ else
8220
+ raw_project_names_hash[pod_name] || parent.project_name_for_pod(pod_name)
8221
+ end
8222
+ end
8223
+
8224
+ def inhibits_warnings_for_pod?(pod_name)
8225
+ if Array(inhibit_warnings_hash['not_for_pods']).include?(pod_name)
8226
+ false
8227
+ elsif Array(inhibit_warnings_hash['for_pods']).include?(pod_name)
8228
+ true
8229
+ elsif inhibit_warnings_hash['all']
8230
+ true
8231
+ elsif !root? && parent.inhibits_warnings_for_pod?(pod_name)
8232
+ true
8233
+ else
8234
+ false
8235
+ end
8236
+ end
8237
+
8238
+ def inhibit_all_warnings=(flag)
8239
+ raw_inhibit_warnings_hash['all'] = flag
8240
+ end
8241
+
8242
+ def set_inhibit_warnings_for_pod(pod_name, should_inhibit)
8243
+ hash_key = case should_inhibit
8244
+ when true
8245
+ 'for_pods'
8246
+ when false
8247
+ 'not_for_pods'
8248
+ when nil
8249
+ return
8250
+ else
8251
+ raise ArgumentError, "Got '#{should_inhibit.inspect}', should be a boolean"
8252
+ end
8253
+ raw_inhibit_warnings_hash[hash_key] ||= []
8254
+ raw_inhibit_warnings_hash[hash_key] << pod_name
8255
+ end
8256
+
8257
+ def build_pod_as_module?(pod_name)
8258
+ if Array(use_modular_headers_hash['not_for_pods']).include?(pod_name)
8259
+ false
8260
+ elsif Array(use_modular_headers_hash['for_pods']).include?(pod_name)
8261
+ true
8262
+ elsif use_modular_headers_hash['all']
8263
+ true
8264
+ elsif !root? && parent.build_pod_as_module?(pod_name)
8265
+ true
8266
+ else
8267
+ false
8268
+ end
8269
+ end
8270
+
8271
+ def use_modular_headers_for_all_pods=(flag)
8272
+ raw_use_modular_headers_hash['all'] = flag
8273
+ end
8274
+
8275
+ def set_use_modular_headers_for_pod(pod_name, flag)
8276
+ hash_key = case flag
8277
+ when true
8278
+ 'for_pods'
8279
+ when false
8280
+ 'not_for_pods'
8281
+ when nil
8282
+ return
8283
+ else
8284
+ raise ArgumentError, "Got '#{flag.inspect}', should be a boolean"
8285
+ end
8286
+ raw_use_modular_headers_hash[hash_key] ||= []
8287
+ raw_use_modular_headers_hash[hash_key] << pod_name
8288
+ end
8289
+
8290
+ def use_frameworks!(option = true)
8291
+ value = case option
8292
+ when true, false
8293
+ option ? BuildType.dynamic_framework : BuildType.static_library
8294
+ when Hash
8295
+ BuildType.new(:linkage => option.fetch(:linkage), :packaging => :framework)
8296
+ else
8297
+ raise ArgumentError, "Got '#{option.inspect}', should be a boolean or hash."
8298
+ end
8299
+ set_hash_value('uses_frameworks', value.to_hash)
8300
+ end
8301
+
8302
+ def build_type
8303
+ value = get_hash_value('uses_frameworks', root? ? BuildType.static_library.to_hash : parent.build_type.to_hash)
8304
+ case value
8305
+ when true, false
8306
+ value ? BuildType.dynamic_framework : BuildType.static_library
8307
+ when Hash
8308
+ BuildType.new(:linkage => value.fetch(:linkage), :packaging => value.fetch(:packaging))
8309
+ when BuildType
8310
+ value
8311
+ else
8312
+ raise ArgumentError, "Got '#{value.inspect}', should be a boolean, hash or BuildType."
8313
+ end
8314
+ end
8315
+
8316
+ def uses_frameworks?
8317
+ if internal_hash['uses_frameworks'].nil?
8318
+ root? ? false : parent.uses_frameworks?
8319
+ else
8320
+ build_type.framework?
8321
+ end
8322
+ end
8323
+
8324
+ def whitelist_pod_for_configuration(pod_name, configuration_name)
8325
+ found = raw_configuration_pod_whitelist.find { |configuration, _| configuration.casecmp(configuration_name.to_s).zero? }
8326
+ configuration_name = found.nil? ? configuration_name.to_s : found.first
8327
+ list = raw_configuration_pod_whitelist[configuration_name] ||= []
8328
+ list << pod_name
8329
+ end
8330
+
8331
+ def pod_whitelisted_for_configuration?(pod_name, configuration_name)
8332
+ found = false
8333
+ configuration_pod_whitelist.each do |configuration, pods|
8334
+ if pods.include?(pod_name)
8335
+ found = true
8336
+ if configuration.casecmp(configuration_name.to_s).zero?
8337
+ return true
8338
+ end
8339
+ end
8340
+ end
8341
+ !found && (root? || (inheritance != 'none' && parent.pod_whitelisted_for_configuration?(pod_name, configuration_name)))
8342
+ end
8343
+
8344
+ def all_whitelisted_configurations
8345
+ parent_configurations = (root? || inheritance == 'none') ? [] : parent.all_whitelisted_configurations
8346
+ (configuration_pod_whitelist.keys + parent_configurations).uniq
8347
+ end
8348
+
8349
+ def platform
8350
+ name_or_hash = get_hash_value('platform')
8351
+ if name_or_hash
8352
+ if name_or_hash.is_a?(Hash)
8353
+ name = name_or_hash.keys.first.to_sym
8354
+ target = name_or_hash.values.first
8355
+ else
8356
+ name = name_or_hash.to_sym
8357
+ end
8358
+ target ||= (name == :ios ? '4.3' : '10.6')
8359
+ Platform.new(name, target)
8360
+ else
8361
+ parent.platform unless root?
8362
+ end
8363
+ end
8364
+
8365
+ def set_platform(name, target = nil)
8366
+ name = :osx if name == :macos
8367
+ unless [:ios, :osx, :tvos, :visionos, :watchos].include?(name)
8368
+ raise StandardError, "Unsupported platform '#{name}'. Platform must be ':ios', ':osx', ':macos', ':tvos', :visionos, or ':watchos'."
8369
+ end
8370
+ if target
8371
+ value = { name.to_s => target }
8372
+ else
8373
+ value = name.to_s
8374
+ end
8375
+ set_hash_value('platform', value)
8376
+ end
8377
+
8378
+ def set_platform!(name, target = nil)
8379
+ raise StandardError, "The target '#{label}' already has a platform set." if get_hash_value('platform')
8380
+ set_platform(name, target)
8381
+ end
8382
+
8383
+ def store_pod(name, *requirements)
8384
+ return if parse_subspecs(name, requirements)
8385
+ parse_inhibit_warnings(name, requirements)
8386
+ parse_modular_headers(name, requirements)
8387
+ parse_configuration_whitelist(name, requirements)
8388
+ parse_project_name(name, requirements)
8389
+ if requirements && !requirements.empty?
8390
+ pod = { name => requirements }
8391
+ else
8392
+ pod = name
8393
+ end
8394
+ get_hash_value('dependencies', []) << pod
8395
+ nil
8396
+ end
8397
+
8398
+ def store_podspec(options = nil)
8399
+ options ||= {}
8400
+ unless options.keys.all? { |key| [:autodetect, :path, :name, :subspecs, :subspec].include?(key) }
8401
+ raise StandardError, "Unrecognized options for the podspec method '#{options}'"
8402
+ end
8403
+ if subspec_name = options[:subspec]
8404
+ options[:subspecs] = [subspec_name]
8405
+ end
8406
+ options[:autodetect] = true if !options.include?(:name) && !options.include?(:path)
8407
+ get_hash_value('podspecs', []) << options
8408
+ end
8409
+
8410
+ def store_script_phase(options)
8411
+ option_keys = options.keys
8412
+ unrecognized_keys = option_keys - Specification::ALL_SCRIPT_PHASE_KEYS
8413
+ unless unrecognized_keys.empty?
8414
+ raise StandardError, "Unrecognized options '#{unrecognized_keys}' in shell script '#{options[:name]}' within '#{name}' target. Available options are '#{Specification::ALL_SCRIPT_PHASE_KEYS}'."
8415
+ end
8416
+ missing_required_keys = Specification::SCRIPT_PHASE_REQUIRED_KEYS - option_keys
8417
+ unless missing_required_keys.empty?
8418
+ raise StandardError, "Missing required shell script phase options '#{missing_required_keys.join(', ')}'"
8419
+ end
8420
+ script_phases_hash = get_hash_value('script_phases', [])
8421
+ if script_phases_hash.map { |script_phase_options| script_phase_options[:name] }.include?(options[:name])
8422
+ raise StandardError, "Script phase with name '#{options[:name]}' name already present for target '#{name}'."
8423
+ end
8424
+ options[:execution_position] = :any unless options.key?(:execution_position)
8425
+ unless Specification::EXECUTION_POSITION_KEYS.include?(options[:execution_position])
8426
+ raise StandardError, "Invalid execution position value '#{options[:execution_position]}' in shell script '#{options[:name]}' within '#{name}' target. Available options are '#{Specification::EXECUTION_POSITION_KEYS}'."
8427
+ end
8428
+ script_phases_hash << options
8429
+ end
8430
+
8431
+ def to_hash
8432
+ hash = internal_hash.dup
8433
+ unless children.empty?
8434
+ hash['children'] = children.map(&:to_hash)
8435
+ end
8436
+ hash
8437
+ end
8438
+
8439
+ private
8440
+
8441
+ def set_hash_value(key, value)
8442
+ unless HASH_KEYS.include?(key)
8443
+ raise StandardError, "Unsupported hash key '#{key}'"
8444
+ end
8445
+ internal_hash[key] = value
8446
+ end
8447
+
8448
+ def get_hash_value(key, base_value = nil)
8449
+ unless HASH_KEYS.include?(key)
8450
+ raise StandardError, "Unsupported hash key '#{key}'"
8451
+ end
8452
+ internal_hash[key] = base_value if internal_hash[key].nil?
8453
+ internal_hash[key]
8454
+ end
8455
+
8456
+ def raw_inhibit_warnings_hash
8457
+ get_hash_value('inhibit_warnings', {})
8458
+ end
8459
+
8460
+ def inhibit_warnings_hash
8461
+ inhibit_hash = raw_inhibit_warnings_hash
8462
+ if exclusive?
8463
+ inhibit_hash
8464
+ else
8465
+ parent_hash = parent.send(:inhibit_warnings_hash).dup
8466
+ if parent_hash['not_for_pods']
8467
+ parent_hash['not_for_pods'] -= Array(inhibit_hash['for_pods'])
8468
+ end
8469
+ if parent_hash['for_pods']
8470
+ parent_hash['for_pods'] -= Array(inhibit_hash['not_for_pods'])
8471
+ end
8472
+ if inhibit_hash['all']
8473
+ parent_hash['all'] = true
8474
+ end
8475
+ parent_hash.merge(inhibit_hash) do |_, l, r|
8476
+ Array(l).concat(r).uniq
8477
+ end
8478
+ end
8479
+ end
8480
+
8481
+ def raw_use_modular_headers_hash
8482
+ get_hash_value('use_modular_headers', {})
8483
+ end
8484
+
8485
+ def use_modular_headers_hash
8486
+ raw_hash = raw_use_modular_headers_hash
8487
+ if exclusive?
8488
+ raw_hash
8489
+ else
8490
+ parent_hash = parent.send(:use_modular_headers_hash).dup
8491
+ if parent_hash['not_for_pods']
8492
+ parent_hash['not_for_pods'] -= Array(raw_hash['for_pods'])
8493
+ end
8494
+ if parent_hash['for_pods']
8495
+ parent_hash['for_pods'] -= Array(raw_hash['not_for_pods'])
8496
+ end
8497
+ if raw_hash['all']
8498
+ parent_hash['all'] = true
8499
+ end
8500
+ parent_hash.merge(raw_hash) do |_, l, r|
8501
+ Array(l).concat(r).uniq
8502
+ end
8503
+ end
8504
+ end
8505
+
8506
+ def raw_project_names_hash
8507
+ get_hash_value('project_names', {})
8508
+ end
8509
+
8510
+ def raw_configuration_pod_whitelist
8511
+ get_hash_value('configuration_pod_whitelist', {})
8512
+ end
8513
+
8514
+ def configuration_pod_whitelist
8515
+ raw_configuration_pod_whitelist
8516
+ end
8517
+
8518
+ def pod_dependencies
8519
+ pods = get_hash_value('dependencies') || []
8520
+ pods.map do |name_or_hash|
8521
+ if name_or_hash.is_a?(Hash)
8522
+ name = name_or_hash.keys.first
8523
+ requirements = name_or_hash.values.first
8524
+ else
8525
+ name = name_or_hash
8526
+ requirements = []
8527
+ end
8528
+ Dependency.new(name, *requirements)
8529
+ end
8530
+ end
8531
+
8532
+ def podspec_dependencies
8533
+ podspecs = get_hash_value('podspecs') || []
8534
+ podspecs.map do |options|
8535
+ file = podspec_path_from_options(options)
8536
+ spec = Specification.from_file(file)
8537
+ subspec_names = options[:subspecs] || options[:subspec]
8538
+ specs = if subspec_names.blank?
8539
+ [spec]
8540
+ else
8541
+ subspec_names = [subspec_names] if subspec_names.is_a?(String)
8542
+ subspec_names.map { |subspec_name| spec.subspec_by_name("#{spec.name}/#{subspec_name}") }
8543
+ end
8544
+ specs.map do |subspec|
8545
+ all_specs = [subspec, *subspec.recursive_subspecs]
8546
+ all_deps = all_specs.map { |s| s.dependencies(platform) }.flatten
8547
+ all_deps.reject { |dep| dep.root_name == subspec.root.name }
8548
+ end.flatten
8549
+ end.flatten.uniq
8550
+ end
8551
+
8552
+ def podspec_path_from_options(options)
8553
+ if path = options[:path]
8554
+ if File.basename(path).include?('.podspec')
8555
+ path_with_ext = path
8556
+ else
8557
+ path_with_ext = "#{path}.podspec"
8558
+ end
8559
+ path_without_tilde = path_with_ext.gsub('~', ENV['HOME'])
8560
+ podfile.defined_in_file.dirname + path_without_tilde
8561
+ elsif name = options[:name]
8562
+ name = File.basename(name).include?('.podspec') ? name : "#{name}.podspec"
8563
+ podfile.defined_in_file.dirname + name
8564
+ elsif options[:autodetect]
8565
+ glob_pattern = podfile.defined_in_file.dirname + '*.podspec{,.json}'
8566
+ path = Pathname.glob(glob_pattern).first
8567
+ unless path
8568
+ raise Informative, 'Could not locate a podspec in the current directory. ' \
8569
+ 'You can specify the path via the path option.'
8570
+ end
8571
+ path
8572
+ end
8573
+ end
8574
+
8575
+ def parse_inhibit_warnings(name, requirements)
8576
+ options = requirements.last
8577
+ return requirements unless options.is_a?(Hash)
8578
+ should_inhibit = options.delete(:inhibit_warnings)
8579
+ pod_name = Specification.root_name(name)
8580
+ set_inhibit_warnings_for_pod(pod_name, should_inhibit)
8581
+ requirements.pop if options.empty?
8582
+ end
8583
+
8584
+ def parse_modular_headers(name, requirements)
8585
+ options = requirements.last
8586
+ return requirements unless options.is_a?(Hash)
8587
+ defines_module = options.delete(:modular_headers)
8588
+ pod_name = Specification.root_name(name)
8589
+ set_use_modular_headers_for_pod(pod_name, defines_module)
8590
+ requirements.pop if options.empty?
8591
+ end
8592
+
8593
+ def parse_project_name(name, requirements)
8594
+ options = requirements.last
8595
+ return requirements unless options.is_a?(Hash)
8596
+ project_name = options.delete(:project_name)
8597
+ pod_name = Specification.root_name(name)
8598
+ raw_project_names_hash[pod_name] = project_name if project_name
8599
+ requirements.pop if options.empty?
8600
+ end
8601
+
8602
+ def parse_configuration_whitelist(name, requirements)
8603
+ options = requirements.last
8604
+ return requirements unless options.is_a?(Hash)
8605
+ configurations = options.delete(:configurations)
8606
+ configurations ||= options.delete(:configuration)
8607
+ Array(configurations).each do |configuration|
8608
+ whitelist_pod_for_configuration(name, configuration)
8609
+ end
8610
+ requirements.pop if options.empty?
8611
+ end
8612
+
8613
+ def parse_subspecs(name, requirements)
8614
+ options = requirements.last
8615
+ return false unless options.is_a?(Hash)
8616
+ subspecs = options.delete(:subspecs)
8617
+ test_specs = options.delete(:testspecs)
8618
+ app_specs = options.delete(:appspecs)
8619
+ if subspecs && subspecs.empty?
8620
+ raise StandardError, 'Empty subspecs list.'
8621
+ end
8622
+ subspecs.each do |ss|
8623
+ store_pod("#{name}/#{ss}", *requirements.dup)
8624
+ end if subspecs
8625
+ requirements.pop if options.empty?
8626
+ if test_specs || app_specs
8627
+ options[:testspecs] = test_specs.uniq if test_specs
8628
+ options[:appspecs] = app_specs.uniq if app_specs
8629
+ requirements.push(options)
8630
+ end
8631
+ !subspecs.nil?
8632
+ end
8633
+ end
8634
+ end
8635
+ end
8636
+ `;
8637
+ var RESOLVER = String.raw`
8638
+ module Pod
8639
+ module ExternalSources
8640
+ def self.from_dependency(dependency, podfile_path)
8641
+ params = dependency.external_source
8642
+ name = dependency.root_name
8643
+ if params.key?(:podspec)
8644
+ PodspecSource.new(name, params, podfile_path)
8645
+ elsif params.key?(:path)
8646
+ PathSource.new(name, params, podfile_path)
8647
+ else
8648
+ raise Informative, "Peach does not fetch the external source of '#{name}': #{params}"
8649
+ end
8650
+ end
8651
+
8652
+ class AbstractExternalSource
8653
+ attr_reader :name, :params, :podfile_path
8654
+ def initialize(name, params, podfile_path)
8655
+ @name = name
8656
+ @params = params
8657
+ @podfile_path = podfile_path
8658
+ end
8659
+
8660
+ def normalized_podspec_path(declared_path)
8661
+ extension = File.extname(declared_path)
8662
+ if extension == '.podspec' || extension == '.json'
8663
+ path_with_ext = declared_path
8664
+ else
8665
+ path_with_ext = "#{declared_path}/#{name}.podspec"
8666
+ end
8667
+ podfile_dir = File.dirname(podfile_path || '')
8668
+ File.expand_path(path_with_ext, podfile_dir)
8669
+ end
8670
+
8671
+ private
8672
+
8673
+ def store_podspec(sandbox, spec, json = false)
8674
+ sandbox.store_podspec(name, Specification.from_file(spec), true, true)
8675
+ end
8676
+ end
8677
+
8678
+ class PathSource < AbstractExternalSource
8679
+ def fetch(sandbox)
8680
+ podspec = podspec_path
8681
+ raise Informative, "No podspec found for '#{name}' in '#{declared_path}'" unless podspec.exist?
8682
+ store_podspec(sandbox, podspec, podspec.extname == '.json')
8683
+ sandbox.store_local_path(name, podspec, Pathname(declared_path).absolute? || declared_path.start_with?('~'))
8684
+ end
8685
+
8686
+ def declared_path
8687
+ result = params[:path]
8688
+ result.to_s if result
8689
+ end
8690
+
8691
+ def podspec_path
8692
+ path = Pathname(normalized_podspec_path(declared_path))
8693
+ path.exist? ? path : Pathname("#{path}.json")
8694
+ end
8695
+ end
8696
+
8697
+ class PodspecSource < AbstractExternalSource
8698
+ def fetch(sandbox)
8699
+ podspec_path = Pathname(podspec_uri)
8700
+ raise Informative, "Peach does not download the podspec of '#{name}' from #{podspec_uri}" unless podspec_path.exist?
8701
+ store_podspec(sandbox, podspec_path, podspec_path.extname == '.json')
8702
+ end
8703
+
8704
+ def podspec_uri
8705
+ declared_path = params[:podspec].to_s
8706
+ declared_path =~ %r{^.+://} ? declared_path : normalized_podspec_path(declared_path)
8707
+ end
8708
+ end
8709
+ end
8710
+
8711
+ class Resolver
8712
+ class Vertex
8713
+ attr_reader :name, :requirements, :origins
8714
+ attr_accessor :spec, :platforms
8715
+ def initialize(name)
8716
+ @name = name
8717
+ @requirements = []
8718
+ @origins = []
8719
+ @platforms = []
8720
+ end
8721
+ end
8722
+
8723
+ attr_reader :vertices, :trunk_roots
8724
+
8725
+ # trunk answers versions(name) with its published version strings and
8726
+ # specification(name, version) with the Specification, or nil until fetched
8727
+ def initialize(sandbox, podfile, trunk)
8728
+ @sandbox = sandbox
8729
+ @podfile = podfile
8730
+ @trunk = trunk
8731
+ @chosen = {}
8732
+ @learned = Hash.new { |h, k| h[k] = [] }
8733
+ @excluded = Hash.new { |h, k| h[k] = [] }
8734
+ end
8735
+
8736
+ def fetch_external_sources
8737
+ @podfile.dependencies.select(&:external_source).uniq(&:root_name).sort.each do |dependency|
8738
+ ExternalSources.from_dependency(dependency, @podfile.defined_in_file).fetch(@sandbox)
8739
+ end
8740
+ end
8741
+
8742
+ # the trunk names and versions still to fetch, empty once resolved
8743
+ def resolve
8744
+ @platforms_by_dependency = Hash.new { |h, k| h[k] = [] }
8745
+ explicit = []
8746
+ @podfile.target_definition_list.each do |target|
8747
+ target.dependencies.each do |dep|
8748
+ explicit << dep
8749
+ @platforms_by_dependency[dep.to_s].push(target.platform) if target.platform
8750
+ end
8751
+ end
8752
+ explicit.uniq!
8753
+ @platforms_by_dependency.each_value(&:uniq!)
8754
+ @podfile_requirements = @podfile.dependencies.group_by(&:root_name)
8755
+ 100.times do
8756
+ @missing = []
8757
+ activate(explicit)
8758
+ return @missing.uniq unless @missing.empty?
8759
+ return [] if consistent?
8760
+ end
8761
+ raise Informative, 'CocoaPods dependency resolution did not settle'
8762
+ end
8763
+
8764
+ def specs_by_target
8765
+ @podfile.target_definition_list.each_with_object({}) do |target, result|
8766
+ next if target.abstract? && !target.platform
8767
+ explicit = target.dependencies.map(&:name)
8768
+ used = {}
8769
+ loop do
8770
+ added = @vertices.values.select do |v|
8771
+ v.spec && !used[v.name] && (explicit.include?(v.name) || v.origins.any? { |origin, dep| used[origin] && edge_valid?(origin, dep, target.platform) })
8772
+ end
8773
+ break if added.empty?
8774
+ added.each { |v| used[v.name] = true }
8775
+ end
8776
+ aggregate = {}
8777
+ loop do
8778
+ added = used.keys.select do |name|
8779
+ !aggregate[name] && @vertices[name].spec.library_specification? &&
8780
+ (explicit.include?(name) || @vertices[name].origins.any? { |origin, _| aggregate[origin] })
8781
+ end
8782
+ break if added.empty?
8783
+ added.each { |name| aggregate[name] = true }
8784
+ end
8785
+ result[target] = used.keys.map { |name| [@vertices[name].spec, !aggregate[name]] }.sort_by { |spec, _| spec.name }
8786
+ end
8787
+ end
8788
+
8789
+ def specifications
8790
+ specs_by_target.values.flatten(1).map(&:first).uniq
8791
+ end
8792
+
8793
+ private
8794
+
8795
+ def activate(explicit)
8796
+ @vertices = {}
8797
+ @requirements = Hash.new { |h, k| h[k] = [] }
8798
+ @trunk_roots = []
8799
+ queue = explicit.map { |dep| [dep, nil] }
8800
+ until queue.empty?
8801
+ dep, origin = queue.shift
8802
+ vertex = (@vertices[dep.name] ||= Vertex.new(dep.name))
8803
+ vertex.requirements << dep
8804
+ vertex.origins << [origin, dep] if origin
8805
+ @requirements[dep.root_name] << dep
8806
+ next if vertex.requirements.size > 1
8807
+ root_spec = root_specification(dep)
8808
+ next unless root_spec
8809
+ spec = root_spec.subspec_by_name(dep.name, false, true)
8810
+ raise Informative, "Unable to find a specification for '#{dep}'" unless spec
8811
+ vertex.spec = spec
8812
+ dependencies_for(spec).each { |d| queue << [d, dep.name] }
8813
+ end
8814
+ end
8815
+
8816
+ def dependencies_for(spec)
8817
+ root_name = Specification.root_name(spec.name)
8818
+ spec.all_dependencies.map do |dependency|
8819
+ dependency.root_name == root_name ? dependency.dup.tap { |d| d.specific_version = spec.version } : dependency
8820
+ end
8821
+ end
8822
+
8823
+ def root_specification(dep)
8824
+ root = dep.root_name
8825
+ stored = @sandbox.specification(root)
8826
+ return stored if stored
8827
+ raise Informative, "Unable to find a specification for '#{dep}'" if dep.external_source
8828
+ @trunk_roots << root unless @trunk_roots.include?(root)
8829
+ version = (@chosen[root] ||= choose(root))
8830
+ return nil unless version
8831
+ spec = @trunk.specification(root, version.to_s)
8832
+ @missing << [root, version.to_s] unless spec
8833
+ spec
8834
+ end
8835
+
8836
+ def choose(root)
8837
+ versions = @trunk.versions(root)
8838
+ unless versions
8839
+ @missing << [root, nil]
8840
+ return nil
8841
+ end
8842
+ deps = @requirements[root] + Array(@podfile_requirements[root])
8843
+ requirements = deps.map(&:requirement) + @learned[root]
8844
+ prerelease = deps.any? { |d| d.prerelease? || d.external_source }
8845
+ candidates = versions.map { |v| Version.new(v) }.sort.reverse.reject { |v| @excluded[root].include?(v) }
8846
+ chosen = candidates.find { |v| requirements.all? { |r| r.satisfied_by?(v) } && (prerelease || !v.prerelease?) }
8847
+ raise Informative, "CocoaPods could not find compatible versions for pod '#{root}': #{requirements.map(&:to_s).uniq.join(', ')}" unless chosen
8848
+ chosen
8849
+ end
8850
+
8851
+ # the version each pod took satisfies every requirement on it and the
8852
+ # platforms of every target that reaches it; otherwise the pass repeats
8853
+ def consistent?
8854
+ platforms
8855
+ settled = true
8856
+ @vertices.each_value do |vertex|
8857
+ spec = vertex.spec
8858
+ root = Specification.root_name(vertex.name)
8859
+ unsatisfied = @requirements[root].map(&:requirement).reject { |r| r.satisfied_by?(spec.version) }
8860
+ unless unsatisfied.empty?
8861
+ raise Informative, "CocoaPods could not satisfy #{unsatisfied.map(&:to_s).join(', ')} with '#{root}' (#{spec.version})" unless @chosen.key?(root)
8862
+ @learned[root] |= unsatisfied
8863
+ @chosen.delete(root)
8864
+ settled = false
8865
+ next
8866
+ end
8867
+ next if platform_compatible?(vertex)
8868
+ raise Informative, "The platforms of '#{vertex.name}' (#{spec.available_platforms.map(&:to_s).join(', ')}) do not support #{vertex.platforms.map(&:to_s).join(', ')}" unless @chosen.key?(root)
8869
+ @excluded[root] << spec.version
8870
+ @chosen.delete(root)
8871
+ settled = false
8872
+ end
8873
+ settled
8874
+ end
8875
+
8876
+ def platforms
8877
+ @vertices.each_value do |vertex|
8878
+ vertex.platforms = vertex.requirements.reject { |dep| vertex.origins.any? { |_, d| d.equal?(dep) } }.flat_map { |dep| @platforms_by_dependency[dep.to_s] }.uniq
8879
+ end
8880
+ loop do
8881
+ grew = false
8882
+ @vertices.each_value do |vertex|
8883
+ inherited = vertex.origins.flat_map { |origin, _| @vertices[origin].platforms } - vertex.platforms
8884
+ next if inherited.empty?
8885
+ vertex.platforms |= inherited
8886
+ grew = true
8887
+ end
8888
+ break unless grew
8889
+ end
8890
+ end
8891
+
8892
+ def platform_compatible?(vertex)
8893
+ spec = vertex.spec
8894
+ vertex.platforms.all? do |platform|
8895
+ spec.available_platforms.all? do |spec_platform|
8896
+ spec_platform.name != platform.name || spec.non_library_specification? || platform.supports?(spec_platform)
8897
+ end
8898
+ end
8899
+ end
8900
+
8901
+ def edge_valid?(origin, dep, platform)
8902
+ @vertices[origin].spec.all_dependencies(platform).any? { |d| d.name == dep.name }
8903
+ end
8904
+ end
8905
+ end
8906
+ `;
8907
+
8908
+ // src/pods-analysis.ts
8909
+ init_podspec_cocoapods();
8910
+ init_podspec_ruby();
8911
+ init_podspec_ruby_stdlib();
8912
+ var ANALYSIS = String.raw`
8913
+ module Pod
8914
+ class Podfile
8915
+ class TargetDefinition
8916
+ def supports_swift_version?(swift_version)
8917
+ if swift_version_requirements.nil?
8918
+ root? || parent.supports_swift_version?(swift_version)
8919
+ else
8920
+ Requirement.create(swift_version_requirements).satisfied_by?(swift_version)
8921
+ end
8922
+ end
8923
+ end
8924
+ end
8925
+
8926
+ class Sandbox
8927
+ def pod_dir(name)
8928
+ root_name = Specification.root_name(name)
8929
+ local?(root_name) ? Pathname.new(local_path(root_name)) : root + root_name
8930
+ end
8931
+ end
8932
+
8933
+ class Specification
8934
+ def static_framework
8935
+ attributes_hash['static_framework']
8936
+ end
8937
+
8938
+ def info_plist
8939
+ attributes_hash['info_plist'] || {}
8940
+ end
8941
+
8942
+ def dependency_whitelisted_for_configuration?(dependency, configuration)
8943
+ inherited = -> { root? ? true : parent.dependency_whitelisted_for_configuration?(dependency, configuration) }
8944
+ return inherited[] unless configuration_whitelist = attributes_hash['configuration_pod_whitelist']
8945
+ return inherited[] unless whitelist_for_pod = configuration_whitelist[dependency.name]
8946
+ whitelist_for_pod.include?(configuration.to_s.downcase)
8947
+ end
8948
+ end
8949
+
8950
+ class Target
8951
+ DEFAULT_BUILD_CONFIGURATIONS = { 'Release' => :release, 'Debug' => :debug }.freeze
8952
+ attr_reader :sandbox, :user_build_configurations, :archs, :platform, :build_type
8953
+ private :build_type
8954
+ def initialize(sandbox, build_type, user_build_configurations, archs, platform)
8955
+ @sandbox = sandbox
8956
+ @user_build_configurations = user_build_configurations
8957
+ @archs = archs
8958
+ @platform = platform
8959
+ @build_type = build_type
8960
+ end
8961
+ def name; label; end
8962
+ alias to_s name
8963
+ def build_as_dynamic?; build_type.dynamic?; end
8964
+ def build_as_dynamic_framework?; build_type.dynamic_framework?; end
8965
+ def build_as_framework?; build_type.framework?; end
8966
+ def build_as_library?; build_type.library?; end
8967
+ def build_as_static?; build_type.static?; end
8968
+ def build_as_static_framework?; build_type.static_framework?; end
8969
+ def build_as_static_library?; build_type.static_library?; end
8970
+ def requires_frameworks?; build_as_framework?; end
8971
+ def inspect; "#<#{self.class} name=#{name}>"; end
8972
+ end
8973
+
8974
+ class PodTarget < Target
8975
+ attr_reader :specs, :library_specs, :test_specs, :app_specs, :target_definitions, :swift_version, :dependent_targets, :dependent_targets_by_config
8976
+ def initialize(sandbox, build_type, user_build_configurations, archs, platform, specs, target_definitions, swift_version)
8977
+ super(sandbox, build_type, user_build_configurations, archs, platform)
8978
+ @specs = specs.dup.freeze
8979
+ @target_definitions = target_definitions
8980
+ @swift_version = swift_version
8981
+ by_type = @specs.group_by(&:spec_type)
8982
+ @library_specs = by_type[:library] || []
8983
+ @test_specs = by_type[:test] || []
8984
+ @app_specs = by_type[:app] || []
8985
+ self.dependent_targets = []
8986
+ end
8987
+ def dependent_targets=(targets)
8988
+ @dependent_targets = targets
8989
+ @dependent_targets_by_config = { :debug => targets, :release => targets }
8990
+ end
8991
+ def dependent_targets_by_config=(by_config)
8992
+ @dependent_targets_by_config = by_config
8993
+ @dependent_targets = by_config.values.reduce([], &:|)
8994
+ end
8995
+ def label; root_spec.name; end
8996
+ def root_spec; @root_spec ||= specs.first.root; end
8997
+ def pod_name; root_spec.name; end
8998
+ def product_module_name; root_spec.module_name; end
8999
+ def podfile; target_definitions.first.podfile; end
9000
+ def spec_consumers; specs.map { |spec| spec.consumer(platform) }; end
9001
+ def dependencies
9002
+ spec_consumers.flat_map { |consumer| consumer.dependencies.map { |dep| Specification.root_name(dep.name) } }.uniq
9003
+ end
9004
+ def inhibit_warnings?
9005
+ answers = target_definitions.map { |td| td.inhibits_warnings_for_pod?(root_spec.name) }.uniq
9006
+ answers.size > 1 ? podfile.root_target_definitions.first.inhibits_warnings_for_pod?(root_spec.name) : answers.first || false
9007
+ end
9008
+ def build_pod_as_module?
9009
+ explicit = target_definitions.select { |td| td.dependencies.any? { |d| d.root_name == pod_name } }
9010
+ answers = explicit.group_by { |td| td.build_pod_as_module?(pod_name) }
9011
+ return false if answers.size > 1
9012
+ answers.keys.first == true || target_definitions.all? { |td| td.build_pod_as_module?(pod_name) }
9013
+ end
9014
+ end
9015
+
9016
+ class AggregateTarget < Target
9017
+ attr_reader :target_definition, :client_root, :user_project, :user_target_uuids, :pod_targets_for_build_configuration, :search_paths_aggregate_targets
9018
+ def initialize(sandbox, build_type, user_build_configurations, archs, platform, target_definition, client_root, user_project, user_target_uuids, pod_targets_for_build_configuration)
9019
+ super(sandbox, build_type, user_build_configurations, archs, platform)
9020
+ @target_definition = target_definition
9021
+ @client_root = client_root
9022
+ @user_project = user_project
9023
+ @user_target_uuids = user_target_uuids
9024
+ @pod_targets_for_build_configuration = pod_targets_for_build_configuration
9025
+ @search_paths_aggregate_targets = []
9026
+ end
9027
+ def label; target_definition.label; end
9028
+ def podfile; target_definition.podfile; end
9029
+ def pod_targets; pod_targets_for_build_configuration.values.flatten.uniq; end
9030
+ def pod_targets_for_build_configuration(build_configuration = nil)
9031
+ build_configuration ? @pod_targets_for_build_configuration[build_configuration] || [] : @pod_targets_for_build_configuration
9032
+ end
9033
+ def user_targets
9034
+ user_target_uuids.map { |uuid| user_project.objects_by_uuid[uuid] }
9035
+ end
9036
+ end
9037
+
9038
+ class Installer
9039
+ # Installer::Analyzer#generate_targets for one variant of each pod, which
9040
+ # is every Podfile with one platform and no target-specific subspecs
9041
+ def peach_analyze(resolver, user_build_configurations, user_project, user_target_uuids, user_swift_version)
9042
+ if user_swift_version
9043
+ podfile.target_definition_list.each { |td| td.swift_version = user_swift_version unless td.abstract? }
9044
+ end
9045
+ specs_by_target = resolver.specs_by_target.reject { |td, _| td.abstract? && !td.platform }
9046
+ # keyed by names: a stored podspec is a copy whose subspecs still name the original root
9047
+ variants = {}
9048
+ specs_by_target.each do |td, resolver_specs|
9049
+ resolver_specs.group_by { |spec, _| spec.root.name }.each do |root_name, entries|
9050
+ all = entries.map(&:first)
9051
+ root = all.first.root
9052
+ unless all.all?(&:library_specification?)
9053
+ raise Informative, "Peach builds no test or app specifications (#{root_name} in #{td.label})"
9054
+ end
9055
+ build_type = td.build_type.framework? ? (root.static_framework ? BuildType.static_framework : td.build_type) : BuildType.static_library
9056
+ key = [all.map(&:name).sort, td.platform.to_s, build_type.to_s].join(' ')
9057
+ variants[root_name] ||= {}
9058
+ (variants[root_name][key] ||= [all, build_type, []])[2] << td
9059
+ end
9060
+ end
9061
+ @pod_targets = variants.map do |root_name, by_variant|
9062
+ if by_variant.size > 1
9063
+ raise Informative, "Peach builds one variant of each pod; #{root_name} differs between #{by_variant.values.map { |v| v[2].map(&:label) }.flatten.join(', ')}"
9064
+ end
9065
+ specs, build_type, target_definitions = by_variant.values.first
9066
+ root = specs.first.root
9067
+ target_definitions.reject!(&:abstract?) unless target_definitions.all?(&:abstract?)
9068
+ swift_version = peach_swift_version(root, target_definitions)
9069
+ PodTarget.new(sandbox, build_type, user_build_configurations, [], peach_platform(specs, target_definitions, build_type), specs, target_definitions, swift_version)
9070
+ end
9071
+ all_specs = specs_by_target.values.flatten(1).map(&:first).uniq.group_by(&:name)
9072
+ by_name = @pod_targets.group_by(&:pod_name)
9073
+ @pod_targets.each do |target|
9074
+ target.dependent_targets_by_config = Hash[[:debug, :release].map do |config|
9075
+ specs = {}
9076
+ target.library_specs.each do |s|
9077
+ s.dependencies(target.platform).each do |dep|
9078
+ all_specs[dep.name].each do |spec|
9079
+ raise Informative, "#{s} depends upon #{spec}, which is a #{spec.spec_type} spec." if spec.non_library_specification?
9080
+ specs[spec.name] ||= spec if s.dependency_whitelisted_for_configuration?(dep, config)
9081
+ end
9082
+ end
9083
+ end
9084
+ own = target.library_specs.map(&:name)
9085
+ [config, specs.values.reject { |spec| own.include?(spec.name) }.group_by { |spec| spec.root.name }.map do |root_name, deps|
9086
+ by_name[root_name].find { |t| t.build_as_framework? == target.build_as_framework? && deps.all? { |d| t.specs.map(&:name).include?(d.name) } }
9087
+ end]
9088
+ end]
9089
+ end
9090
+ @aggregate_targets = specs_by_target.keys.reject(&:abstract?).map do |td|
9091
+ configurations = user_build_configurations.keys.concat(td.all_whitelisted_configurations).uniq
9092
+ pods = @pod_targets.select { |t| t.target_definitions.include?(td) }
9093
+ named = specs_by_target[td].group_by { |spec, _| spec.root.name }.reject { |_, entries| entries.all? { |_, non_library_only| non_library_only } }
9094
+ pods.keep_if { |t| named.key?(t.pod_name) }
9095
+ dependencies = td.dependencies.group_by(&:root_name)
9096
+ by_configuration = Hash[configurations.map { |c| [c, []] }]
9097
+ pods.each do |t|
9098
+ configurations.each do |c|
9099
+ answers = (dependencies[t.pod_name] || []).map { |d| td.pod_whitelisted_for_configuration?(d.name, c) }.uniq
9100
+ raise Informative, "The subspecs of #{t.pod_name} are linked to different build configurations for #{td}" if answers.size > 1
9101
+ by_configuration[c] << t unless answers == [false]
9102
+ end
9103
+ end
9104
+ build_type = td.uses_frameworks? ? BuildType.static_framework : BuildType.static_library
9105
+ AggregateTarget.new(sandbox, build_type, user_build_configurations, [], td.platform, td, Config.instance.installation_root, user_project, user_target_uuids, by_configuration)
9106
+ end
9107
+ raise Informative, "Peach builds the pods of one application target, not #{@aggregate_targets.map(&:label).join(', ')}" unless @aggregate_targets.size == 1
9108
+ @aggregate_targets.each do |target|
9109
+ target.search_paths_aggregate_targets.concat(@aggregate_targets.select { |other| target.target_definition.targets_to_inherit_search_paths.include?(other.target_definition) })
9110
+ end
9111
+ run_podfile_pre_install_hooks
9112
+ end
9113
+
9114
+ private
9115
+
9116
+ def peach_platform(specs, target_definitions, build_type)
9117
+ name = target_definitions.first.platform.name
9118
+ defaults = { :ios => '4.3', :osx => '10.6', :tvos => '9.0', :visionos => '1.0', :watchos => '2.0' }
9119
+ target = specs.select(&:library_specification?).map { |s| Version.new(s.deployment_target(name) || defaults[name]) }.max
9120
+ target = [target, Version.new('8.0')].max if name == :ios && build_type.framework?
9121
+ Platform.new(name, target)
9122
+ end
9123
+
9124
+ def peach_swift_version(root, target_definitions)
9125
+ if root.swift_versions.empty?
9126
+ target_definitions.map(&:swift_version).compact.uniq.first
9127
+ else
9128
+ root.swift_versions.sort.reverse.find { |v| target_definitions.all? { |td| td.supports_swift_version?(v) } }.to_s
9129
+ end
9130
+ end
9131
+ end
9132
+ end
9133
+ `;
9134
+ var EXPORT = String.raw`
9135
+ lambda do |installer, attributes|
9136
+ spec_json = lambda do |spec, platform|
9137
+ consumer = spec.consumer(platform)
9138
+ values = attributes.each_with_object({}) { |a, h| h[a] = consumer.value_for_attribute(a.to_sym) }
9139
+ values['pod_target_xcconfig'] = consumer.pod_target_xcconfig
9140
+ values['user_target_xcconfig'] = consumer.user_target_xcconfig
9141
+ values['dependencies'] = consumer.dependencies.map(&:name)
9142
+ { 'name' => spec.name, 'root' => spec.root?, 'deploymentTarget' => spec.deployment_target(platform.name), 'consumer' => values }
9143
+ end
9144
+ {
9145
+ 'pods' => installer.pod_targets.map do |t|
9146
+ root = t.root_spec
9147
+ local = installer.sandbox.local_path(root.name)
9148
+ {
9149
+ 'label' => t.label,
9150
+ 'name' => t.pod_name,
9151
+ 'version' => root.version.to_s,
9152
+ 'moduleName' => t.product_module_name,
9153
+ 'local' => local && local.to_s,
9154
+ 'source' => root.source,
9155
+ 'license' => root.attributes_hash['license'],
9156
+ 'platform' => { 'name' => t.platform.name.to_s, 'deploymentTarget' => t.platform.deployment_target.to_s },
9157
+ 'framework' => t.build_as_framework?,
9158
+ 'dynamic' => t.build_as_dynamic?,
9159
+ 'swiftVersion' => t.swift_version,
9160
+ 'swiftVersions' => root.swift_versions.map(&:to_s),
9161
+ 'targetDefinitions' => t.target_definitions.map(&:label),
9162
+ 'dependencies' => { 'debug' => t.dependent_targets_by_config[:debug].map(&:label), 'release' => t.dependent_targets_by_config[:release].map(&:label) },
9163
+ 'inhibitWarnings' => t.inhibit_warnings?,
9164
+ 'buildPodAsModule' => t.build_pod_as_module?,
9165
+ 'infoPlist' => root.info_plist,
9166
+ 'specs' => t.specs.map { |s| spec_json.call(s, t.platform) },
9167
+ }
9168
+ end,
9169
+ 'aggregates' => installer.aggregate_targets.map do |t|
9170
+ td = t.target_definition
9171
+ {
9172
+ 'label' => t.label,
9173
+ 'name' => td.name,
9174
+ 'platform' => { 'name' => t.platform.name.to_s, 'deploymentTarget' => t.platform.deployment_target.to_s },
9175
+ 'framework' => t.build_as_framework?,
9176
+ 'userBuildConfigurations' => t.user_build_configurations.transform_values(&:to_s),
9177
+ 'podsByConfiguration' => t.pod_targets_for_build_configuration.transform_values { |pods| pods.map(&:label) },
9178
+ 'searchPathsAggregates' => t.search_paths_aggregate_targets.map(&:label),
9179
+ 'inhibitAllWarnings' => td.inhibits_warnings_for_pod?(''),
9180
+ 'swiftVersion' => td.swift_version.to_s,
9181
+ 'setArcCompatibilityFlag' => td.podfile.set_arc_compatibility_flag? ? true : false,
9182
+ 'userTargets' => t.user_target_uuids,
9183
+ 'scriptPhases' => td.script_phases,
9184
+ }
9185
+ end,
9186
+ }
9187
+ end
9188
+ `;
9189
+
9190
+ // src/pods-files.ts
9191
+ init_is_record();
9192
+ init_plist_bytes();
9193
+ var HEADER_EXTENSIONS2 = [
9194
+ ".h",
9195
+ ".hh",
9196
+ ".hpp",
9197
+ ".ipp",
9198
+ ".tpp",
9199
+ ".hxx",
9200
+ ".def",
9201
+ ".inl",
9202
+ ".inc"
9203
+ ];
9204
+ var SOURCE_FILE_EXTENSIONS = [
9205
+ .../* @__PURE__ */ new Set([
9206
+ ".m",
9207
+ ".mm",
9208
+ ".i",
9209
+ ".c",
9210
+ ".cc",
9211
+ ".cxx",
9212
+ ".cpp",
9213
+ ".c++",
9214
+ ".swift",
9215
+ ...HEADER_EXTENSIONS2
9216
+ ])
9217
+ ];
9218
+ var GLOB_PATTERNS = {
9219
+ source_files: `*{${SOURCE_FILE_EXTENSIONS.join(",")}}`,
9220
+ public_header_files: `*{${HEADER_EXTENSIONS2.join(",")}}`
9221
+ };
9222
+
9223
+ // src/pods-post-install.ts
9224
+ init_openstep_plist();
9225
+ init_plist_bytes();
9226
+ init_podspec_cocoapods();
9227
+ init_podspec_ruby();
9228
+ init_podspec_ruby_stdlib();
9229
+ var XCODEPROJ = String.raw`
9230
+ module Xcodeproj
9231
+ module Constants
9232
+ INHERITED_KEYWORDS = ['$(inherited)', '$' + '{inherited}'].freeze
9233
+ PRODUCT_TYPE_UTI = Peach::Xcode.product_type_utis.freeze
9234
+ end
9235
+
9236
+ class Informative < StandardError; end
9237
+
9238
+ module Plist
9239
+ def self.read_from_path(path)
9240
+ path = path.to_s
9241
+ raise Informative, "The plist file at path '#{path}' doesn't exist." unless File.exist?(path)
9242
+ Peach::Xcode.plist_read(path)
9243
+ end
9244
+
9245
+ def self.write_to_path(hash, path)
9246
+ Peach::Xcode.plist_write(path.to_s, hash)
9247
+ end
9248
+ end
9249
+
9250
+ class Config
9251
+ attr_accessor :attributes, :other_linker_flags, :includes
9252
+
9253
+ def initialize(source = {})
9254
+ @attributes, @other_linker_flags, @includes =
9255
+ source.is_a?(Hash) ? Peach::Xcode.config_from_hash(source) : Peach::Xcode.config_parse(source.to_s)
9256
+ end
9257
+
9258
+ def ==(other)
9259
+ other.attributes == attributes && other.other_linker_flags == other_linker_flags && other.includes == includes
9260
+ end
9261
+
9262
+ def merge!(xcconfig)
9263
+ xcconfig = Config.new(xcconfig) if xcconfig.is_a?(Hash)
9264
+ @attributes, @other_linker_flags = Peach::Xcode.config_merge(self, xcconfig)
9265
+ self
9266
+ end
9267
+ alias_method :<<, :merge!
9268
+
9269
+ def merge(config)
9270
+ dup.tap { |copy| copy.merge!(config) }
9271
+ end
9272
+
9273
+ def dup
9274
+ Config.new(to_hash.dup)
9275
+ end
9276
+
9277
+ def to_hash(prefix = nil)
9278
+ raise ArgumentError, 'Peach writes no prefixed xcconfig' if prefix
9279
+ Peach::Xcode.config_hash(self)
9280
+ end
9281
+ alias_method :to_h, :to_hash
9282
+
9283
+ def to_s(prefix = nil)
9284
+ raise ArgumentError, 'Peach writes no prefixed xcconfig' if prefix
9285
+ Peach::Xcode.config_render(self)
9286
+ end
9287
+
9288
+ def save_as(pathname, prefix = nil)
9289
+ return if File.exist?(pathname) && Config.new(pathname) == self
9290
+ File.write(pathname.to_s, to_s(prefix))
9291
+ end
9292
+ end
9293
+
9294
+ class Project
9295
+ attr_reader :path, :root_object, :object_version, :generated_uuids
9296
+
9297
+ # keys whose values name objects without referring to them
9298
+ PEACH_PLAIN_KEYS = %w(isa remoteGlobalIDString containerPortal).freeze
9299
+
9300
+ def initialize(path, objects, root_uuid, object_version)
9301
+ @path = Pathname.new(path)
9302
+ @objects = objects
9303
+ @object_version = object_version
9304
+ @wrapped = {}
9305
+ @generated_uuids = []
9306
+ @available_uuids = []
9307
+ @dirty = false
9308
+ @root_object = object(root_uuid)
9309
+ end
9310
+
9311
+ def object(uuid)
9312
+ @wrapped[uuid] ||= begin
9313
+ attributes = @objects[uuid]
9314
+ raise ArgumentError, "#{path} has no object #{uuid}" unless attributes
9315
+ klass = Object::ISA[attributes['isa']]
9316
+ raise ArgumentError, "Peach models no #{attributes['isa']} (#{uuid} in #{path})" unless klass
9317
+ klass.new(self, uuid, attributes)
9318
+ end
9319
+ end
9320
+
9321
+ def objects_by_uuid
9322
+ @objects.keys.each_with_object({}) { |uuid, by_uuid| by_uuid[uuid] = object(uuid) }
9323
+ end
9324
+
9325
+ def objects
9326
+ @objects.keys.map { |uuid| object(uuid) }
9327
+ end
9328
+
9329
+ def uuids
9330
+ @objects.keys
9331
+ end
9332
+
9333
+ def new(klass)
9334
+ klass = Object.const_get(klass) if klass.is_a?(String)
9335
+ raise ArgumentError, "Peach creates no #{klass}" unless Object::ISA[klass.isa].equal?(klass)
9336
+ uuid = generate_uuid
9337
+ attributes = { 'isa' => klass.isa }
9338
+ klass.peach_defaults.each { |key, value| attributes[key] = value.dup }
9339
+ @objects[uuid] = attributes
9340
+ mark_dirty!
9341
+ object(uuid)
9342
+ end
9343
+
9344
+ def generate_uuid
9345
+ generate_available_uuid_list while @available_uuids.empty?
9346
+ @available_uuids.shift
9347
+ end
9348
+
9349
+ # Xcodeproj draws random ids; Peach derives them from the project and a counter
9350
+ def generate_available_uuid_list(count = 100)
9351
+ start = @generated_uuids.size
9352
+ candidates = Array.new(count) { |i| Digest::SHA1.hexdigest("#{path.basename}/#{start + i}")[0, 24].upcase }
9353
+ uniques = candidates - (@generated_uuids + uuids)
9354
+ @generated_uuids += uniques
9355
+ @available_uuids += uniques
9356
+ end
9357
+
9358
+ def mark_dirty!
9359
+ @dirty = true
9360
+ @referrers = nil
9361
+ end
9362
+
9363
+ def dirty?
9364
+ @dirty
9365
+ end
9366
+
9367
+ def peach_referrers(uuid)
9368
+ unless @referrers
9369
+ @referrers = {}
9370
+ @objects.each do |owner, attributes|
9371
+ attributes.each do |key, value|
9372
+ next if PEACH_PLAIN_KEYS.include?(key)
9373
+ refs = value.is_a?(Array) ? value : [value]
9374
+ refs.each { |ref| (@referrers[ref] ||= []) << owner if ref.is_a?(String) && @objects.key?(ref) }
9375
+ end
9376
+ end
9377
+ end
9378
+ (@referrers[uuid] || []).uniq.map { |owner| object(owner) }
9379
+ end
9380
+
9381
+ def peach_remove(uuid)
9382
+ @objects.each_value do |attributes|
9383
+ attributes.keys.each do |key|
9384
+ next if PEACH_PLAIN_KEYS.include?(key)
9385
+ value = attributes[key]
9386
+ if value == uuid
9387
+ attributes.delete(key)
9388
+ elsif value.is_a?(Array)
9389
+ value.delete(uuid)
9390
+ end
9391
+ end
9392
+ end
9393
+ @objects.delete(uuid)
9394
+ @wrapped.delete(uuid)
9395
+ mark_dirty!
9396
+ end
9397
+
9398
+ # the objects table after Peach's TypeScript integrator changed it
9399
+ def peach_reload(objects)
9400
+ @objects.keys.each do |uuid|
9401
+ next if objects.key?(uuid)
9402
+ @objects.delete(uuid)
9403
+ @wrapped.delete(uuid)
9404
+ end
9405
+ objects.each do |uuid, attributes|
9406
+ current = @objects[uuid]
9407
+ if current
9408
+ current.keys.each { |key| current.delete(key) unless attributes.key?(key) }
9409
+ attributes.each { |key, value| current[key] = value unless current[key] == value }
9410
+ else
9411
+ @objects[uuid] = attributes
9412
+ end
9413
+ end
9414
+ mark_dirty!
9415
+ end
9416
+
9417
+ def project_dir
9418
+ path.dirname
9419
+ end
9420
+
9421
+ def main_group
9422
+ root_object.main_group
9423
+ end
9424
+
9425
+ def [](group_name)
9426
+ main_group[group_name]
9427
+ end
9428
+
9429
+ def targets
9430
+ root_object.targets
9431
+ end
9432
+
9433
+ def native_targets
9434
+ targets.select { |o| o.is_a?(Object::PBXNativeTarget) }
9435
+ end
9436
+
9437
+ def build_configuration_list
9438
+ root_object.build_configuration_list
9439
+ end
9440
+
9441
+ def build_configurations
9442
+ root_object.build_configuration_list.build_configurations
9443
+ end
9444
+
9445
+ def build_settings(name)
9446
+ root_object.build_configuration_list.build_settings(name)
9447
+ end
9448
+
9449
+ def files
9450
+ objects.select { |o| o.is_a?(Object::PBXFileReference) }
9451
+ end
9452
+
9453
+ def groups
9454
+ main_group.groups
9455
+ end
9456
+
9457
+ def products_group
9458
+ root_object.product_ref_group
9459
+ end
9460
+
9461
+ def frameworks_group
9462
+ main_group['Frameworks'] || main_group.new_group('Frameworks')
9463
+ end
9464
+
9465
+ # the tables stay in memory, where Peach reads them
9466
+ def save(save_path = nil)
9467
+ raise ArgumentError, "Peach saves #{path} only in place" if save_path
9468
+ end
9469
+
9470
+ # Xcodeproj's to-many attribute: a live list of the uuids in the owner's table entry
9471
+ class ObjectList
9472
+ include Enumerable
9473
+ attr_reader :owner
9474
+
9475
+ def initialize(owner, key)
9476
+ @owner = owner
9477
+ @key = key
9478
+ end
9479
+
9480
+ def uuids
9481
+ @owner.peach_uuids(@key).dup
9482
+ end
9483
+
9484
+ def objects
9485
+ @owner.peach_uuids(@key).map { |uuid| @owner.project.object(uuid) }
9486
+ end
9487
+ alias_method :to_a, :objects
9488
+ alias_method :to_ary, :objects
9489
+
9490
+ def each(&block)
9491
+ objects.each(&block)
9492
+ self
9493
+ end
9494
+
9495
+ def size
9496
+ @owner.peach_uuids(@key).size
9497
+ end
9498
+ alias_method :length, :size
9499
+
9500
+ def empty?
9501
+ size.zero?
9502
+ end
9503
+
9504
+ def [](index)
9505
+ objects[index]
9506
+ end
9507
+ alias_method :at, :[]
9508
+
9509
+ def first
9510
+ objects.first
9511
+ end
9512
+
9513
+ def last
9514
+ objects.last
9515
+ end
9516
+
9517
+ def index(object = nil, &block)
9518
+ block ? objects.index(&block) : objects.index(object)
9519
+ end
9520
+ alias_method :find_index, :index
9521
+
9522
+ def include?(object)
9523
+ objects.include?(object)
9524
+ end
9525
+
9526
+ def ==(other)
9527
+ objects == (other.is_a?(ObjectList) ? other.objects : other)
9528
+ end
9529
+
9530
+ def inspect
9531
+ objects.inspect
9532
+ end
9533
+
9534
+ def <<(object)
9535
+ live << peach_uuid(object)
9536
+ self
9537
+ end
9538
+ alias_method :push, :<<
9539
+
9540
+ def concat(list)
9541
+ list.each { |object| self << object }
9542
+ self
9543
+ end
9544
+
9545
+ def insert(index, object)
9546
+ live.insert(index, peach_uuid(object))
9547
+ self
9548
+ end
9549
+
9550
+ def unshift(object)
9551
+ live.unshift(peach_uuid(object))
9552
+ self
9553
+ end
9554
+
9555
+ def delete(object)
9556
+ return nil unless object.is_a?(Object::AbstractObject) && live.include?(object.uuid)
9557
+ live.delete(object.uuid)
9558
+ @owner.project.mark_dirty!
9559
+ object
9560
+ end
9561
+
9562
+ def delete_at(index)
9563
+ uuid = live.delete_at(index)
9564
+ @owner.project.mark_dirty!
9565
+ uuid && @owner.project.object(uuid)
9566
+ end
9567
+
9568
+ def delete_if(&block)
9569
+ live.reject! { |uuid| block.call(@owner.project.object(uuid)) }
9570
+ @owner.project.mark_dirty!
9571
+ self
9572
+ end
9573
+
9574
+ def clear
9575
+ live.clear
9576
+ @owner.project.mark_dirty!
9577
+ self
9578
+ end
9579
+
9580
+ def uniq!
9581
+ result = live.uniq!
9582
+ @owner.project.mark_dirty!
9583
+ result && self
9584
+ end
9585
+
9586
+ def move(object, new_index)
9587
+ return if index(object) == new_index
9588
+ raise "Attempt to move object '#{object}' not present in the list '#{inspect}'" unless delete(object)
9589
+ insert(new_index, object)
9590
+ end
9591
+
9592
+ def move_from(current_index, new_index)
9593
+ return if current_index == new_index
9594
+ object = delete_at(current_index)
9595
+ raise "Attempt to move object from index '#{current_index}' which is beyond bounds of the list '#{inspect}'" unless object
9596
+ insert(new_index, object)
9597
+ end
9598
+
9599
+ private
9600
+
9601
+ def live
9602
+ @owner.peach_live_uuids(@key)
9603
+ end
9604
+
9605
+ def peach_uuid(object)
9606
+ unless object.is_a?(Object::AbstractObject) && object.project.equal?(@owner.project)
9607
+ raise ArgumentError, "#{@owner.inspect} lists objects of its own project, not #{object.inspect}"
9608
+ end
9609
+ @owner.project.mark_dirty!
9610
+ object.uuid
9611
+ end
9612
+ end
9613
+
9614
+ module Object
9615
+ class AbstractObject
9616
+ attr_reader :project, :uuid
9617
+
9618
+ def self.isa
9619
+ name.split('::').last
9620
+ end
9621
+
9622
+ def self.peach_defaults
9623
+ inherited = equal?(AbstractObject) ? {} : superclass.peach_defaults
9624
+ inherited.merge(@peach_defaults || {})
9625
+ end
9626
+
9627
+ def initialize(project, uuid, attributes)
9628
+ @project = project
9629
+ @uuid = uuid
9630
+ @attributes = attributes
9631
+ end
9632
+
9633
+ def self.attribute(name, key, default = nil)
9634
+ (@peach_defaults ||= {})[key] = default unless default.nil?
9635
+ define_method(name) { @attributes[key] }
9636
+ define_method("#{name}=") { |value| peach_set(key, value) }
9637
+ end
9638
+
9639
+ def self.has_one(name, key)
9640
+ define_method(name) { (uuid = @attributes[key]) && project.object(uuid) }
9641
+ define_method("#{name}=") { |object| peach_set(key, object) }
9642
+ end
9643
+
9644
+ def self.has_many(name, key)
9645
+ (@peach_defaults ||= {})[key] = []
9646
+ define_method(name) { Project::ObjectList.new(self, key) }
9647
+ end
9648
+
9649
+ def peach_uuid(key)
9650
+ @attributes[key]
9651
+ end
9652
+
9653
+ def peach_uuids(key)
9654
+ @attributes[key] || []
9655
+ end
9656
+
9657
+ def peach_live_uuids(key)
9658
+ @attributes[key] ||= []
9659
+ end
9660
+
9661
+ def peach_set(key, value)
9662
+ value = value.uuid if value.is_a?(AbstractObject)
9663
+ if value.nil?
9664
+ @attributes.delete(key)
9665
+ else
9666
+ @attributes[key] = value
9667
+ end
9668
+ project.mark_dirty!
9669
+ end
9670
+
9671
+ def isa
9672
+ @attributes['isa']
9673
+ end
9674
+
9675
+ def referrers
9676
+ project.peach_referrers(uuid)
9677
+ end
9678
+
9679
+ def mark_project_as_dirty!
9680
+ project.mark_dirty!
9681
+ end
9682
+
9683
+ def remove_from_project
9684
+ project.peach_remove(uuid)
9685
+ end
9686
+
9687
+ def display_name
9688
+ declared_name = name if respond_to?(:name)
9689
+ declared_name && !declared_name.empty? ? declared_name : isa.gsub(/^(PBX|XC)/, '')
9690
+ end
9691
+ alias_method :to_s, :display_name
9692
+
9693
+ def inspect
9694
+ "<#{isa} name=#{display_name.inspect} uuid=#{uuid}>"
9695
+ end
9696
+ end
9697
+
9698
+ module GroupableHelper
9699
+ SOURCE_TREES_BY_KEY = {
9700
+ :absolute => '<absolute>',
9701
+ :group => '<group>',
9702
+ :project => 'SOURCE_ROOT',
9703
+ :built_products => 'BUILT_PRODUCTS_DIR',
9704
+ :developer_dir => 'DEVELOPER_DIR',
9705
+ :sdk_root => 'SDKROOT',
9706
+ }.freeze
9707
+
9708
+ def self.normalize_source_tree(source_tree)
9709
+ source_tree = SOURCE_TREES_BY_KEY[source_tree] if source_tree.is_a?(Symbol)
9710
+ raise "[Xcodeproj] Unrecognized source tree option '#{source_tree}'" unless SOURCE_TREES_BY_KEY.values.include?(source_tree)
9711
+ source_tree
9712
+ end
9713
+
9714
+ def parent
9715
+ parents = referrers
9716
+ parents = parents.select { |o| o.is_a?(PBXGroup) } if parents.count > 1
9717
+ raise "[Xcodeproj] Consistency issue: no parent for object '#{display_name}'" if parents.empty?
9718
+ raise "[Xcodeproj] Consistency issue: unexpected multiple parents for object '#{display_name}'" if parents.count > 1
9719
+ parents.first
9720
+ end
9721
+
9722
+ def real_path
9723
+ source_tree_path = source_tree_real_path
9724
+ source_tree_path ? source_tree_path + (path || '') : Pathname(path || '')
9725
+ end
9726
+
9727
+ def source_tree_real_path
9728
+ case source_tree
9729
+ when '<group>'
9730
+ object_parent = parent
9731
+ if object_parent.isa == 'PBXProject'
9732
+ project.project_dir + project.root_object.project_dir_path
9733
+ else
9734
+ object_parent.real_path
9735
+ end
9736
+ when 'SOURCE_ROOT'
9737
+ project.project_dir
9738
+ when '<absolute>'
9739
+ nil
9740
+ else
9741
+ Pathname.new("$" + "{#{source_tree}}")
9742
+ end
9743
+ end
9744
+
9745
+ def set_source_tree(source_tree)
9746
+ self.source_tree = GroupableHelper.normalize_source_tree(source_tree)
9747
+ end
9748
+
9749
+ def peach_set_path_with_source_tree(new_path, source_tree)
9750
+ new_path = Pathname.new(new_path.to_s)
9751
+ source_tree = GroupableHelper.normalize_source_tree(source_tree)
9752
+ self.source_tree = source_tree
9753
+ if source_tree == '<absolute>'
9754
+ raise "[Xcodeproj] Attempt to set a relative path with an absolute source tree: '#{new_path}'" unless new_path.absolute?
9755
+ self.path = new_path.to_s
9756
+ elsif source_tree == '<group>' || source_tree == 'SOURCE_ROOT'
9757
+ tree_path = source_tree_real_path
9758
+ self.path = tree_path && tree_path.absolute? == new_path.absolute? ? new_path.relative_path_from(tree_path).to_s : new_path.to_s
9759
+ else
9760
+ self.path = new_path.to_s
9761
+ end
9762
+ end
9763
+
9764
+ def build_files
9765
+ referrers.select { |o| o.is_a?(PBXBuildFile) }
9766
+ end
9767
+
9768
+ def remove_from_project
9769
+ build_files.each(&:remove_from_project)
9770
+ super
9771
+ end
9772
+ end
9773
+ class XCBuildConfiguration < AbstractObject
9774
+ MUTUAL_RECURSION_SENTINEL = 'xcodeproj.mutual_recursion_sentinel'.freeze
9775
+ ARRAY_SETTINGS = %w(
9776
+ ALTERNATE_PERMISSIONS_FILES ARCHS BUILD_VARIANTS EXCLUDED_SOURCE_FILE_NAMES FRAMEWORK_SEARCH_PATHS
9777
+ GCC_PREPROCESSOR_DEFINITIONS GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS HEADER_SEARCH_PATHS
9778
+ INFOPLIST_PREPROCESSOR_DEFINITIONS LIBRARY_SEARCH_PATHS OTHER_CFLAGS OTHER_CPLUSPLUSFLAGS OTHER_LDFLAGS
9779
+ REZ_SEARCH_PATHS SECTORDER_FLAGS WARNING_CFLAGS WARNING_LDFLAGS
9780
+ ).freeze
9781
+ ARRAY_SETTINGS_OBJECT_VERSION_50 = %w(
9782
+ ALTERNATE_PERMISSIONS_FILES ARCHS BUILD_VARIANTS EXCLUDED_SOURCE_FILE_NAMES FRAMEWORK_SEARCH_PATHS
9783
+ GCC_PREPROCESSOR_DEFINITIONS GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS HEADER_SEARCH_PATHS
9784
+ INCLUDED_SOURCE_FILE_NAMES INFOPLIST_PREPROCESSOR_DEFINITIONS LD_RUNPATH_SEARCH_PATHS LIBRARY_SEARCH_PATHS
9785
+ LOCALIZED_STRING_MACRO_NAMES OTHER_CFLAGS OTHER_CPLUSPLUSFLAGS OTHER_LDFLAGS REZ_SEARCH_PATHS SECTORDER_FLAGS
9786
+ SYSTEM_FRAMEWORK_SEARCH_PATHS SYSTEM_HEADER_SEARCH_PATHS USER_HEADER_SEARCH_PATHS WARNING_CFLAGS WARNING_LDFLAGS
9787
+ ).freeze
9788
+
9789
+ attribute :name, 'name'
9790
+ has_one :base_configuration_reference, 'baseConfigurationReference'
9791
+
9792
+ def build_settings
9793
+ @attributes['buildSettings'] ||= {}
9794
+ end
9795
+
9796
+ def build_settings=(settings)
9797
+ peach_set('buildSettings', settings)
9798
+ end
9799
+
9800
+ def debug?
9801
+ gcc_preprocessor_definitions = resolve_build_setting('GCC_PREPROCESSOR_DEFINITIONS')
9802
+ gcc_preprocessor_definitions && gcc_preprocessor_definitions.include?('DEBUG=1')
9803
+ end
9804
+
9805
+ def type
9806
+ debug? ? :debug : :release
9807
+ end
9808
+
9809
+ def resolve_build_setting(key, root_target = nil, previous_key = nil)
9810
+ setting = build_settings[key]
9811
+ setting = resolve_variable_substitution(key, setting, root_target, previous_key)
9812
+
9813
+ config_setting = config[key]
9814
+ config_setting = resolve_variable_substitution(key, config_setting, root_target, previous_key)
9815
+
9816
+ project_setting = project.build_configuration_list[name]
9817
+ project_setting = nil if equal?(project_setting)
9818
+ project_setting &&= project_setting.resolve_build_setting(key, root_target)
9819
+
9820
+ defaults = {
9821
+ 'CONFIGURATION' => name,
9822
+ 'SRCROOT' => project.project_dir.to_s,
9823
+ }
9824
+
9825
+ if previous_key.nil? && setting == MUTUAL_RECURSION_SENTINEL
9826
+ setting = nil
9827
+ end
9828
+
9829
+ [defaults[key], project_setting, config_setting, setting, ENV[key]].compact.reduce(nil) do |inherited, value|
9830
+ expand_build_setting(value, inherited)
9831
+ end
9832
+ end
9833
+
9834
+ private
9835
+
9836
+ def expand_build_setting(build_setting_value, config_value)
9837
+ if build_setting_value.is_a?(Array) && config_value.is_a?(String)
9838
+ config_value = split_build_setting_array_to_string(config_value)
9839
+ elsif build_setting_value.is_a?(String) && config_value.is_a?(Array)
9840
+ build_setting_value = split_build_setting_array_to_string(build_setting_value)
9841
+ end
9842
+
9843
+ default = build_setting_value.is_a?(String) ? '' : []
9844
+ inherited = config_value || default
9845
+
9846
+ return build_setting_value.gsub(Regexp.union(Constants::INHERITED_KEYWORDS), inherited) if build_setting_value.is_a? String
9847
+ build_setting_value.flat_map { |value| Constants::INHERITED_KEYWORDS.include?(value) ? inherited : value }
9848
+ end
9849
+
9850
+ def resolve_variable_substitution(key, value, root_target, previous_key = nil)
9851
+ case value
9852
+ when Array
9853
+ return value.map { |v| resolve_variable_substitution(key, v, root_target) }
9854
+ when nil
9855
+ return
9856
+ when String
9857
+ nil
9858
+ else
9859
+ raise ArgumentError, "Settings values can only be nil, string, or array, got #{value.inspect} for #{key}"
9860
+ end
9861
+
9862
+ unless variable_match_data = value.match(/\$(?:[{]([_a-zA-Z0-9]+?)[}]|[(]([_a-zA-Z0-9]+?)[)])/)
9863
+ return value
9864
+ end
9865
+ variable_reference = variable_match_data[0]
9866
+ variable = variable_match_data[1] || variable_match_data[2]
9867
+
9868
+ case variable
9869
+ when 'inherited'
9870
+ value
9871
+ when key
9872
+ nil
9873
+ when previous_key
9874
+ MUTUAL_RECURSION_SENTINEL
9875
+ else
9876
+ configuration_to_resolve_against = root_target ? root_target.build_configuration_list[name] : self
9877
+ resolved_value_for_variable = configuration_to_resolve_against.resolve_build_setting(variable, root_target, key) || ''
9878
+
9879
+ if resolved_value_for_variable == MUTUAL_RECURSION_SENTINEL
9880
+ return MUTUAL_RECURSION_SENTINEL
9881
+ end
9882
+
9883
+ value = value.gsub(variable_reference, resolved_value_for_variable)
9884
+ resolve_variable_substitution(key, value, root_target)
9885
+ end
9886
+ end
9887
+
9888
+ def normalize_array_settings(settings)
9889
+ return unless settings
9890
+
9891
+ array_settings = project.object_version.to_i >= 50 ? ARRAY_SETTINGS_OBJECT_VERSION_50 : ARRAY_SETTINGS
9892
+
9893
+ settings.keys.each do |key|
9894
+ next unless value = settings[key]
9895
+ stripped_key = key.sub(/\[[^\]]+\]$/, '')
9896
+ case value
9897
+ when String
9898
+ next unless array_settings.include?(stripped_key)
9899
+ array_value = split_build_setting_array_to_string(value)
9900
+ next unless array_value.size > 1
9901
+ settings[key] = array_value
9902
+ when Array
9903
+ next if value.size > 1 && array_settings.include?(stripped_key)
9904
+ settings[key] = value.join(' ')
9905
+ end
9906
+ end
9907
+ end
9908
+
9909
+ def split_build_setting_array_to_string(string)
9910
+ regexp = / *((['"]?).*?[^\\]\2)(?=( |\z))/
9911
+ string.scan(regexp).map(&:first)
9912
+ end
9913
+
9914
+ def config
9915
+ return {} unless base_configuration_reference
9916
+ # integration sets the reference after hooks have read the settings
9917
+ @config = nil unless @config_reference == peach_uuid('baseConfigurationReference')
9918
+ @config_reference = peach_uuid('baseConfigurationReference')
9919
+ @config ||=
9920
+ if base_configuration_reference.real_path.exist?
9921
+ Xcodeproj::Config.new(base_configuration_reference.real_path).to_hash.tap do |hash|
9922
+ normalize_array_settings(hash)
9923
+ end
9924
+ else
9925
+ {}
9926
+ end
9927
+ end
9928
+ end
9929
+
9930
+ class XCConfigurationList < AbstractObject
9931
+ attribute :default_configuration_is_visible, 'defaultConfigurationIsVisible', '0'
9932
+ attribute :default_configuration_name, 'defaultConfigurationName'
9933
+ has_many :build_configurations, 'buildConfigurations'
9934
+
9935
+ def [](name)
9936
+ build_configurations.find { |bc| bc.name == name }
9937
+ end
9938
+
9939
+ def build_settings(build_configuration_name)
9940
+ configuration = self[build_configuration_name]
9941
+ configuration && configuration.build_settings
9942
+ end
9943
+ end
9944
+
9945
+ class PBXBuildFile < AbstractObject
9946
+ attribute :settings, 'settings'
9947
+ has_one :file_ref, 'fileRef'
9948
+ has_one :product_ref, 'productRef'
9949
+
9950
+ def display_name
9951
+ if product_ref
9952
+ product_ref.display_name
9953
+ elsif file_ref
9954
+ file_ref.display_name
9955
+ else
9956
+ super
9957
+ end
9958
+ end
9959
+ end
9960
+
9961
+ class AbstractBuildPhase < AbstractObject
9962
+ has_many :files, 'files'
9963
+ attribute :build_action_mask, 'buildActionMask', '2147483647'
9964
+ attribute :run_only_for_deployment_postprocessing, 'runOnlyForDeploymentPostprocessing', '0'
9965
+ attribute :always_out_of_date, 'alwaysOutOfDate'
9966
+
9967
+ def files_references
9968
+ files.map(&:file_ref)
9969
+ end
9970
+
9971
+ def file_display_names
9972
+ files.map(&:display_name)
9973
+ end
9974
+
9975
+ def build_file(file_ref)
9976
+ files.find { |build_file| build_file.peach_uuid('fileRef') == file_ref.uuid }
9977
+ end
9978
+
9979
+ def include?(file_ref)
9980
+ !build_file(file_ref).nil?
9981
+ end
9982
+
9983
+ def add_file_reference(file_ref, avoid_duplicates = false)
9984
+ existing = avoid_duplicates && build_file(file_ref)
9985
+ return existing if existing
9986
+ build_file = project.new(PBXBuildFile)
9987
+ build_file.file_ref = file_ref
9988
+ files << build_file
9989
+ build_file
9990
+ end
9991
+
9992
+ def remove_file_reference(file_ref)
9993
+ build_file = files.find { |bf| bf.file_ref == file_ref }
9994
+ remove_build_file(build_file) if build_file
9995
+ end
9996
+
9997
+ def remove_build_file(build_file)
9998
+ build_file.file_ref = nil
9999
+ build_file.remove_from_project
10000
+ end
10001
+
10002
+ def clear
10003
+ files.objects.each { |bf| remove_build_file(bf) }
10004
+ end
10005
+ alias_method :clear_build_files, :clear
10006
+
10007
+ def display_name
10008
+ super.gsub(/BuildPhase$/, '')
10009
+ end
10010
+ end
10011
+
10012
+ class PBXHeadersBuildPhase < AbstractBuildPhase; end
10013
+ class PBXSourcesBuildPhase < AbstractBuildPhase; end
10014
+ class PBXFrameworksBuildPhase < AbstractBuildPhase; end
10015
+ class PBXResourcesBuildPhase < AbstractBuildPhase; end
10016
+
10017
+ class PBXCopyFilesBuildPhase < AbstractBuildPhase
10018
+ attribute :name, 'name'
10019
+ attribute :dst_path, 'dstPath', ''
10020
+ attribute :dst_subfolder_spec, 'dstSubfolderSpec', '7'
10021
+ end
10022
+
10023
+ class PBXShellScriptBuildPhase < AbstractBuildPhase
10024
+ attribute :name, 'name'
10025
+ attribute :input_paths, 'inputPaths', []
10026
+ attribute :input_file_list_paths, 'inputFileListPaths', []
10027
+ attribute :output_paths, 'outputPaths', []
10028
+ attribute :output_file_list_paths, 'outputFileListPaths', []
10029
+ attribute :shell_path, 'shellPath', '/bin/sh'
10030
+ attribute :shell_script, 'shellScript', "# Type a script or drag a script file from your workspace to insert its path.\n"
10031
+ attribute :show_env_vars_in_log, 'showEnvVarsInLog'
10032
+ attribute :dependency_file, 'dependencyFile'
10033
+ end
10034
+
10035
+ class PBXFileReference < AbstractObject
10036
+ include GroupableHelper
10037
+ attribute :name, 'name'
10038
+ attribute :path, 'path'
10039
+ attribute :source_tree, 'sourceTree', 'SOURCE_ROOT'
10040
+ attribute :explicit_file_type, 'explicitFileType'
10041
+ attribute :last_known_file_type, 'lastKnownFileType'
10042
+ attribute :include_in_index, 'includeInIndex', '1'
10043
+ attribute :fileEncoding, 'fileEncoding'
10044
+
10045
+ def display_name
10046
+ if name
10047
+ name
10048
+ elsif source_tree == 'BUILT_PRODUCTS_DIR'
10049
+ path
10050
+ elsif path
10051
+ File.basename(path)
10052
+ end
10053
+ end
10054
+
10055
+ def set_path(new_path)
10056
+ if new_path
10057
+ peach_set_path_with_source_tree(new_path, source_tree)
10058
+ else
10059
+ self.path = nil
10060
+ end
10061
+ end
10062
+
10063
+ def set_last_known_file_type(type = nil)
10064
+ if type
10065
+ self.last_known_file_type = type
10066
+ elsif path
10067
+ self.last_known_file_type = Peach::Xcode.file_type(File.extname(path)[1..-1].to_s)
10068
+ end
10069
+ end
10070
+
10071
+ def set_explicit_file_type(type = nil)
10072
+ self.last_known_file_type = nil
10073
+ if type
10074
+ self.explicit_file_type = type
10075
+ elsif path
10076
+ self.explicit_file_type = Peach::Xcode.file_type(File.extname(path)[1..-1].to_s)
10077
+ end
10078
+ end
10079
+ end
10080
+
10081
+ class PBXReferenceProxy < AbstractObject
10082
+ include GroupableHelper
10083
+ attribute :name, 'name'
10084
+ attribute :path, 'path'
10085
+ attribute :file_type, 'fileType'
10086
+ attribute :source_tree, 'sourceTree'
10087
+ has_one :remote_ref, 'remoteRef'
10088
+ end
10089
+
10090
+ class PBXGroup < AbstractObject
10091
+ include GroupableHelper
10092
+ has_many :children, 'children'
10093
+ attribute :source_tree, 'sourceTree', '<group>'
10094
+ attribute :path, 'path'
10095
+ attribute :name, 'name'
10096
+
10097
+ def display_name
10098
+ if name
10099
+ name
10100
+ elsif path
10101
+ File.basename(path)
10102
+ elsif equal?(project.main_group)
10103
+ 'Main Group'
10104
+ end
10105
+ end
10106
+
10107
+ def set_path(new_path)
10108
+ if new_path
10109
+ peach_set_path_with_source_tree(new_path, source_tree)
10110
+ else
10111
+ self.path = nil
10112
+ self.source_tree = '<group>'
10113
+ end
10114
+ end
10115
+
10116
+ def files
10117
+ children.select { |o| o.is_a?(PBXFileReference) }
10118
+ end
10119
+
10120
+ def find_file_by_path(file_path)
10121
+ files.find { |ref| ref.path == file_path }
10122
+ end
10123
+
10124
+ def groups
10125
+ children.select { |o| o.instance_of?(PBXGroup) }
10126
+ end
10127
+
10128
+ def recursive_children_groups
10129
+ groups.flat_map { |child| [child] + child.recursive_children_groups }
10130
+ end
10131
+
10132
+ def recursive_children
10133
+ children.flat_map { |child| child.is_a?(PBXGroup) ? [child] + child.recursive_children : [child] }
10134
+ end
10135
+
10136
+ def empty?
10137
+ children.count.zero?
10138
+ end
10139
+
10140
+ # FileReferencesFactory.new_reference for a plain file
10141
+ def new_reference(file_path, source_tree = :group)
10142
+ extension = File.extname(file_path.to_s).downcase
10143
+ raise ArgumentError, "Peach adds no #{extension} reference (#{file_path})" if %w(.xcdatamodeld .xcodeproj).include?(extension)
10144
+ ref = project.new(PBXFileReference)
10145
+ children << ref
10146
+ ref.peach_set_path_with_source_tree(file_path, source_tree)
10147
+ ref.set_last_known_file_type
10148
+ ref.name = ref.path.split('/').last if ref.path.include?('/')
10149
+ ref.include_in_index = nil if File.extname(ref.path).downcase == '.framework'
10150
+ ref
10151
+ end
10152
+ alias_method :new_file, :new_reference
10153
+
10154
+ def new_product_ref_for_target(product_basename, product_type)
10155
+ extension = Peach::Xcode.product_extension(product_type.to_s)
10156
+ product_path = "#{product_type == :static_library ? 'lib' : ''}#{product_basename}"
10157
+ product_path += ".#{extension}" if extension
10158
+ ref = new_reference(product_path, :built_products)
10159
+ ref.include_in_index = '0'
10160
+ ref.set_explicit_file_type
10161
+ ref
10162
+ end
10163
+
10164
+ def new_group(name, group_path = nil, source_tree = :group)
10165
+ group = project.new(PBXGroup)
10166
+ children << group
10167
+ group.name = name
10168
+ group.set_source_tree(source_tree)
10169
+ group.set_path(group_path)
10170
+ group
10171
+ end
10172
+
10173
+ def [](group_path)
10174
+ find_subpath(group_path, false)
10175
+ end
10176
+
10177
+ def <<(child)
10178
+ children << child
10179
+ end
10180
+
10181
+ def find_subpath(group_path, should_create = false)
10182
+ return self unless group_path
10183
+ group_path = group_path.split('/') unless group_path.is_a?(Array)
10184
+ child_name = group_path.first
10185
+ rest = group_path.drop(1)
10186
+ child = children.find { |c| c.display_name == child_name }
10187
+ if child.nil?
10188
+ return nil unless should_create
10189
+ child = new_group(child_name)
10190
+ end
10191
+ rest.empty? ? child : child.find_subpath(rest, should_create)
10192
+ end
10193
+ end
10194
+
10195
+ class PBXVariantGroup < PBXGroup
10196
+ attribute :last_known_file_type, 'lastKnownFileType'
10197
+ end
10198
+
10199
+ class XCVersionGroup < PBXGroup
10200
+ attribute :version_group_type, 'versionGroupType', 'wrapper.xcdatamodel'
10201
+ end
10202
+
10203
+ class PBXContainerItemProxy < AbstractObject
10204
+ attribute :container_portal, 'containerPortal'
10205
+ attribute :proxy_type, 'proxyType'
10206
+ attribute :remote_global_id_string, 'remoteGlobalIDString'
10207
+ attribute :remote_info, 'remoteInfo'
10208
+ end
10209
+
10210
+ class PBXTargetDependency < AbstractObject
10211
+ has_one :target, 'target'
10212
+ has_one :target_proxy, 'targetProxy'
10213
+ has_one :product_ref, 'productRef'
10214
+ attribute :name, 'name'
10215
+
10216
+ def display_name
10217
+ return name if name
10218
+ return target.name if target
10219
+ return target_proxy.remote_info if target_proxy
10220
+ return product_ref.product_name if product_ref
10221
+ end
10222
+ end
10223
+
10224
+ class XCSwiftPackageProductDependency < AbstractObject
10225
+ has_one :package, 'package'
10226
+ attribute :product_name, 'productName'
10227
+
10228
+ def display_name
10229
+ product_name || super
10230
+ end
10231
+ end
10232
+
10233
+ class XCRemoteSwiftPackageReference < AbstractObject
10234
+ attribute :repositoryURL, 'repositoryURL'
10235
+ attribute :requirement, 'requirement'
10236
+
10237
+ def display_name
10238
+ repositoryURL || super
10239
+ end
10240
+ end
10241
+
10242
+ class XCLocalSwiftPackageReference < AbstractObject
10243
+ attribute :path, 'path'
10244
+ attribute :relative_path, 'relativePath'
10245
+ end
10246
+
10247
+ class AbstractTarget < AbstractObject
10248
+ attribute :name, 'name'
10249
+ attribute :product_name, 'productName'
10250
+ has_one :build_configuration_list, 'buildConfigurationList'
10251
+ has_many :dependencies, 'dependencies'
10252
+ has_many :build_phases, 'buildPhases'
10253
+
10254
+ def build_configurations
10255
+ build_configuration_list.build_configurations
10256
+ end
10257
+
10258
+ def build_settings(build_configuration_name)
10259
+ build_configuration_list.build_settings(build_configuration_name)
10260
+ end
10261
+
10262
+ def common_resolved_build_setting(key)
10263
+ values = build_configurations.map { |config| config.resolve_build_setting(key, self) }.compact.uniq
10264
+ values.first if values.count <= 1
10265
+ end
10266
+
10267
+ def dependency_for_target(target)
10268
+ dependencies.find { |dep| dep.target ? dep.target.uuid == target.uuid : dep.target_proxy && dep.target_proxy.remote_global_id_string == target.uuid }
10269
+ end
10270
+
10271
+ def shell_script_build_phases
10272
+ build_phases.select { |o| o.is_a?(PBXShellScriptBuildPhase) }
10273
+ end
10274
+
10275
+ def copy_files_build_phases
10276
+ build_phases.select { |o| o.is_a?(PBXCopyFilesBuildPhase) }
10277
+ end
10278
+
10279
+ def new_shell_script_build_phase(name = nil)
10280
+ phase = project.new(PBXShellScriptBuildPhase)
10281
+ phase.name = name
10282
+ build_phases << phase
10283
+ phase
10284
+ end
10285
+
10286
+ def new_copy_files_build_phase(name = nil)
10287
+ phase = project.new(PBXCopyFilesBuildPhase)
10288
+ phase.name = name
10289
+ build_phases << phase
10290
+ phase
10291
+ end
10292
+ end
10293
+
10294
+ class PBXNativeTarget < AbstractTarget
10295
+ attribute :product_type, 'productType'
10296
+ attribute :product_install_path, 'productInstallPath'
10297
+ has_one :product_reference, 'productReference'
10298
+ has_many :package_product_dependencies, 'packageProductDependencies'
10299
+
10300
+ def symbol_type
10301
+ Constants::PRODUCT_TYPE_UTI.key(product_type)
10302
+ end
10303
+
10304
+ def test_target_type?
10305
+ %i(octest_bundle unit_test_bundle ui_test_bundle).include?(symbol_type)
10306
+ end
10307
+
10308
+ def extension_target_type?
10309
+ %i(app_extension watch_extension watch2_extension tv_extension messages_extension).include?(symbol_type)
10310
+ end
10311
+
10312
+ def launchable_target_type?
10313
+ %i(application command_line_tool).include?(symbol_type)
10314
+ end
10315
+
10316
+ def source_build_phase
10317
+ peach_phase(PBXSourcesBuildPhase)
10318
+ end
10319
+
10320
+ def headers_build_phase
10321
+ peach_phase(PBXHeadersBuildPhase)
10322
+ end
10323
+
10324
+ def frameworks_build_phase
10325
+ peach_phase(PBXFrameworksBuildPhase)
10326
+ end
10327
+
10328
+ def resources_build_phase
10329
+ peach_phase(PBXResourcesBuildPhase)
10330
+ end
10331
+
10332
+ def add_file_references(file_references, compiler_flags = {})
10333
+ file_references.map do |file|
10334
+ header = Peach::Xcode.header?(file.path)
10335
+ phase = header ? headers_build_phase : source_build_phase
10336
+ build_file = phase.build_file(file) || phase.add_file_reference(file)
10337
+ if compiler_flags && !compiler_flags.empty? && !header
10338
+ settings = build_file.settings || {}
10339
+ settings['COMPILER_FLAGS'] = [settings['COMPILER_FLAGS'], compiler_flags].compact.join(' ')
10340
+ build_file.settings = settings
10341
+ end
10342
+ yield build_file if block_given?
10343
+ build_file
10344
+ end
10345
+ end
10346
+
10347
+ def add_resources(resource_file_references)
10348
+ resource_file_references.each do |file|
10349
+ resources_build_phase.add_file_reference(file) unless resources_build_phase.include?(file)
10350
+ end
10351
+ end
10352
+
10353
+ private
10354
+
10355
+ def peach_phase(klass)
10356
+ build_phases.find { |phase| phase.instance_of?(klass) } || project.new(klass).tap { |phase| build_phases << phase }
10357
+ end
10358
+ end
10359
+
10360
+ class PBXAggregateTarget < AbstractTarget; end
10361
+ class PBXLegacyTarget < AbstractTarget; end
10362
+
10363
+ class PBXProject < AbstractObject
10364
+ has_many :targets, 'targets'
10365
+ attribute :attributes, 'attributes'
10366
+ has_one :build_configuration_list, 'buildConfigurationList'
10367
+ attribute :compatibility_version, 'compatibilityVersion'
10368
+ attribute :development_region, 'developmentRegion'
10369
+ attribute :known_regions, 'knownRegions'
10370
+ has_one :main_group, 'mainGroup'
10371
+ has_one :product_ref_group, 'productRefGroup'
10372
+ attribute :project_dir_path, 'projectDirPath', ''
10373
+ attribute :project_root, 'projectRoot', ''
10374
+ has_many :package_references, 'packageReferences'
10375
+
10376
+ def name
10377
+ project.path.basename('.xcodeproj').to_s
10378
+ end
10379
+ end
10380
+
10381
+ ISA = [
10382
+ XCBuildConfiguration, XCConfigurationList, PBXBuildFile, PBXHeadersBuildPhase, PBXSourcesBuildPhase,
10383
+ PBXFrameworksBuildPhase, PBXResourcesBuildPhase, PBXCopyFilesBuildPhase, PBXShellScriptBuildPhase,
10384
+ PBXFileReference, PBXReferenceProxy, PBXGroup, PBXVariantGroup, XCVersionGroup, PBXContainerItemProxy,
10385
+ PBXTargetDependency, XCSwiftPackageProductDependency, XCRemoteSwiftPackageReference,
10386
+ XCLocalSwiftPackageReference, PBXNativeTarget, PBXAggregateTarget, PBXLegacyTarget, PBXProject,
10387
+ ].each_with_object({}) { |klass, by_isa| by_isa[klass.isa] = klass }.freeze
10388
+ end
10389
+
10390
+ include Object
10391
+ end
10392
+ end
10393
+
10394
+ module Pod
10395
+ class Project < Xcodeproj::Project
10396
+ def initialize(path, objects, root_uuid, object_version)
10397
+ @uuid_prefix = Digest::SHA256.hexdigest(File.basename(path)).upcase
10398
+ super
10399
+ end
10400
+
10401
+ def generate_available_uuid_list(count = 100)
10402
+ start = @generated_uuids.size
10403
+ uniques = Array.new(count) { |i| format('%.6s%07X0', @uuid_prefix, start + i) }
10404
+ @generated_uuids += uniques
10405
+ @available_uuids += uniques
10406
+ end
10407
+
10408
+ def pods
10409
+ main_group['Pods']
10410
+ end
10411
+
10412
+ def development_pods
10413
+ main_group['Development Pods']
10414
+ end
10415
+
10416
+ def pod_groups
10417
+ [pods, development_pods].compact.flat_map(&:children)
10418
+ end
10419
+
10420
+ def pod_group(pod_name)
10421
+ pod_groups.find { |group| group.name == pod_name }
10422
+ end
10423
+ end
10424
+ end
10425
+ `;
10426
+ var INSTALLER = String.raw`
10427
+ module Pod
10428
+ class Installer
10429
+ class Xcode
10430
+ class PodsProjectGenerator
10431
+ class TargetInstallationResult
10432
+ attr_reader :target, :native_target, :resource_bundle_targets, :test_native_targets,
10433
+ :test_resource_bundle_targets, :test_app_host_targets, :app_native_targets,
10434
+ :app_resource_bundle_targets
10435
+
10436
+ def initialize(target, native_target, resource_bundle_targets = [])
10437
+ @target = target
10438
+ @native_target = native_target
10439
+ @resource_bundle_targets = resource_bundle_targets
10440
+ @test_native_targets = []
10441
+ @test_resource_bundle_targets = {}
10442
+ @test_app_host_targets = []
10443
+ @app_native_targets = {}
10444
+ @app_resource_bundle_targets = {}
10445
+ end
10446
+ end
10447
+
10448
+ class InstallationResults
10449
+ attr_reader :pod_target_installation_results, :aggregate_target_installation_results
10450
+
10451
+ def initialize(pod_target_installation_results, aggregate_target_installation_results)
10452
+ @pod_target_installation_results = pod_target_installation_results
10453
+ @aggregate_target_installation_results = aggregate_target_installation_results
10454
+ end
10455
+ end
10456
+ end
10457
+ end
10458
+
10459
+ attr_reader :pods_project, :target_installation_results
10460
+
10461
+ def generated_projects
10462
+ [pods_project]
10463
+ end
10464
+
10465
+ def generated_pod_targets
10466
+ pod_targets
10467
+ end
10468
+
10469
+ def generated_aggregate_targets
10470
+ aggregate_targets
10471
+ end
10472
+
10473
+ # what pod install does once it has generated the Pods project
10474
+ def peach_install(pods_project, pod_results, aggregate_results, aggregate_xcconfigs, pod_xcconfigs, file_accessors)
10475
+ @pods_project = pods_project
10476
+ result_class = Xcode::PodsProjectGenerator::TargetInstallationResult
10477
+ by_label = pod_targets.each_with_object({}) { |t, h| h[t.label] = t }
10478
+ aggregates_by_label = aggregate_targets.each_with_object({}) { |t, h| h[t.label] = t }
10479
+ pods = pod_results.each_with_object({}) do |(label, (native_target, bundles)), h|
10480
+ h[label] = result_class.new(by_label.fetch(label), pods_project.object(native_target), bundles.map { |uuid| pods_project.object(uuid) })
10481
+ end
10482
+ aggregates = aggregate_results.each_with_object({}) do |(label, native_target), h|
10483
+ h[label] = result_class.new(aggregates_by_label.fetch(label), pods_project.object(native_target))
10484
+ end
10485
+ @target_installation_results = Xcode::PodsProjectGenerator::InstallationResults.new(pods, aggregates)
10486
+ aggregate_xcconfigs.each { |label, by_config| aggregates_by_label.fetch(label).peach_xcconfigs = by_config }
10487
+ pod_xcconfigs.each { |label, by_config| by_label.fetch(label).peach_xcconfigs = by_config }
10488
+ file_accessors.each { |label, accessors| by_label.fetch(label).peach_file_accessors = accessors }
10489
+ run_podfile_post_install_hooks
10490
+ integrate_user_project
10491
+ perform_post_install_actions
10492
+ end
10493
+
10494
+ def integrate_user_project
10495
+ UserProjectIntegrator.new(podfile, sandbox, Pod::Config.instance.installation_root, aggregate_targets,
10496
+ generated_aggregate_targets).integrate!
10497
+ run_podfile_post_integrate_hooks
10498
+ end
10499
+ end
10500
+
10501
+ class Target
10502
+ def support_files_dir
10503
+ sandbox.root + 'Target Support Files' + label
10504
+ end
10505
+
10506
+ def xcconfig_path(variant = nil)
10507
+ if variant
10508
+ support_files_dir + "#{label}.#{variant.to_s.gsub(File::SEPARATOR, '-').downcase}.xcconfig"
10509
+ else
10510
+ support_files_dir + "#{label}.xcconfig"
10511
+ end
10512
+ end
10513
+ end
10514
+
10515
+ class AggregateTarget
10516
+ attr_writer :peach_xcconfigs
10517
+
10518
+ def xcconfigs
10519
+ @peach_xcconfigs
10520
+ end
10521
+
10522
+ def build_settings(configuration_name = nil)
10523
+ @build_settings ||= @peach_xcconfigs.each_with_object({}) do |(name, xcconfig), by_name|
10524
+ by_name[name] = Target::BuildSettings::AggregateTargetSettings.new(xcconfig)
10525
+ end
10526
+ if configuration_name
10527
+ @build_settings[configuration_name] ||
10528
+ raise(ArgumentError, "#{self} does not contain a build setting for the #{configuration_name} configuration, only #{@build_settings.keys}")
10529
+ else
10530
+ @build_settings.each_value.first || raise(ArgumentError, "#{self} does not contain any build settings")
10531
+ end
10532
+ end
10533
+ end
10534
+
10535
+ class PodTarget
10536
+ attr_writer :peach_file_accessors, :peach_xcconfigs
10537
+
10538
+ def file_accessors
10539
+ @peach_file_accessors
10540
+ end
10541
+
10542
+ def build_settings
10543
+ @build_settings ||= @peach_xcconfigs.each_with_object({}) do |(name, xcconfig), by_name|
10544
+ by_name[name] = Target::BuildSettings::PodTargetSettings.new(xcconfig)
10545
+ end
10546
+ end
10547
+ end
10548
+
10549
+ class Target
10550
+ # the settings Peach computed, as the xcconfig CocoaPods writes for them
10551
+ class BuildSettings
10552
+ attr_reader :xcconfig
10553
+
10554
+ def initialize(xcconfig)
10555
+ @xcconfig = xcconfig
10556
+ end
10557
+
10558
+ class PodTargetSettings < BuildSettings; end
10559
+ class AggregateTargetSettings < BuildSettings; end
10560
+ end
10561
+ end
10562
+
10563
+ class Sandbox
10564
+ class FileAccessor
10565
+ attr_reader :spec, :resource_bundles
10566
+
10567
+ def initialize(spec, resource_bundles)
10568
+ @spec = spec
10569
+ @resource_bundles = resource_bundles
10570
+ end
10571
+ end
10572
+ end
10573
+ end
10574
+ `;
10575
+
10576
+ // src/pods-project.ts
10577
+ init_openstep_plist();
10578
+ var HEADERS = new Set(HEADER_EXTENSIONS2);
10579
+ var SOURCES = new Set(SOURCE_FILE_EXTENSIONS);
10580
+
10581
+ // src/pods-install.ts
10582
+ init_podspec_cocoapods();
10583
+ init_podspec_ruby();
10584
+ init_podspec_ruby_stdlib();
10585
+ var COCOAPODS_VERSION2 = "1.17.0";
10586
+ var INSTALL_INPUTS = String.raw`
10587
+ lambda do |podfile, sandbox, resolver|
10588
+ roots = resolver.specifications.map(&:root).uniq
10589
+ {
10590
+ 'definitions' => podfile.target_definition_list.reject(&:abstract?).map do |td|
10591
+ { 'name' => td.name.to_s, 'project' => td.user_project_path&.to_s, 'configurations' => (td.build_configurations || {}).map { |name, type| [name.to_s, type.to_s] }.to_h }
10592
+ end,
10593
+ 'workspace' => podfile.workspace_path&.to_s,
10594
+ 'downloads' => roots.reject { |spec| sandbox.local?(spec.name) }.map { |spec| [spec.name, spec.to_pretty_json] },
10595
+ 'stored' => sandbox.stored_podspecs.map { |name, spec| [name, spec.to_pretty_json] },
10596
+ }
10597
+ end
10598
+ `;
10599
+ var LOCKFILE = String.raw`
10600
+ lambda do |podfile, sandbox, resolver|
10601
+ specs = resolver.specifications
10602
+ pods = specs.each_with_object({}) { |spec, result| (result[spec.to_s] ||= []).concat(spec.all_dependencies.map(&:to_s)) }
10603
+ trunk = specs.map(&:root).uniq.reject { |spec| sandbox.specification(spec.name) }.map(&:name)
10604
+ {
10605
+ 'PODS' => pods.map { |name, deps| deps.empty? ? name : { name => deps.uniq } },
10606
+ 'DEPENDENCIES' => podfile.dependencies.map(&:to_s),
10607
+ 'SPEC REPOS' => trunk.empty? ? {} : { 'trunk' => trunk },
10608
+ 'EXTERNAL SOURCES' => podfile.dependencies.select(&:external?).each_with_object({}) { |dep, result| result[dep.root_name] = dep.external_source },
10609
+ 'SPEC CHECKSUMS' => specs.select(&:defined_in_file).each_with_object({}) { |spec, result| result[spec.root.name] = spec.checksum },
10610
+ 'PODFILE CHECKSUM' => podfile.checksum,
10611
+ 'COCOAPODS' => '${COCOAPODS_VERSION2}',
10612
+ }
10613
+ end
10614
+ `;
10615
+
7464
10616
  // src/expo-native-workspace.ts
7465
10617
  init_podspec_sources();
7466
10618
 
@@ -7498,7 +10650,6 @@ init_swift_root_lock();
7498
10650
  init_swift_toolchain();
7499
10651
  init_workspace_root();
7500
10652
  init_xcode_project();
7501
- var utf8Env = { ...process.env, LANG: "en_US.UTF-8", LC_ALL: "en_US.UTF-8" };
7502
10653
  var ABANDONED_WORKSPACE_MS = 24 * 36e5;
7503
10654
 
7504
10655
  // src/expoSwiftContract.ts
@@ -7519,8 +10670,8 @@ var IDENTITY_SOURCE_SKIPS = 1 | 4 | 8 | 16 | 32 | 64 | 128 | 4096;
7519
10670
 
7520
10671
  // src/expo-swift-host.ts
7521
10672
  var import_node_async_hooks3 = require("node:async_hooks");
7522
- var import_node_child_process9 = require("node:child_process");
7523
- var import_node_util9 = require("node:util");
10673
+ var import_node_child_process8 = require("node:child_process");
10674
+ var import_node_util8 = require("node:util");
7524
10675
  init_answeredNativePackages();
7525
10676
 
7526
10677
  // src/app-config.ts
@@ -9186,7 +12337,7 @@ init_swift_standins();
9186
12337
  init_swift_submit();
9187
12338
  init_swift_toolchain();
9188
12339
  init_turbo_source();
9189
- var run5 = (0, import_node_util9.promisify)(import_node_child_process9.execFile);
12340
+ var run5 = (0, import_node_util8.promisify)(import_node_child_process8.execFile);
9190
12341
  var scriptEnv = { ...process.env, [PEACH_FORKED_SCRIPT_ENV]: "1" };
9191
12342
  var traceStore = new import_node_async_hooks3.AsyncLocalStorage();
9192
12343
  var openPreparations = new NativePreparationReceipts();