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.
- package/cli/commands/preview.ts +2 -1
- package/cli/outbound-endpoints.ts +10 -2
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +15792 -5999
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +14638 -4887
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +15465 -5754
- package/dist-lib/host/fetch-proxy-handler.cjs +3205 -54
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +3542 -391
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +3438 -287
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +2 -2
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +24 -24
- package/dist-lib/public-origins-lib.json +174 -81
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +16783 -6989
- package/dist-lib/swift-compile.cjs +2 -2
- package/dist-lib/swift-compile.mjs +2 -2
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +95 -27
- package/dist-lib/vite.cjs +3331 -180
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/expo-native-workspace.ts +23 -63
- package/src/pbx-table.ts +200 -0
- package/src/pod-sources.ts +628 -0
- package/src/podfile-cocoapods.ts +40 -3
- package/src/pods-analysis.ts +488 -0
- package/src/pods-build-settings.ts +1015 -0
- package/src/pods-files.ts +478 -0
- package/src/pods-install.ts +475 -0
- package/src/pods-integration.ts +778 -0
- package/src/pods-post-install.ts +1811 -0
- package/src/pods-project.ts +2416 -0
- package/src/pods-scripts.ts +409 -0
- package/src/pods-targets.ts +757 -0
- package/src/pods-xcconfig.ts +198 -0
- package/src/podspec-cocoapods.ts +29 -3
- package/src/podspec-ruby-stdlib.ts +111 -10
- package/src/podspec-ruby.ts +52 -8
- package/src/swift-catalog-png.ts +75 -0
- package/src/swift-host.ts +4 -3
- package/src/swift-root-lock.ts +0 -10
- package/src/swift-source-pods.ts +29 -73
- package/src/turbo-source.ts +16 -37
|
@@ -0,0 +1,1811 @@
|
|
|
1
|
+
// runs what pod install does after generating the Pods project: the Podfile's
|
|
2
|
+
// install hooks and the integration of the application's targets, against the
|
|
3
|
+
// projects Peach holds in memory. the Ruby below is the part of Xcodeproj
|
|
4
|
+
// 1.28's object model those hooks use (MIT, Eloy Durán and the Xcodeproj team)
|
|
5
|
+
// over the projects' objects tables; anything outside it fails as an
|
|
6
|
+
// undefined method.
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import { isDict, type PlistDict, type PlistValue } from './openstep-plist'
|
|
10
|
+
import { normalizeArraySettings, PbxTable } from './pbx-table'
|
|
11
|
+
import { parsePlistBytes } from './plist-bytes'
|
|
12
|
+
import {
|
|
13
|
+
FILE_TYPES_BY_EXTENSION,
|
|
14
|
+
integrateUserTargets,
|
|
15
|
+
isHeader,
|
|
16
|
+
PRODUCT_TYPE_UTI,
|
|
17
|
+
PRODUCT_UTI_EXTENSIONS,
|
|
18
|
+
UserProject,
|
|
19
|
+
} from './pods-integration'
|
|
20
|
+
import { XcodeConfig } from './pods-xcconfig'
|
|
21
|
+
import { rubyFailures } from './podspec-cocoapods'
|
|
22
|
+
import {
|
|
23
|
+
type Call,
|
|
24
|
+
type Interpreter,
|
|
25
|
+
RFloat,
|
|
26
|
+
RHash,
|
|
27
|
+
RModule,
|
|
28
|
+
RObject,
|
|
29
|
+
RString,
|
|
30
|
+
RSymbol,
|
|
31
|
+
str,
|
|
32
|
+
sym,
|
|
33
|
+
UnsupportedRuby,
|
|
34
|
+
type Value,
|
|
35
|
+
} from './podspec-ruby'
|
|
36
|
+
import { fromJson, toJson } from './podspec-ruby-stdlib'
|
|
37
|
+
import type { AnalyzedAggregateTarget } from './pods-analysis'
|
|
38
|
+
import type { PodsBuildSettings } from './pods-build-settings'
|
|
39
|
+
import type { PodTargets } from './pods-targets'
|
|
40
|
+
|
|
41
|
+
const LINKER_KEYS = [
|
|
42
|
+
'simple',
|
|
43
|
+
'frameworks',
|
|
44
|
+
'weak_frameworks',
|
|
45
|
+
'libraries',
|
|
46
|
+
'arg_files',
|
|
47
|
+
'force_load',
|
|
48
|
+
] as const
|
|
49
|
+
|
|
50
|
+
const XCODEPROJ = String.raw`
|
|
51
|
+
module Xcodeproj
|
|
52
|
+
module Constants
|
|
53
|
+
INHERITED_KEYWORDS = ['$(inherited)', '$' + '{inherited}'].freeze
|
|
54
|
+
PRODUCT_TYPE_UTI = Peach::Xcode.product_type_utis.freeze
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class Informative < StandardError; end
|
|
58
|
+
|
|
59
|
+
module Plist
|
|
60
|
+
def self.read_from_path(path)
|
|
61
|
+
path = path.to_s
|
|
62
|
+
raise Informative, "The plist file at path '#{path}' doesn't exist." unless File.exist?(path)
|
|
63
|
+
Peach::Xcode.plist_read(path)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.write_to_path(hash, path)
|
|
67
|
+
Peach::Xcode.plist_write(path.to_s, hash)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class Config
|
|
72
|
+
attr_accessor :attributes, :other_linker_flags, :includes
|
|
73
|
+
|
|
74
|
+
def initialize(source = {})
|
|
75
|
+
@attributes, @other_linker_flags, @includes =
|
|
76
|
+
source.is_a?(Hash) ? Peach::Xcode.config_from_hash(source) : Peach::Xcode.config_parse(source.to_s)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def ==(other)
|
|
80
|
+
other.attributes == attributes && other.other_linker_flags == other_linker_flags && other.includes == includes
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def merge!(xcconfig)
|
|
84
|
+
xcconfig = Config.new(xcconfig) if xcconfig.is_a?(Hash)
|
|
85
|
+
@attributes, @other_linker_flags = Peach::Xcode.config_merge(self, xcconfig)
|
|
86
|
+
self
|
|
87
|
+
end
|
|
88
|
+
alias_method :<<, :merge!
|
|
89
|
+
|
|
90
|
+
def merge(config)
|
|
91
|
+
dup.tap { |copy| copy.merge!(config) }
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def dup
|
|
95
|
+
Config.new(to_hash.dup)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def to_hash(prefix = nil)
|
|
99
|
+
raise ArgumentError, 'Peach writes no prefixed xcconfig' if prefix
|
|
100
|
+
Peach::Xcode.config_hash(self)
|
|
101
|
+
end
|
|
102
|
+
alias_method :to_h, :to_hash
|
|
103
|
+
|
|
104
|
+
def to_s(prefix = nil)
|
|
105
|
+
raise ArgumentError, 'Peach writes no prefixed xcconfig' if prefix
|
|
106
|
+
Peach::Xcode.config_render(self)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def save_as(pathname, prefix = nil)
|
|
110
|
+
return if File.exist?(pathname) && Config.new(pathname) == self
|
|
111
|
+
File.write(pathname.to_s, to_s(prefix))
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
class Project
|
|
116
|
+
attr_reader :path, :root_object, :object_version, :generated_uuids
|
|
117
|
+
|
|
118
|
+
# keys whose values name objects without referring to them
|
|
119
|
+
PEACH_PLAIN_KEYS = %w(isa remoteGlobalIDString containerPortal).freeze
|
|
120
|
+
|
|
121
|
+
def initialize(path, objects, root_uuid, object_version)
|
|
122
|
+
@path = Pathname.new(path)
|
|
123
|
+
@objects = objects
|
|
124
|
+
@object_version = object_version
|
|
125
|
+
@wrapped = {}
|
|
126
|
+
@generated_uuids = []
|
|
127
|
+
@available_uuids = []
|
|
128
|
+
@dirty = false
|
|
129
|
+
@root_object = object(root_uuid)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def object(uuid)
|
|
133
|
+
@wrapped[uuid] ||= begin
|
|
134
|
+
attributes = @objects[uuid]
|
|
135
|
+
raise ArgumentError, "#{path} has no object #{uuid}" unless attributes
|
|
136
|
+
klass = Object::ISA[attributes['isa']]
|
|
137
|
+
raise ArgumentError, "Peach models no #{attributes['isa']} (#{uuid} in #{path})" unless klass
|
|
138
|
+
klass.new(self, uuid, attributes)
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def objects_by_uuid
|
|
143
|
+
@objects.keys.each_with_object({}) { |uuid, by_uuid| by_uuid[uuid] = object(uuid) }
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def objects
|
|
147
|
+
@objects.keys.map { |uuid| object(uuid) }
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def uuids
|
|
151
|
+
@objects.keys
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def new(klass)
|
|
155
|
+
klass = Object.const_get(klass) if klass.is_a?(String)
|
|
156
|
+
raise ArgumentError, "Peach creates no #{klass}" unless Object::ISA[klass.isa].equal?(klass)
|
|
157
|
+
uuid = generate_uuid
|
|
158
|
+
attributes = { 'isa' => klass.isa }
|
|
159
|
+
klass.peach_defaults.each { |key, value| attributes[key] = value.dup }
|
|
160
|
+
@objects[uuid] = attributes
|
|
161
|
+
mark_dirty!
|
|
162
|
+
object(uuid)
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def generate_uuid
|
|
166
|
+
generate_available_uuid_list while @available_uuids.empty?
|
|
167
|
+
@available_uuids.shift
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Xcodeproj draws random ids; Peach derives them from the project and a counter
|
|
171
|
+
def generate_available_uuid_list(count = 100)
|
|
172
|
+
start = @generated_uuids.size
|
|
173
|
+
candidates = Array.new(count) { |i| Digest::SHA1.hexdigest("#{path.basename}/#{start + i}")[0, 24].upcase }
|
|
174
|
+
uniques = candidates - (@generated_uuids + uuids)
|
|
175
|
+
@generated_uuids += uniques
|
|
176
|
+
@available_uuids += uniques
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def mark_dirty!
|
|
180
|
+
@dirty = true
|
|
181
|
+
@referrers = nil
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def dirty?
|
|
185
|
+
@dirty
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def peach_referrers(uuid)
|
|
189
|
+
unless @referrers
|
|
190
|
+
@referrers = {}
|
|
191
|
+
@objects.each do |owner, attributes|
|
|
192
|
+
attributes.each do |key, value|
|
|
193
|
+
next if PEACH_PLAIN_KEYS.include?(key)
|
|
194
|
+
refs = value.is_a?(Array) ? value : [value]
|
|
195
|
+
refs.each { |ref| (@referrers[ref] ||= []) << owner if ref.is_a?(String) && @objects.key?(ref) }
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
(@referrers[uuid] || []).uniq.map { |owner| object(owner) }
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def peach_remove(uuid)
|
|
203
|
+
@objects.each_value do |attributes|
|
|
204
|
+
attributes.keys.each do |key|
|
|
205
|
+
next if PEACH_PLAIN_KEYS.include?(key)
|
|
206
|
+
value = attributes[key]
|
|
207
|
+
if value == uuid
|
|
208
|
+
attributes.delete(key)
|
|
209
|
+
elsif value.is_a?(Array)
|
|
210
|
+
value.delete(uuid)
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
@objects.delete(uuid)
|
|
215
|
+
@wrapped.delete(uuid)
|
|
216
|
+
mark_dirty!
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# the objects table after Peach's TypeScript integrator changed it
|
|
220
|
+
def peach_reload(objects)
|
|
221
|
+
@objects.keys.each do |uuid|
|
|
222
|
+
next if objects.key?(uuid)
|
|
223
|
+
@objects.delete(uuid)
|
|
224
|
+
@wrapped.delete(uuid)
|
|
225
|
+
end
|
|
226
|
+
objects.each do |uuid, attributes|
|
|
227
|
+
current = @objects[uuid]
|
|
228
|
+
if current
|
|
229
|
+
current.keys.each { |key| current.delete(key) unless attributes.key?(key) }
|
|
230
|
+
attributes.each { |key, value| current[key] = value unless current[key] == value }
|
|
231
|
+
else
|
|
232
|
+
@objects[uuid] = attributes
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
mark_dirty!
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def project_dir
|
|
239
|
+
path.dirname
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
def main_group
|
|
243
|
+
root_object.main_group
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
def [](group_name)
|
|
247
|
+
main_group[group_name]
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def targets
|
|
251
|
+
root_object.targets
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def native_targets
|
|
255
|
+
targets.select { |o| o.is_a?(Object::PBXNativeTarget) }
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def build_configuration_list
|
|
259
|
+
root_object.build_configuration_list
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def build_configurations
|
|
263
|
+
root_object.build_configuration_list.build_configurations
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def build_settings(name)
|
|
267
|
+
root_object.build_configuration_list.build_settings(name)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def files
|
|
271
|
+
objects.select { |o| o.is_a?(Object::PBXFileReference) }
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
def groups
|
|
275
|
+
main_group.groups
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def products_group
|
|
279
|
+
root_object.product_ref_group
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
def frameworks_group
|
|
283
|
+
main_group['Frameworks'] || main_group.new_group('Frameworks')
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# the tables stay in memory, where Peach reads them
|
|
287
|
+
def save(save_path = nil)
|
|
288
|
+
raise ArgumentError, "Peach saves #{path} only in place" if save_path
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
# Xcodeproj's to-many attribute: a live list of the uuids in the owner's table entry
|
|
292
|
+
class ObjectList
|
|
293
|
+
include Enumerable
|
|
294
|
+
attr_reader :owner
|
|
295
|
+
|
|
296
|
+
def initialize(owner, key)
|
|
297
|
+
@owner = owner
|
|
298
|
+
@key = key
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
def uuids
|
|
302
|
+
@owner.peach_uuids(@key).dup
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
def objects
|
|
306
|
+
@owner.peach_uuids(@key).map { |uuid| @owner.project.object(uuid) }
|
|
307
|
+
end
|
|
308
|
+
alias_method :to_a, :objects
|
|
309
|
+
alias_method :to_ary, :objects
|
|
310
|
+
|
|
311
|
+
def each(&block)
|
|
312
|
+
objects.each(&block)
|
|
313
|
+
self
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def size
|
|
317
|
+
@owner.peach_uuids(@key).size
|
|
318
|
+
end
|
|
319
|
+
alias_method :length, :size
|
|
320
|
+
|
|
321
|
+
def empty?
|
|
322
|
+
size.zero?
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
def [](index)
|
|
326
|
+
objects[index]
|
|
327
|
+
end
|
|
328
|
+
alias_method :at, :[]
|
|
329
|
+
|
|
330
|
+
def first
|
|
331
|
+
objects.first
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def last
|
|
335
|
+
objects.last
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def index(object = nil, &block)
|
|
339
|
+
block ? objects.index(&block) : objects.index(object)
|
|
340
|
+
end
|
|
341
|
+
alias_method :find_index, :index
|
|
342
|
+
|
|
343
|
+
def include?(object)
|
|
344
|
+
objects.include?(object)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def ==(other)
|
|
348
|
+
objects == (other.is_a?(ObjectList) ? other.objects : other)
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
def inspect
|
|
352
|
+
objects.inspect
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
def <<(object)
|
|
356
|
+
live << peach_uuid(object)
|
|
357
|
+
self
|
|
358
|
+
end
|
|
359
|
+
alias_method :push, :<<
|
|
360
|
+
|
|
361
|
+
def concat(list)
|
|
362
|
+
list.each { |object| self << object }
|
|
363
|
+
self
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
def insert(index, object)
|
|
367
|
+
live.insert(index, peach_uuid(object))
|
|
368
|
+
self
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def unshift(object)
|
|
372
|
+
live.unshift(peach_uuid(object))
|
|
373
|
+
self
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
def delete(object)
|
|
377
|
+
return nil unless object.is_a?(Object::AbstractObject) && live.include?(object.uuid)
|
|
378
|
+
live.delete(object.uuid)
|
|
379
|
+
@owner.project.mark_dirty!
|
|
380
|
+
object
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def delete_at(index)
|
|
384
|
+
uuid = live.delete_at(index)
|
|
385
|
+
@owner.project.mark_dirty!
|
|
386
|
+
uuid && @owner.project.object(uuid)
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def delete_if(&block)
|
|
390
|
+
live.reject! { |uuid| block.call(@owner.project.object(uuid)) }
|
|
391
|
+
@owner.project.mark_dirty!
|
|
392
|
+
self
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def clear
|
|
396
|
+
live.clear
|
|
397
|
+
@owner.project.mark_dirty!
|
|
398
|
+
self
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
def uniq!
|
|
402
|
+
result = live.uniq!
|
|
403
|
+
@owner.project.mark_dirty!
|
|
404
|
+
result && self
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def move(object, new_index)
|
|
408
|
+
return if index(object) == new_index
|
|
409
|
+
raise "Attempt to move object '#{object}' not present in the list '#{inspect}'" unless delete(object)
|
|
410
|
+
insert(new_index, object)
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
def move_from(current_index, new_index)
|
|
414
|
+
return if current_index == new_index
|
|
415
|
+
object = delete_at(current_index)
|
|
416
|
+
raise "Attempt to move object from index '#{current_index}' which is beyond bounds of the list '#{inspect}'" unless object
|
|
417
|
+
insert(new_index, object)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
private
|
|
421
|
+
|
|
422
|
+
def live
|
|
423
|
+
@owner.peach_live_uuids(@key)
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
def peach_uuid(object)
|
|
427
|
+
unless object.is_a?(Object::AbstractObject) && object.project.equal?(@owner.project)
|
|
428
|
+
raise ArgumentError, "#{@owner.inspect} lists objects of its own project, not #{object.inspect}"
|
|
429
|
+
end
|
|
430
|
+
@owner.project.mark_dirty!
|
|
431
|
+
object.uuid
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
module Object
|
|
436
|
+
class AbstractObject
|
|
437
|
+
attr_reader :project, :uuid
|
|
438
|
+
|
|
439
|
+
def self.isa
|
|
440
|
+
name.split('::').last
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def self.peach_defaults
|
|
444
|
+
inherited = equal?(AbstractObject) ? {} : superclass.peach_defaults
|
|
445
|
+
inherited.merge(@peach_defaults || {})
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
def initialize(project, uuid, attributes)
|
|
449
|
+
@project = project
|
|
450
|
+
@uuid = uuid
|
|
451
|
+
@attributes = attributes
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
def self.attribute(name, key, default = nil)
|
|
455
|
+
(@peach_defaults ||= {})[key] = default unless default.nil?
|
|
456
|
+
define_method(name) { @attributes[key] }
|
|
457
|
+
define_method("#{name}=") { |value| peach_set(key, value) }
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
def self.has_one(name, key)
|
|
461
|
+
define_method(name) { (uuid = @attributes[key]) && project.object(uuid) }
|
|
462
|
+
define_method("#{name}=") { |object| peach_set(key, object) }
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
def self.has_many(name, key)
|
|
466
|
+
(@peach_defaults ||= {})[key] = []
|
|
467
|
+
define_method(name) { Project::ObjectList.new(self, key) }
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def peach_uuid(key)
|
|
471
|
+
@attributes[key]
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
def peach_uuids(key)
|
|
475
|
+
@attributes[key] || []
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
def peach_live_uuids(key)
|
|
479
|
+
@attributes[key] ||= []
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
def peach_set(key, value)
|
|
483
|
+
value = value.uuid if value.is_a?(AbstractObject)
|
|
484
|
+
if value.nil?
|
|
485
|
+
@attributes.delete(key)
|
|
486
|
+
else
|
|
487
|
+
@attributes[key] = value
|
|
488
|
+
end
|
|
489
|
+
project.mark_dirty!
|
|
490
|
+
end
|
|
491
|
+
|
|
492
|
+
def isa
|
|
493
|
+
@attributes['isa']
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
def referrers
|
|
497
|
+
project.peach_referrers(uuid)
|
|
498
|
+
end
|
|
499
|
+
|
|
500
|
+
def mark_project_as_dirty!
|
|
501
|
+
project.mark_dirty!
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def remove_from_project
|
|
505
|
+
project.peach_remove(uuid)
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
def display_name
|
|
509
|
+
declared_name = name if respond_to?(:name)
|
|
510
|
+
declared_name && !declared_name.empty? ? declared_name : isa.gsub(/^(PBX|XC)/, '')
|
|
511
|
+
end
|
|
512
|
+
alias_method :to_s, :display_name
|
|
513
|
+
|
|
514
|
+
def inspect
|
|
515
|
+
"<#{isa} name=#{display_name.inspect} uuid=#{uuid}>"
|
|
516
|
+
end
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
module GroupableHelper
|
|
520
|
+
SOURCE_TREES_BY_KEY = {
|
|
521
|
+
:absolute => '<absolute>',
|
|
522
|
+
:group => '<group>',
|
|
523
|
+
:project => 'SOURCE_ROOT',
|
|
524
|
+
:built_products => 'BUILT_PRODUCTS_DIR',
|
|
525
|
+
:developer_dir => 'DEVELOPER_DIR',
|
|
526
|
+
:sdk_root => 'SDKROOT',
|
|
527
|
+
}.freeze
|
|
528
|
+
|
|
529
|
+
def self.normalize_source_tree(source_tree)
|
|
530
|
+
source_tree = SOURCE_TREES_BY_KEY[source_tree] if source_tree.is_a?(Symbol)
|
|
531
|
+
raise "[Xcodeproj] Unrecognized source tree option '#{source_tree}'" unless SOURCE_TREES_BY_KEY.values.include?(source_tree)
|
|
532
|
+
source_tree
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def parent
|
|
536
|
+
parents = referrers
|
|
537
|
+
parents = parents.select { |o| o.is_a?(PBXGroup) } if parents.count > 1
|
|
538
|
+
raise "[Xcodeproj] Consistency issue: no parent for object '#{display_name}'" if parents.empty?
|
|
539
|
+
raise "[Xcodeproj] Consistency issue: unexpected multiple parents for object '#{display_name}'" if parents.count > 1
|
|
540
|
+
parents.first
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
def real_path
|
|
544
|
+
source_tree_path = source_tree_real_path
|
|
545
|
+
source_tree_path ? source_tree_path + (path || '') : Pathname(path || '')
|
|
546
|
+
end
|
|
547
|
+
|
|
548
|
+
def source_tree_real_path
|
|
549
|
+
case source_tree
|
|
550
|
+
when '<group>'
|
|
551
|
+
object_parent = parent
|
|
552
|
+
if object_parent.isa == 'PBXProject'
|
|
553
|
+
project.project_dir + project.root_object.project_dir_path
|
|
554
|
+
else
|
|
555
|
+
object_parent.real_path
|
|
556
|
+
end
|
|
557
|
+
when 'SOURCE_ROOT'
|
|
558
|
+
project.project_dir
|
|
559
|
+
when '<absolute>'
|
|
560
|
+
nil
|
|
561
|
+
else
|
|
562
|
+
Pathname.new("$" + "{#{source_tree}}")
|
|
563
|
+
end
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
def set_source_tree(source_tree)
|
|
567
|
+
self.source_tree = GroupableHelper.normalize_source_tree(source_tree)
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
def peach_set_path_with_source_tree(new_path, source_tree)
|
|
571
|
+
new_path = Pathname.new(new_path.to_s)
|
|
572
|
+
source_tree = GroupableHelper.normalize_source_tree(source_tree)
|
|
573
|
+
self.source_tree = source_tree
|
|
574
|
+
if source_tree == '<absolute>'
|
|
575
|
+
raise "[Xcodeproj] Attempt to set a relative path with an absolute source tree: '#{new_path}'" unless new_path.absolute?
|
|
576
|
+
self.path = new_path.to_s
|
|
577
|
+
elsif source_tree == '<group>' || source_tree == 'SOURCE_ROOT'
|
|
578
|
+
tree_path = source_tree_real_path
|
|
579
|
+
self.path = tree_path && tree_path.absolute? == new_path.absolute? ? new_path.relative_path_from(tree_path).to_s : new_path.to_s
|
|
580
|
+
else
|
|
581
|
+
self.path = new_path.to_s
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
def build_files
|
|
586
|
+
referrers.select { |o| o.is_a?(PBXBuildFile) }
|
|
587
|
+
end
|
|
588
|
+
|
|
589
|
+
def remove_from_project
|
|
590
|
+
build_files.each(&:remove_from_project)
|
|
591
|
+
super
|
|
592
|
+
end
|
|
593
|
+
end
|
|
594
|
+
class XCBuildConfiguration < AbstractObject
|
|
595
|
+
MUTUAL_RECURSION_SENTINEL = 'xcodeproj.mutual_recursion_sentinel'.freeze
|
|
596
|
+
ARRAY_SETTINGS = %w(
|
|
597
|
+
ALTERNATE_PERMISSIONS_FILES ARCHS BUILD_VARIANTS EXCLUDED_SOURCE_FILE_NAMES FRAMEWORK_SEARCH_PATHS
|
|
598
|
+
GCC_PREPROCESSOR_DEFINITIONS GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS HEADER_SEARCH_PATHS
|
|
599
|
+
INFOPLIST_PREPROCESSOR_DEFINITIONS LIBRARY_SEARCH_PATHS OTHER_CFLAGS OTHER_CPLUSPLUSFLAGS OTHER_LDFLAGS
|
|
600
|
+
REZ_SEARCH_PATHS SECTORDER_FLAGS WARNING_CFLAGS WARNING_LDFLAGS
|
|
601
|
+
).freeze
|
|
602
|
+
ARRAY_SETTINGS_OBJECT_VERSION_50 = %w(
|
|
603
|
+
ALTERNATE_PERMISSIONS_FILES ARCHS BUILD_VARIANTS EXCLUDED_SOURCE_FILE_NAMES FRAMEWORK_SEARCH_PATHS
|
|
604
|
+
GCC_PREPROCESSOR_DEFINITIONS GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS HEADER_SEARCH_PATHS
|
|
605
|
+
INCLUDED_SOURCE_FILE_NAMES INFOPLIST_PREPROCESSOR_DEFINITIONS LD_RUNPATH_SEARCH_PATHS LIBRARY_SEARCH_PATHS
|
|
606
|
+
LOCALIZED_STRING_MACRO_NAMES OTHER_CFLAGS OTHER_CPLUSPLUSFLAGS OTHER_LDFLAGS REZ_SEARCH_PATHS SECTORDER_FLAGS
|
|
607
|
+
SYSTEM_FRAMEWORK_SEARCH_PATHS SYSTEM_HEADER_SEARCH_PATHS USER_HEADER_SEARCH_PATHS WARNING_CFLAGS WARNING_LDFLAGS
|
|
608
|
+
).freeze
|
|
609
|
+
|
|
610
|
+
attribute :name, 'name'
|
|
611
|
+
has_one :base_configuration_reference, 'baseConfigurationReference'
|
|
612
|
+
|
|
613
|
+
def build_settings
|
|
614
|
+
@attributes['buildSettings'] ||= {}
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
def build_settings=(settings)
|
|
618
|
+
peach_set('buildSettings', settings)
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
def debug?
|
|
622
|
+
gcc_preprocessor_definitions = resolve_build_setting('GCC_PREPROCESSOR_DEFINITIONS')
|
|
623
|
+
gcc_preprocessor_definitions && gcc_preprocessor_definitions.include?('DEBUG=1')
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
def type
|
|
627
|
+
debug? ? :debug : :release
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
def resolve_build_setting(key, root_target = nil, previous_key = nil)
|
|
631
|
+
setting = build_settings[key]
|
|
632
|
+
setting = resolve_variable_substitution(key, setting, root_target, previous_key)
|
|
633
|
+
|
|
634
|
+
config_setting = config[key]
|
|
635
|
+
config_setting = resolve_variable_substitution(key, config_setting, root_target, previous_key)
|
|
636
|
+
|
|
637
|
+
project_setting = project.build_configuration_list[name]
|
|
638
|
+
project_setting = nil if equal?(project_setting)
|
|
639
|
+
project_setting &&= project_setting.resolve_build_setting(key, root_target)
|
|
640
|
+
|
|
641
|
+
defaults = {
|
|
642
|
+
'CONFIGURATION' => name,
|
|
643
|
+
'SRCROOT' => project.project_dir.to_s,
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if previous_key.nil? && setting == MUTUAL_RECURSION_SENTINEL
|
|
647
|
+
setting = nil
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
[defaults[key], project_setting, config_setting, setting, ENV[key]].compact.reduce(nil) do |inherited, value|
|
|
651
|
+
expand_build_setting(value, inherited)
|
|
652
|
+
end
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
private
|
|
656
|
+
|
|
657
|
+
def expand_build_setting(build_setting_value, config_value)
|
|
658
|
+
if build_setting_value.is_a?(Array) && config_value.is_a?(String)
|
|
659
|
+
config_value = split_build_setting_array_to_string(config_value)
|
|
660
|
+
elsif build_setting_value.is_a?(String) && config_value.is_a?(Array)
|
|
661
|
+
build_setting_value = split_build_setting_array_to_string(build_setting_value)
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
default = build_setting_value.is_a?(String) ? '' : []
|
|
665
|
+
inherited = config_value || default
|
|
666
|
+
|
|
667
|
+
return build_setting_value.gsub(Regexp.union(Constants::INHERITED_KEYWORDS), inherited) if build_setting_value.is_a? String
|
|
668
|
+
build_setting_value.flat_map { |value| Constants::INHERITED_KEYWORDS.include?(value) ? inherited : value }
|
|
669
|
+
end
|
|
670
|
+
|
|
671
|
+
def resolve_variable_substitution(key, value, root_target, previous_key = nil)
|
|
672
|
+
case value
|
|
673
|
+
when Array
|
|
674
|
+
return value.map { |v| resolve_variable_substitution(key, v, root_target) }
|
|
675
|
+
when nil
|
|
676
|
+
return
|
|
677
|
+
when String
|
|
678
|
+
nil
|
|
679
|
+
else
|
|
680
|
+
raise ArgumentError, "Settings values can only be nil, string, or array, got #{value.inspect} for #{key}"
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
unless variable_match_data = value.match(/\$(?:[{]([_a-zA-Z0-9]+?)[}]|[(]([_a-zA-Z0-9]+?)[)])/)
|
|
684
|
+
return value
|
|
685
|
+
end
|
|
686
|
+
variable_reference = variable_match_data[0]
|
|
687
|
+
variable = variable_match_data[1] || variable_match_data[2]
|
|
688
|
+
|
|
689
|
+
case variable
|
|
690
|
+
when 'inherited'
|
|
691
|
+
value
|
|
692
|
+
when key
|
|
693
|
+
nil
|
|
694
|
+
when previous_key
|
|
695
|
+
MUTUAL_RECURSION_SENTINEL
|
|
696
|
+
else
|
|
697
|
+
configuration_to_resolve_against = root_target ? root_target.build_configuration_list[name] : self
|
|
698
|
+
resolved_value_for_variable = configuration_to_resolve_against.resolve_build_setting(variable, root_target, key) || ''
|
|
699
|
+
|
|
700
|
+
if resolved_value_for_variable == MUTUAL_RECURSION_SENTINEL
|
|
701
|
+
return MUTUAL_RECURSION_SENTINEL
|
|
702
|
+
end
|
|
703
|
+
|
|
704
|
+
value = value.gsub(variable_reference, resolved_value_for_variable)
|
|
705
|
+
resolve_variable_substitution(key, value, root_target)
|
|
706
|
+
end
|
|
707
|
+
end
|
|
708
|
+
|
|
709
|
+
def normalize_array_settings(settings)
|
|
710
|
+
return unless settings
|
|
711
|
+
|
|
712
|
+
array_settings = project.object_version.to_i >= 50 ? ARRAY_SETTINGS_OBJECT_VERSION_50 : ARRAY_SETTINGS
|
|
713
|
+
|
|
714
|
+
settings.keys.each do |key|
|
|
715
|
+
next unless value = settings[key]
|
|
716
|
+
stripped_key = key.sub(/\[[^\]]+\]$/, '')
|
|
717
|
+
case value
|
|
718
|
+
when String
|
|
719
|
+
next unless array_settings.include?(stripped_key)
|
|
720
|
+
array_value = split_build_setting_array_to_string(value)
|
|
721
|
+
next unless array_value.size > 1
|
|
722
|
+
settings[key] = array_value
|
|
723
|
+
when Array
|
|
724
|
+
next if value.size > 1 && array_settings.include?(stripped_key)
|
|
725
|
+
settings[key] = value.join(' ')
|
|
726
|
+
end
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
def split_build_setting_array_to_string(string)
|
|
731
|
+
regexp = / *((['"]?).*?[^\\]\2)(?=( |\z))/
|
|
732
|
+
string.scan(regexp).map(&:first)
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
def config
|
|
736
|
+
return {} unless base_configuration_reference
|
|
737
|
+
# integration sets the reference after hooks have read the settings
|
|
738
|
+
@config = nil unless @config_reference == peach_uuid('baseConfigurationReference')
|
|
739
|
+
@config_reference = peach_uuid('baseConfigurationReference')
|
|
740
|
+
@config ||=
|
|
741
|
+
if base_configuration_reference.real_path.exist?
|
|
742
|
+
Xcodeproj::Config.new(base_configuration_reference.real_path).to_hash.tap do |hash|
|
|
743
|
+
normalize_array_settings(hash)
|
|
744
|
+
end
|
|
745
|
+
else
|
|
746
|
+
{}
|
|
747
|
+
end
|
|
748
|
+
end
|
|
749
|
+
end
|
|
750
|
+
|
|
751
|
+
class XCConfigurationList < AbstractObject
|
|
752
|
+
attribute :default_configuration_is_visible, 'defaultConfigurationIsVisible', '0'
|
|
753
|
+
attribute :default_configuration_name, 'defaultConfigurationName'
|
|
754
|
+
has_many :build_configurations, 'buildConfigurations'
|
|
755
|
+
|
|
756
|
+
def [](name)
|
|
757
|
+
build_configurations.find { |bc| bc.name == name }
|
|
758
|
+
end
|
|
759
|
+
|
|
760
|
+
def build_settings(build_configuration_name)
|
|
761
|
+
configuration = self[build_configuration_name]
|
|
762
|
+
configuration && configuration.build_settings
|
|
763
|
+
end
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
class PBXBuildFile < AbstractObject
|
|
767
|
+
attribute :settings, 'settings'
|
|
768
|
+
has_one :file_ref, 'fileRef'
|
|
769
|
+
has_one :product_ref, 'productRef'
|
|
770
|
+
|
|
771
|
+
def display_name
|
|
772
|
+
if product_ref
|
|
773
|
+
product_ref.display_name
|
|
774
|
+
elsif file_ref
|
|
775
|
+
file_ref.display_name
|
|
776
|
+
else
|
|
777
|
+
super
|
|
778
|
+
end
|
|
779
|
+
end
|
|
780
|
+
end
|
|
781
|
+
|
|
782
|
+
class AbstractBuildPhase < AbstractObject
|
|
783
|
+
has_many :files, 'files'
|
|
784
|
+
attribute :build_action_mask, 'buildActionMask', '2147483647'
|
|
785
|
+
attribute :run_only_for_deployment_postprocessing, 'runOnlyForDeploymentPostprocessing', '0'
|
|
786
|
+
attribute :always_out_of_date, 'alwaysOutOfDate'
|
|
787
|
+
|
|
788
|
+
def files_references
|
|
789
|
+
files.map(&:file_ref)
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
def file_display_names
|
|
793
|
+
files.map(&:display_name)
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
def build_file(file_ref)
|
|
797
|
+
files.find { |build_file| build_file.peach_uuid('fileRef') == file_ref.uuid }
|
|
798
|
+
end
|
|
799
|
+
|
|
800
|
+
def include?(file_ref)
|
|
801
|
+
!build_file(file_ref).nil?
|
|
802
|
+
end
|
|
803
|
+
|
|
804
|
+
def add_file_reference(file_ref, avoid_duplicates = false)
|
|
805
|
+
existing = avoid_duplicates && build_file(file_ref)
|
|
806
|
+
return existing if existing
|
|
807
|
+
build_file = project.new(PBXBuildFile)
|
|
808
|
+
build_file.file_ref = file_ref
|
|
809
|
+
files << build_file
|
|
810
|
+
build_file
|
|
811
|
+
end
|
|
812
|
+
|
|
813
|
+
def remove_file_reference(file_ref)
|
|
814
|
+
build_file = files.find { |bf| bf.file_ref == file_ref }
|
|
815
|
+
remove_build_file(build_file) if build_file
|
|
816
|
+
end
|
|
817
|
+
|
|
818
|
+
def remove_build_file(build_file)
|
|
819
|
+
build_file.file_ref = nil
|
|
820
|
+
build_file.remove_from_project
|
|
821
|
+
end
|
|
822
|
+
|
|
823
|
+
def clear
|
|
824
|
+
files.objects.each { |bf| remove_build_file(bf) }
|
|
825
|
+
end
|
|
826
|
+
alias_method :clear_build_files, :clear
|
|
827
|
+
|
|
828
|
+
def display_name
|
|
829
|
+
super.gsub(/BuildPhase$/, '')
|
|
830
|
+
end
|
|
831
|
+
end
|
|
832
|
+
|
|
833
|
+
class PBXHeadersBuildPhase < AbstractBuildPhase; end
|
|
834
|
+
class PBXSourcesBuildPhase < AbstractBuildPhase; end
|
|
835
|
+
class PBXFrameworksBuildPhase < AbstractBuildPhase; end
|
|
836
|
+
class PBXResourcesBuildPhase < AbstractBuildPhase; end
|
|
837
|
+
|
|
838
|
+
class PBXCopyFilesBuildPhase < AbstractBuildPhase
|
|
839
|
+
attribute :name, 'name'
|
|
840
|
+
attribute :dst_path, 'dstPath', ''
|
|
841
|
+
attribute :dst_subfolder_spec, 'dstSubfolderSpec', '7'
|
|
842
|
+
end
|
|
843
|
+
|
|
844
|
+
class PBXShellScriptBuildPhase < AbstractBuildPhase
|
|
845
|
+
attribute :name, 'name'
|
|
846
|
+
attribute :input_paths, 'inputPaths', []
|
|
847
|
+
attribute :input_file_list_paths, 'inputFileListPaths', []
|
|
848
|
+
attribute :output_paths, 'outputPaths', []
|
|
849
|
+
attribute :output_file_list_paths, 'outputFileListPaths', []
|
|
850
|
+
attribute :shell_path, 'shellPath', '/bin/sh'
|
|
851
|
+
attribute :shell_script, 'shellScript', "# Type a script or drag a script file from your workspace to insert its path.\n"
|
|
852
|
+
attribute :show_env_vars_in_log, 'showEnvVarsInLog'
|
|
853
|
+
attribute :dependency_file, 'dependencyFile'
|
|
854
|
+
end
|
|
855
|
+
|
|
856
|
+
class PBXFileReference < AbstractObject
|
|
857
|
+
include GroupableHelper
|
|
858
|
+
attribute :name, 'name'
|
|
859
|
+
attribute :path, 'path'
|
|
860
|
+
attribute :source_tree, 'sourceTree', 'SOURCE_ROOT'
|
|
861
|
+
attribute :explicit_file_type, 'explicitFileType'
|
|
862
|
+
attribute :last_known_file_type, 'lastKnownFileType'
|
|
863
|
+
attribute :include_in_index, 'includeInIndex', '1'
|
|
864
|
+
attribute :fileEncoding, 'fileEncoding'
|
|
865
|
+
|
|
866
|
+
def display_name
|
|
867
|
+
if name
|
|
868
|
+
name
|
|
869
|
+
elsif source_tree == 'BUILT_PRODUCTS_DIR'
|
|
870
|
+
path
|
|
871
|
+
elsif path
|
|
872
|
+
File.basename(path)
|
|
873
|
+
end
|
|
874
|
+
end
|
|
875
|
+
|
|
876
|
+
def set_path(new_path)
|
|
877
|
+
if new_path
|
|
878
|
+
peach_set_path_with_source_tree(new_path, source_tree)
|
|
879
|
+
else
|
|
880
|
+
self.path = nil
|
|
881
|
+
end
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
def set_last_known_file_type(type = nil)
|
|
885
|
+
if type
|
|
886
|
+
self.last_known_file_type = type
|
|
887
|
+
elsif path
|
|
888
|
+
self.last_known_file_type = Peach::Xcode.file_type(File.extname(path)[1..-1].to_s)
|
|
889
|
+
end
|
|
890
|
+
end
|
|
891
|
+
|
|
892
|
+
def set_explicit_file_type(type = nil)
|
|
893
|
+
self.last_known_file_type = nil
|
|
894
|
+
if type
|
|
895
|
+
self.explicit_file_type = type
|
|
896
|
+
elsif path
|
|
897
|
+
self.explicit_file_type = Peach::Xcode.file_type(File.extname(path)[1..-1].to_s)
|
|
898
|
+
end
|
|
899
|
+
end
|
|
900
|
+
end
|
|
901
|
+
|
|
902
|
+
class PBXReferenceProxy < AbstractObject
|
|
903
|
+
include GroupableHelper
|
|
904
|
+
attribute :name, 'name'
|
|
905
|
+
attribute :path, 'path'
|
|
906
|
+
attribute :file_type, 'fileType'
|
|
907
|
+
attribute :source_tree, 'sourceTree'
|
|
908
|
+
has_one :remote_ref, 'remoteRef'
|
|
909
|
+
end
|
|
910
|
+
|
|
911
|
+
class PBXGroup < AbstractObject
|
|
912
|
+
include GroupableHelper
|
|
913
|
+
has_many :children, 'children'
|
|
914
|
+
attribute :source_tree, 'sourceTree', '<group>'
|
|
915
|
+
attribute :path, 'path'
|
|
916
|
+
attribute :name, 'name'
|
|
917
|
+
|
|
918
|
+
def display_name
|
|
919
|
+
if name
|
|
920
|
+
name
|
|
921
|
+
elsif path
|
|
922
|
+
File.basename(path)
|
|
923
|
+
elsif equal?(project.main_group)
|
|
924
|
+
'Main Group'
|
|
925
|
+
end
|
|
926
|
+
end
|
|
927
|
+
|
|
928
|
+
def set_path(new_path)
|
|
929
|
+
if new_path
|
|
930
|
+
peach_set_path_with_source_tree(new_path, source_tree)
|
|
931
|
+
else
|
|
932
|
+
self.path = nil
|
|
933
|
+
self.source_tree = '<group>'
|
|
934
|
+
end
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
def files
|
|
938
|
+
children.select { |o| o.is_a?(PBXFileReference) }
|
|
939
|
+
end
|
|
940
|
+
|
|
941
|
+
def find_file_by_path(file_path)
|
|
942
|
+
files.find { |ref| ref.path == file_path }
|
|
943
|
+
end
|
|
944
|
+
|
|
945
|
+
def groups
|
|
946
|
+
children.select { |o| o.instance_of?(PBXGroup) }
|
|
947
|
+
end
|
|
948
|
+
|
|
949
|
+
def recursive_children_groups
|
|
950
|
+
groups.flat_map { |child| [child] + child.recursive_children_groups }
|
|
951
|
+
end
|
|
952
|
+
|
|
953
|
+
def recursive_children
|
|
954
|
+
children.flat_map { |child| child.is_a?(PBXGroup) ? [child] + child.recursive_children : [child] }
|
|
955
|
+
end
|
|
956
|
+
|
|
957
|
+
def empty?
|
|
958
|
+
children.count.zero?
|
|
959
|
+
end
|
|
960
|
+
|
|
961
|
+
# FileReferencesFactory.new_reference for a plain file
|
|
962
|
+
def new_reference(file_path, source_tree = :group)
|
|
963
|
+
extension = File.extname(file_path.to_s).downcase
|
|
964
|
+
raise ArgumentError, "Peach adds no #{extension} reference (#{file_path})" if %w(.xcdatamodeld .xcodeproj).include?(extension)
|
|
965
|
+
ref = project.new(PBXFileReference)
|
|
966
|
+
children << ref
|
|
967
|
+
ref.peach_set_path_with_source_tree(file_path, source_tree)
|
|
968
|
+
ref.set_last_known_file_type
|
|
969
|
+
ref.name = ref.path.split('/').last if ref.path.include?('/')
|
|
970
|
+
ref.include_in_index = nil if File.extname(ref.path).downcase == '.framework'
|
|
971
|
+
ref
|
|
972
|
+
end
|
|
973
|
+
alias_method :new_file, :new_reference
|
|
974
|
+
|
|
975
|
+
def new_product_ref_for_target(product_basename, product_type)
|
|
976
|
+
extension = Peach::Xcode.product_extension(product_type.to_s)
|
|
977
|
+
product_path = "#{product_type == :static_library ? 'lib' : ''}#{product_basename}"
|
|
978
|
+
product_path += ".#{extension}" if extension
|
|
979
|
+
ref = new_reference(product_path, :built_products)
|
|
980
|
+
ref.include_in_index = '0'
|
|
981
|
+
ref.set_explicit_file_type
|
|
982
|
+
ref
|
|
983
|
+
end
|
|
984
|
+
|
|
985
|
+
def new_group(name, group_path = nil, source_tree = :group)
|
|
986
|
+
group = project.new(PBXGroup)
|
|
987
|
+
children << group
|
|
988
|
+
group.name = name
|
|
989
|
+
group.set_source_tree(source_tree)
|
|
990
|
+
group.set_path(group_path)
|
|
991
|
+
group
|
|
992
|
+
end
|
|
993
|
+
|
|
994
|
+
def [](group_path)
|
|
995
|
+
find_subpath(group_path, false)
|
|
996
|
+
end
|
|
997
|
+
|
|
998
|
+
def <<(child)
|
|
999
|
+
children << child
|
|
1000
|
+
end
|
|
1001
|
+
|
|
1002
|
+
def find_subpath(group_path, should_create = false)
|
|
1003
|
+
return self unless group_path
|
|
1004
|
+
group_path = group_path.split('/') unless group_path.is_a?(Array)
|
|
1005
|
+
child_name = group_path.first
|
|
1006
|
+
rest = group_path.drop(1)
|
|
1007
|
+
child = children.find { |c| c.display_name == child_name }
|
|
1008
|
+
if child.nil?
|
|
1009
|
+
return nil unless should_create
|
|
1010
|
+
child = new_group(child_name)
|
|
1011
|
+
end
|
|
1012
|
+
rest.empty? ? child : child.find_subpath(rest, should_create)
|
|
1013
|
+
end
|
|
1014
|
+
end
|
|
1015
|
+
|
|
1016
|
+
class PBXVariantGroup < PBXGroup
|
|
1017
|
+
attribute :last_known_file_type, 'lastKnownFileType'
|
|
1018
|
+
end
|
|
1019
|
+
|
|
1020
|
+
class XCVersionGroup < PBXGroup
|
|
1021
|
+
attribute :version_group_type, 'versionGroupType', 'wrapper.xcdatamodel'
|
|
1022
|
+
end
|
|
1023
|
+
|
|
1024
|
+
class PBXContainerItemProxy < AbstractObject
|
|
1025
|
+
attribute :container_portal, 'containerPortal'
|
|
1026
|
+
attribute :proxy_type, 'proxyType'
|
|
1027
|
+
attribute :remote_global_id_string, 'remoteGlobalIDString'
|
|
1028
|
+
attribute :remote_info, 'remoteInfo'
|
|
1029
|
+
end
|
|
1030
|
+
|
|
1031
|
+
class PBXTargetDependency < AbstractObject
|
|
1032
|
+
has_one :target, 'target'
|
|
1033
|
+
has_one :target_proxy, 'targetProxy'
|
|
1034
|
+
has_one :product_ref, 'productRef'
|
|
1035
|
+
attribute :name, 'name'
|
|
1036
|
+
|
|
1037
|
+
def display_name
|
|
1038
|
+
return name if name
|
|
1039
|
+
return target.name if target
|
|
1040
|
+
return target_proxy.remote_info if target_proxy
|
|
1041
|
+
return product_ref.product_name if product_ref
|
|
1042
|
+
end
|
|
1043
|
+
end
|
|
1044
|
+
|
|
1045
|
+
class XCSwiftPackageProductDependency < AbstractObject
|
|
1046
|
+
has_one :package, 'package'
|
|
1047
|
+
attribute :product_name, 'productName'
|
|
1048
|
+
|
|
1049
|
+
def display_name
|
|
1050
|
+
product_name || super
|
|
1051
|
+
end
|
|
1052
|
+
end
|
|
1053
|
+
|
|
1054
|
+
class XCRemoteSwiftPackageReference < AbstractObject
|
|
1055
|
+
attribute :repositoryURL, 'repositoryURL'
|
|
1056
|
+
attribute :requirement, 'requirement'
|
|
1057
|
+
|
|
1058
|
+
def display_name
|
|
1059
|
+
repositoryURL || super
|
|
1060
|
+
end
|
|
1061
|
+
end
|
|
1062
|
+
|
|
1063
|
+
class XCLocalSwiftPackageReference < AbstractObject
|
|
1064
|
+
attribute :path, 'path'
|
|
1065
|
+
attribute :relative_path, 'relativePath'
|
|
1066
|
+
end
|
|
1067
|
+
|
|
1068
|
+
class AbstractTarget < AbstractObject
|
|
1069
|
+
attribute :name, 'name'
|
|
1070
|
+
attribute :product_name, 'productName'
|
|
1071
|
+
has_one :build_configuration_list, 'buildConfigurationList'
|
|
1072
|
+
has_many :dependencies, 'dependencies'
|
|
1073
|
+
has_many :build_phases, 'buildPhases'
|
|
1074
|
+
|
|
1075
|
+
def build_configurations
|
|
1076
|
+
build_configuration_list.build_configurations
|
|
1077
|
+
end
|
|
1078
|
+
|
|
1079
|
+
def build_settings(build_configuration_name)
|
|
1080
|
+
build_configuration_list.build_settings(build_configuration_name)
|
|
1081
|
+
end
|
|
1082
|
+
|
|
1083
|
+
def common_resolved_build_setting(key)
|
|
1084
|
+
values = build_configurations.map { |config| config.resolve_build_setting(key, self) }.compact.uniq
|
|
1085
|
+
values.first if values.count <= 1
|
|
1086
|
+
end
|
|
1087
|
+
|
|
1088
|
+
def dependency_for_target(target)
|
|
1089
|
+
dependencies.find { |dep| dep.target ? dep.target.uuid == target.uuid : dep.target_proxy && dep.target_proxy.remote_global_id_string == target.uuid }
|
|
1090
|
+
end
|
|
1091
|
+
|
|
1092
|
+
def shell_script_build_phases
|
|
1093
|
+
build_phases.select { |o| o.is_a?(PBXShellScriptBuildPhase) }
|
|
1094
|
+
end
|
|
1095
|
+
|
|
1096
|
+
def copy_files_build_phases
|
|
1097
|
+
build_phases.select { |o| o.is_a?(PBXCopyFilesBuildPhase) }
|
|
1098
|
+
end
|
|
1099
|
+
|
|
1100
|
+
def new_shell_script_build_phase(name = nil)
|
|
1101
|
+
phase = project.new(PBXShellScriptBuildPhase)
|
|
1102
|
+
phase.name = name
|
|
1103
|
+
build_phases << phase
|
|
1104
|
+
phase
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
def new_copy_files_build_phase(name = nil)
|
|
1108
|
+
phase = project.new(PBXCopyFilesBuildPhase)
|
|
1109
|
+
phase.name = name
|
|
1110
|
+
build_phases << phase
|
|
1111
|
+
phase
|
|
1112
|
+
end
|
|
1113
|
+
end
|
|
1114
|
+
|
|
1115
|
+
class PBXNativeTarget < AbstractTarget
|
|
1116
|
+
attribute :product_type, 'productType'
|
|
1117
|
+
attribute :product_install_path, 'productInstallPath'
|
|
1118
|
+
has_one :product_reference, 'productReference'
|
|
1119
|
+
has_many :package_product_dependencies, 'packageProductDependencies'
|
|
1120
|
+
|
|
1121
|
+
def symbol_type
|
|
1122
|
+
Constants::PRODUCT_TYPE_UTI.key(product_type)
|
|
1123
|
+
end
|
|
1124
|
+
|
|
1125
|
+
def test_target_type?
|
|
1126
|
+
%i(octest_bundle unit_test_bundle ui_test_bundle).include?(symbol_type)
|
|
1127
|
+
end
|
|
1128
|
+
|
|
1129
|
+
def extension_target_type?
|
|
1130
|
+
%i(app_extension watch_extension watch2_extension tv_extension messages_extension).include?(symbol_type)
|
|
1131
|
+
end
|
|
1132
|
+
|
|
1133
|
+
def launchable_target_type?
|
|
1134
|
+
%i(application command_line_tool).include?(symbol_type)
|
|
1135
|
+
end
|
|
1136
|
+
|
|
1137
|
+
def source_build_phase
|
|
1138
|
+
peach_phase(PBXSourcesBuildPhase)
|
|
1139
|
+
end
|
|
1140
|
+
|
|
1141
|
+
def headers_build_phase
|
|
1142
|
+
peach_phase(PBXHeadersBuildPhase)
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
def frameworks_build_phase
|
|
1146
|
+
peach_phase(PBXFrameworksBuildPhase)
|
|
1147
|
+
end
|
|
1148
|
+
|
|
1149
|
+
def resources_build_phase
|
|
1150
|
+
peach_phase(PBXResourcesBuildPhase)
|
|
1151
|
+
end
|
|
1152
|
+
|
|
1153
|
+
def add_file_references(file_references, compiler_flags = {})
|
|
1154
|
+
file_references.map do |file|
|
|
1155
|
+
header = Peach::Xcode.header?(file.path)
|
|
1156
|
+
phase = header ? headers_build_phase : source_build_phase
|
|
1157
|
+
build_file = phase.build_file(file) || phase.add_file_reference(file)
|
|
1158
|
+
if compiler_flags && !compiler_flags.empty? && !header
|
|
1159
|
+
settings = build_file.settings || {}
|
|
1160
|
+
settings['COMPILER_FLAGS'] = [settings['COMPILER_FLAGS'], compiler_flags].compact.join(' ')
|
|
1161
|
+
build_file.settings = settings
|
|
1162
|
+
end
|
|
1163
|
+
yield build_file if block_given?
|
|
1164
|
+
build_file
|
|
1165
|
+
end
|
|
1166
|
+
end
|
|
1167
|
+
|
|
1168
|
+
def add_resources(resource_file_references)
|
|
1169
|
+
resource_file_references.each do |file|
|
|
1170
|
+
resources_build_phase.add_file_reference(file) unless resources_build_phase.include?(file)
|
|
1171
|
+
end
|
|
1172
|
+
end
|
|
1173
|
+
|
|
1174
|
+
private
|
|
1175
|
+
|
|
1176
|
+
def peach_phase(klass)
|
|
1177
|
+
build_phases.find { |phase| phase.instance_of?(klass) } || project.new(klass).tap { |phase| build_phases << phase }
|
|
1178
|
+
end
|
|
1179
|
+
end
|
|
1180
|
+
|
|
1181
|
+
class PBXAggregateTarget < AbstractTarget; end
|
|
1182
|
+
class PBXLegacyTarget < AbstractTarget; end
|
|
1183
|
+
|
|
1184
|
+
class PBXProject < AbstractObject
|
|
1185
|
+
has_many :targets, 'targets'
|
|
1186
|
+
attribute :attributes, 'attributes'
|
|
1187
|
+
has_one :build_configuration_list, 'buildConfigurationList'
|
|
1188
|
+
attribute :compatibility_version, 'compatibilityVersion'
|
|
1189
|
+
attribute :development_region, 'developmentRegion'
|
|
1190
|
+
attribute :known_regions, 'knownRegions'
|
|
1191
|
+
has_one :main_group, 'mainGroup'
|
|
1192
|
+
has_one :product_ref_group, 'productRefGroup'
|
|
1193
|
+
attribute :project_dir_path, 'projectDirPath', ''
|
|
1194
|
+
attribute :project_root, 'projectRoot', ''
|
|
1195
|
+
has_many :package_references, 'packageReferences'
|
|
1196
|
+
|
|
1197
|
+
def name
|
|
1198
|
+
project.path.basename('.xcodeproj').to_s
|
|
1199
|
+
end
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
ISA = [
|
|
1203
|
+
XCBuildConfiguration, XCConfigurationList, PBXBuildFile, PBXHeadersBuildPhase, PBXSourcesBuildPhase,
|
|
1204
|
+
PBXFrameworksBuildPhase, PBXResourcesBuildPhase, PBXCopyFilesBuildPhase, PBXShellScriptBuildPhase,
|
|
1205
|
+
PBXFileReference, PBXReferenceProxy, PBXGroup, PBXVariantGroup, XCVersionGroup, PBXContainerItemProxy,
|
|
1206
|
+
PBXTargetDependency, XCSwiftPackageProductDependency, XCRemoteSwiftPackageReference,
|
|
1207
|
+
XCLocalSwiftPackageReference, PBXNativeTarget, PBXAggregateTarget, PBXLegacyTarget, PBXProject,
|
|
1208
|
+
].each_with_object({}) { |klass, by_isa| by_isa[klass.isa] = klass }.freeze
|
|
1209
|
+
end
|
|
1210
|
+
|
|
1211
|
+
include Object
|
|
1212
|
+
end
|
|
1213
|
+
end
|
|
1214
|
+
|
|
1215
|
+
module Pod
|
|
1216
|
+
class Project < Xcodeproj::Project
|
|
1217
|
+
def initialize(path, objects, root_uuid, object_version)
|
|
1218
|
+
@uuid_prefix = Digest::SHA256.hexdigest(File.basename(path)).upcase
|
|
1219
|
+
super
|
|
1220
|
+
end
|
|
1221
|
+
|
|
1222
|
+
def generate_available_uuid_list(count = 100)
|
|
1223
|
+
start = @generated_uuids.size
|
|
1224
|
+
uniques = Array.new(count) { |i| format('%.6s%07X0', @uuid_prefix, start + i) }
|
|
1225
|
+
@generated_uuids += uniques
|
|
1226
|
+
@available_uuids += uniques
|
|
1227
|
+
end
|
|
1228
|
+
|
|
1229
|
+
def pods
|
|
1230
|
+
main_group['Pods']
|
|
1231
|
+
end
|
|
1232
|
+
|
|
1233
|
+
def development_pods
|
|
1234
|
+
main_group['Development Pods']
|
|
1235
|
+
end
|
|
1236
|
+
|
|
1237
|
+
def pod_groups
|
|
1238
|
+
[pods, development_pods].compact.flat_map(&:children)
|
|
1239
|
+
end
|
|
1240
|
+
|
|
1241
|
+
def pod_group(pod_name)
|
|
1242
|
+
pod_groups.find { |group| group.name == pod_name }
|
|
1243
|
+
end
|
|
1244
|
+
end
|
|
1245
|
+
end
|
|
1246
|
+
`
|
|
1247
|
+
|
|
1248
|
+
// the installer's post-generation state, over the analysis classes
|
|
1249
|
+
const INSTALLER = String.raw`
|
|
1250
|
+
module Pod
|
|
1251
|
+
class Installer
|
|
1252
|
+
class Xcode
|
|
1253
|
+
class PodsProjectGenerator
|
|
1254
|
+
class TargetInstallationResult
|
|
1255
|
+
attr_reader :target, :native_target, :resource_bundle_targets, :test_native_targets,
|
|
1256
|
+
:test_resource_bundle_targets, :test_app_host_targets, :app_native_targets,
|
|
1257
|
+
:app_resource_bundle_targets
|
|
1258
|
+
|
|
1259
|
+
def initialize(target, native_target, resource_bundle_targets = [])
|
|
1260
|
+
@target = target
|
|
1261
|
+
@native_target = native_target
|
|
1262
|
+
@resource_bundle_targets = resource_bundle_targets
|
|
1263
|
+
@test_native_targets = []
|
|
1264
|
+
@test_resource_bundle_targets = {}
|
|
1265
|
+
@test_app_host_targets = []
|
|
1266
|
+
@app_native_targets = {}
|
|
1267
|
+
@app_resource_bundle_targets = {}
|
|
1268
|
+
end
|
|
1269
|
+
end
|
|
1270
|
+
|
|
1271
|
+
class InstallationResults
|
|
1272
|
+
attr_reader :pod_target_installation_results, :aggregate_target_installation_results
|
|
1273
|
+
|
|
1274
|
+
def initialize(pod_target_installation_results, aggregate_target_installation_results)
|
|
1275
|
+
@pod_target_installation_results = pod_target_installation_results
|
|
1276
|
+
@aggregate_target_installation_results = aggregate_target_installation_results
|
|
1277
|
+
end
|
|
1278
|
+
end
|
|
1279
|
+
end
|
|
1280
|
+
end
|
|
1281
|
+
|
|
1282
|
+
attr_reader :pods_project, :target_installation_results
|
|
1283
|
+
|
|
1284
|
+
def generated_projects
|
|
1285
|
+
[pods_project]
|
|
1286
|
+
end
|
|
1287
|
+
|
|
1288
|
+
def generated_pod_targets
|
|
1289
|
+
pod_targets
|
|
1290
|
+
end
|
|
1291
|
+
|
|
1292
|
+
def generated_aggregate_targets
|
|
1293
|
+
aggregate_targets
|
|
1294
|
+
end
|
|
1295
|
+
|
|
1296
|
+
# what pod install does once it has generated the Pods project
|
|
1297
|
+
def peach_install(pods_project, pod_results, aggregate_results, aggregate_xcconfigs, pod_xcconfigs, file_accessors)
|
|
1298
|
+
@pods_project = pods_project
|
|
1299
|
+
result_class = Xcode::PodsProjectGenerator::TargetInstallationResult
|
|
1300
|
+
by_label = pod_targets.each_with_object({}) { |t, h| h[t.label] = t }
|
|
1301
|
+
aggregates_by_label = aggregate_targets.each_with_object({}) { |t, h| h[t.label] = t }
|
|
1302
|
+
pods = pod_results.each_with_object({}) do |(label, (native_target, bundles)), h|
|
|
1303
|
+
h[label] = result_class.new(by_label.fetch(label), pods_project.object(native_target), bundles.map { |uuid| pods_project.object(uuid) })
|
|
1304
|
+
end
|
|
1305
|
+
aggregates = aggregate_results.each_with_object({}) do |(label, native_target), h|
|
|
1306
|
+
h[label] = result_class.new(aggregates_by_label.fetch(label), pods_project.object(native_target))
|
|
1307
|
+
end
|
|
1308
|
+
@target_installation_results = Xcode::PodsProjectGenerator::InstallationResults.new(pods, aggregates)
|
|
1309
|
+
aggregate_xcconfigs.each { |label, by_config| aggregates_by_label.fetch(label).peach_xcconfigs = by_config }
|
|
1310
|
+
pod_xcconfigs.each { |label, by_config| by_label.fetch(label).peach_xcconfigs = by_config }
|
|
1311
|
+
file_accessors.each { |label, accessors| by_label.fetch(label).peach_file_accessors = accessors }
|
|
1312
|
+
run_podfile_post_install_hooks
|
|
1313
|
+
integrate_user_project
|
|
1314
|
+
perform_post_install_actions
|
|
1315
|
+
end
|
|
1316
|
+
|
|
1317
|
+
def integrate_user_project
|
|
1318
|
+
UserProjectIntegrator.new(podfile, sandbox, Pod::Config.instance.installation_root, aggregate_targets,
|
|
1319
|
+
generated_aggregate_targets).integrate!
|
|
1320
|
+
run_podfile_post_integrate_hooks
|
|
1321
|
+
end
|
|
1322
|
+
end
|
|
1323
|
+
|
|
1324
|
+
class Target
|
|
1325
|
+
def support_files_dir
|
|
1326
|
+
sandbox.root + 'Target Support Files' + label
|
|
1327
|
+
end
|
|
1328
|
+
|
|
1329
|
+
def xcconfig_path(variant = nil)
|
|
1330
|
+
if variant
|
|
1331
|
+
support_files_dir + "#{label}.#{variant.to_s.gsub(File::SEPARATOR, '-').downcase}.xcconfig"
|
|
1332
|
+
else
|
|
1333
|
+
support_files_dir + "#{label}.xcconfig"
|
|
1334
|
+
end
|
|
1335
|
+
end
|
|
1336
|
+
end
|
|
1337
|
+
|
|
1338
|
+
class AggregateTarget
|
|
1339
|
+
attr_writer :peach_xcconfigs
|
|
1340
|
+
|
|
1341
|
+
def xcconfigs
|
|
1342
|
+
@peach_xcconfigs
|
|
1343
|
+
end
|
|
1344
|
+
|
|
1345
|
+
def build_settings(configuration_name = nil)
|
|
1346
|
+
@build_settings ||= @peach_xcconfigs.each_with_object({}) do |(name, xcconfig), by_name|
|
|
1347
|
+
by_name[name] = Target::BuildSettings::AggregateTargetSettings.new(xcconfig)
|
|
1348
|
+
end
|
|
1349
|
+
if configuration_name
|
|
1350
|
+
@build_settings[configuration_name] ||
|
|
1351
|
+
raise(ArgumentError, "#{self} does not contain a build setting for the #{configuration_name} configuration, only #{@build_settings.keys}")
|
|
1352
|
+
else
|
|
1353
|
+
@build_settings.each_value.first || raise(ArgumentError, "#{self} does not contain any build settings")
|
|
1354
|
+
end
|
|
1355
|
+
end
|
|
1356
|
+
end
|
|
1357
|
+
|
|
1358
|
+
class PodTarget
|
|
1359
|
+
attr_writer :peach_file_accessors, :peach_xcconfigs
|
|
1360
|
+
|
|
1361
|
+
def file_accessors
|
|
1362
|
+
@peach_file_accessors
|
|
1363
|
+
end
|
|
1364
|
+
|
|
1365
|
+
def build_settings
|
|
1366
|
+
@build_settings ||= @peach_xcconfigs.each_with_object({}) do |(name, xcconfig), by_name|
|
|
1367
|
+
by_name[name] = Target::BuildSettings::PodTargetSettings.new(xcconfig)
|
|
1368
|
+
end
|
|
1369
|
+
end
|
|
1370
|
+
end
|
|
1371
|
+
|
|
1372
|
+
class Target
|
|
1373
|
+
# the settings Peach computed, as the xcconfig CocoaPods writes for them
|
|
1374
|
+
class BuildSettings
|
|
1375
|
+
attr_reader :xcconfig
|
|
1376
|
+
|
|
1377
|
+
def initialize(xcconfig)
|
|
1378
|
+
@xcconfig = xcconfig
|
|
1379
|
+
end
|
|
1380
|
+
|
|
1381
|
+
class PodTargetSettings < BuildSettings; end
|
|
1382
|
+
class AggregateTargetSettings < BuildSettings; end
|
|
1383
|
+
end
|
|
1384
|
+
end
|
|
1385
|
+
|
|
1386
|
+
class Sandbox
|
|
1387
|
+
class FileAccessor
|
|
1388
|
+
attr_reader :spec, :resource_bundles
|
|
1389
|
+
|
|
1390
|
+
def initialize(spec, resource_bundles)
|
|
1391
|
+
@spec = spec
|
|
1392
|
+
@resource_bundles = resource_bundles
|
|
1393
|
+
end
|
|
1394
|
+
end
|
|
1395
|
+
end
|
|
1396
|
+
end
|
|
1397
|
+
`
|
|
1398
|
+
|
|
1399
|
+
/** a generated project as its project.pbxproj holds it. */
|
|
1400
|
+
export interface ProjectTable {
|
|
1401
|
+
/** the .xcodeproj directory. */
|
|
1402
|
+
path: string
|
|
1403
|
+
objects: Record<string, PlistDict>
|
|
1404
|
+
rootObject: string
|
|
1405
|
+
objectVersion: string
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/** what the generator made for each target, by CocoaPods target label. */
|
|
1409
|
+
export interface InstallationResults {
|
|
1410
|
+
pods: Record<string, { nativeTarget: string; resourceBundleTargets: string[] }>
|
|
1411
|
+
aggregates: Record<string, { nativeTarget: string }>
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
1415
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
1416
|
+
|
|
1417
|
+
const XML_ESCAPES: Record<string, string> = { '&': '&', '<': '<', '>': '>' }
|
|
1418
|
+
const byBytes = (a: string, b: string) => Buffer.compare(Buffer.from(a), Buffer.from(b))
|
|
1419
|
+
|
|
1420
|
+
/** `root` as Nanaimo's pretty XML writer, which Xcodeproj::Plist.write_to_path uses, writes it. */
|
|
1421
|
+
function nanaimoXml(interp: Interpreter, root: RHash): string {
|
|
1422
|
+
let out =
|
|
1423
|
+
'<?xml version="1.0" encoding="UTF-8"?>\n<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n<plist version="1.0">\n'
|
|
1424
|
+
const write = (value: Value, depth: number): void => {
|
|
1425
|
+
const indent = '\t'.repeat(depth)
|
|
1426
|
+
if (value === true || value === false) out += `<${value}/>`
|
|
1427
|
+
else if (typeof value === 'number') out += `<integer>${value}</integer>`
|
|
1428
|
+
else if (value instanceof RFloat) out += `<real>${interp.toS(value)}</real>`
|
|
1429
|
+
else if (value instanceof RString || value instanceof RSymbol)
|
|
1430
|
+
out += `<string>${interp.toS(value).replace(/[&<>]/g, (c) => XML_ESCAPES[c]!)}</string>`
|
|
1431
|
+
else if (Array.isArray(value)) {
|
|
1432
|
+
if (value.length === 0) {
|
|
1433
|
+
out += '<array/>'
|
|
1434
|
+
return
|
|
1435
|
+
}
|
|
1436
|
+
out += '<array>\n'
|
|
1437
|
+
for (const item of value) {
|
|
1438
|
+
out += `${indent}\t`
|
|
1439
|
+
write(item, depth + 1)
|
|
1440
|
+
out += '\n'
|
|
1441
|
+
}
|
|
1442
|
+
out += `${indent}</array>`
|
|
1443
|
+
} else if (value instanceof RHash) {
|
|
1444
|
+
const entries = new Map(
|
|
1445
|
+
value.entries().map(([key, item]) => [interp.toS(key), item]),
|
|
1446
|
+
)
|
|
1447
|
+
if (entries.size === 0) {
|
|
1448
|
+
out += '<dict/>'
|
|
1449
|
+
return
|
|
1450
|
+
}
|
|
1451
|
+
out += '<dict>\n'
|
|
1452
|
+
for (const key of [...entries.keys()].sort(byBytes)) {
|
|
1453
|
+
out += `${indent}\t<key>${key.replace(/[&<>]/g, (c) => XML_ESCAPES[c]!)}</key>\n${indent}\t`
|
|
1454
|
+
write(entries.get(key)!, depth + 1)
|
|
1455
|
+
out += '\n'
|
|
1456
|
+
}
|
|
1457
|
+
out += `${indent}</dict>`
|
|
1458
|
+
} else
|
|
1459
|
+
throw new UnsupportedRuby(`Xcodeproj::Plist.write_to_path of ${interp.toS(value)}`)
|
|
1460
|
+
}
|
|
1461
|
+
write(root, 0)
|
|
1462
|
+
return `${out}\n</plist>\n`
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
const loaded = new WeakSet<Interpreter>()
|
|
1466
|
+
/** what `Peach::Pods.integrate_user_targets` runs for each interpreter's install. */
|
|
1467
|
+
const integrations = new WeakMap<Interpreter, (labels: string[]) => void>()
|
|
1468
|
+
|
|
1469
|
+
const own = (table: Record<string, string>, key: string) =>
|
|
1470
|
+
Object.hasOwn(table, key) ? str(table[key]!) : null
|
|
1471
|
+
|
|
1472
|
+
function loadFacade(interp: Interpreter) {
|
|
1473
|
+
if (loaded.has(interp)) return
|
|
1474
|
+
loaded.add(interp)
|
|
1475
|
+
const peach = interp.defineModule('Peach')
|
|
1476
|
+
const xcode = interp.defineModule('Xcode', peach)
|
|
1477
|
+
const def = (name: string, fn: (c: Call) => Value) =>
|
|
1478
|
+
interp.defineNative(xcode, name, fn, true)
|
|
1479
|
+
const text = (value: Value | undefined) => interp.toS(value ?? null)
|
|
1480
|
+
def('product_type_utis', () =>
|
|
1481
|
+
RHash.from(
|
|
1482
|
+
Object.entries(PRODUCT_TYPE_UTI).map(([type, uti]) => [sym(type), str(uti)]),
|
|
1483
|
+
),
|
|
1484
|
+
)
|
|
1485
|
+
def('file_type', (c) => own(FILE_TYPES_BY_EXTENSION, text(c.args[0])))
|
|
1486
|
+
def('product_extension', (c) => own(PRODUCT_UTI_EXTENSIONS, text(c.args[0])))
|
|
1487
|
+
def('header?', (c) => isHeader(text(c.args[0])))
|
|
1488
|
+
interp.defineNative(
|
|
1489
|
+
interp.defineModule('Pods', peach),
|
|
1490
|
+
'integrate_user_targets',
|
|
1491
|
+
(c) => {
|
|
1492
|
+
const integrate = integrations.get(interp)
|
|
1493
|
+
const labels = c.args[0]
|
|
1494
|
+
if (!integrate || !Array.isArray(labels))
|
|
1495
|
+
throw new UnsupportedRuby('UserProjectIntegrator outside a Peach install')
|
|
1496
|
+
integrate(labels.map((label) => text(label)))
|
|
1497
|
+
return null
|
|
1498
|
+
},
|
|
1499
|
+
true,
|
|
1500
|
+
)
|
|
1501
|
+
const settingValue = (key: string, value: Value): string => {
|
|
1502
|
+
if (value instanceof RString) return value.s
|
|
1503
|
+
throw new UnsupportedRuby(
|
|
1504
|
+
`xcconfig ${key} = ${Array.isArray(value) ? 'a list' : interp.toS(value)}`,
|
|
1505
|
+
)
|
|
1506
|
+
}
|
|
1507
|
+
const linkerFlags = (config: XcodeConfig) =>
|
|
1508
|
+
RHash.from(
|
|
1509
|
+
LINKER_KEYS.map((key) => [
|
|
1510
|
+
sym(key),
|
|
1511
|
+
[...config.otherLinkerFlags[key]].map((flag) => str(flag)),
|
|
1512
|
+
]),
|
|
1513
|
+
)
|
|
1514
|
+
const fromConfig = (config: XcodeConfig): Value[] => [
|
|
1515
|
+
RHash.from([...config.attributes].map(([key, value]) => [str(key), str(value)])),
|
|
1516
|
+
linkerFlags(config),
|
|
1517
|
+
config.includes.map((file) => str(file)),
|
|
1518
|
+
]
|
|
1519
|
+
const toConfig = (value: Value | undefined) => {
|
|
1520
|
+
if (!(value instanceof RObject))
|
|
1521
|
+
throw new UnsupportedRuby('Xcodeproj::Config without a config')
|
|
1522
|
+
const attributes = value.ivars.get('@attributes')
|
|
1523
|
+
const flags = value.ivars.get('@other_linker_flags')
|
|
1524
|
+
const includes = value.ivars.get('@includes')
|
|
1525
|
+
if (
|
|
1526
|
+
!(attributes instanceof RHash) ||
|
|
1527
|
+
!(flags instanceof RHash) ||
|
|
1528
|
+
!Array.isArray(includes)
|
|
1529
|
+
)
|
|
1530
|
+
throw new UnsupportedRuby('Xcodeproj::Config with replaced attributes')
|
|
1531
|
+
const config = new XcodeConfig()
|
|
1532
|
+
for (const [key, setting] of attributes.entries())
|
|
1533
|
+
config.attributes.set(text(key), settingValue(text(key), setting))
|
|
1534
|
+
for (const key of LINKER_KEYS) {
|
|
1535
|
+
const list = flags.get(sym(key))
|
|
1536
|
+
if (!Array.isArray(list))
|
|
1537
|
+
throw new UnsupportedRuby(`Xcodeproj::Config linker flags without ${key}`)
|
|
1538
|
+
for (const flag of list) config.otherLinkerFlags[key].add(text(flag))
|
|
1539
|
+
}
|
|
1540
|
+
config.includes = includes.map((file) => text(file))
|
|
1541
|
+
return config
|
|
1542
|
+
}
|
|
1543
|
+
def('config_parse', (c) =>
|
|
1544
|
+
fromConfig(XcodeConfig.parse(fs.readFileSync(text(c.args[0]), 'utf8'))),
|
|
1545
|
+
)
|
|
1546
|
+
def('config_from_hash', (c) => {
|
|
1547
|
+
const hash = c.args[0]
|
|
1548
|
+
if (!(hash instanceof RHash))
|
|
1549
|
+
throw new UnsupportedRuby('Xcodeproj::Config.new without a hash')
|
|
1550
|
+
return fromConfig(
|
|
1551
|
+
new XcodeConfig(
|
|
1552
|
+
new Map(
|
|
1553
|
+
hash
|
|
1554
|
+
.entries()
|
|
1555
|
+
.map(([key, value]) => [text(key), settingValue(text(key), value)]),
|
|
1556
|
+
),
|
|
1557
|
+
),
|
|
1558
|
+
)
|
|
1559
|
+
})
|
|
1560
|
+
def('config_merge', (c) => {
|
|
1561
|
+
const config = toConfig(c.args[0])
|
|
1562
|
+
config.merge(toConfig(c.args[1]))
|
|
1563
|
+
return fromConfig(config).slice(0, 2)
|
|
1564
|
+
})
|
|
1565
|
+
def('config_hash', (c) =>
|
|
1566
|
+
RHash.from(
|
|
1567
|
+
[...toConfig(c.args[0]).toHash()].map(([key, value]) => [str(key), str(value)]),
|
|
1568
|
+
),
|
|
1569
|
+
)
|
|
1570
|
+
def('config_render', (c) => str(toConfig(c.args[0]).toString()))
|
|
1571
|
+
def('plist_read', (c) => fromJson(parsePlistBytes(fs.readFileSync(text(c.args[0])))))
|
|
1572
|
+
def('plist_write', (c) => {
|
|
1573
|
+
const target = path.resolve(interp.host.cwd, text(c.args[0]))
|
|
1574
|
+
if (
|
|
1575
|
+
!interp.host.writable.some(
|
|
1576
|
+
(root) => target === root || target.startsWith(`${root}/`),
|
|
1577
|
+
)
|
|
1578
|
+
)
|
|
1579
|
+
throw new UnsupportedRuby(
|
|
1580
|
+
`Xcodeproj::Plist.write_to_path writes ${target} outside the app`,
|
|
1581
|
+
)
|
|
1582
|
+
const value = c.args[1] ?? null
|
|
1583
|
+
if (!(value instanceof RHash))
|
|
1584
|
+
throw new UnsupportedRuby(
|
|
1585
|
+
`Xcodeproj::Plist.write_to_path(${target}) without a hash`,
|
|
1586
|
+
)
|
|
1587
|
+
fs.writeFileSync(target, nanaimoXml(interp, value))
|
|
1588
|
+
return null
|
|
1589
|
+
})
|
|
1590
|
+
interp.evalString(XCODEPROJ, 'xcodeproj')
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
/** the Ruby `Xcodeproj::Project` (or `Pod::Project`) over `table`, whose build settings hooks may change. */
|
|
1594
|
+
export function rubyProject(
|
|
1595
|
+
interp: Interpreter,
|
|
1596
|
+
table: ProjectTable,
|
|
1597
|
+
className: 'Xcodeproj::Project' | 'Pod::Project',
|
|
1598
|
+
): RObject {
|
|
1599
|
+
loadFacade(interp)
|
|
1600
|
+
const [outer, inner] = className.split('::')
|
|
1601
|
+
const module = interp.object.consts.get(outer!)
|
|
1602
|
+
const cls = module instanceof RModule ? interp.constIn(module, inner!, null, '-') : null
|
|
1603
|
+
const project = interp.callMethod(
|
|
1604
|
+
cls,
|
|
1605
|
+
'new',
|
|
1606
|
+
[
|
|
1607
|
+
str(table.path),
|
|
1608
|
+
fromJson(table.objects),
|
|
1609
|
+
str(table.rootObject),
|
|
1610
|
+
str(table.objectVersion),
|
|
1611
|
+
],
|
|
1612
|
+
null,
|
|
1613
|
+
null,
|
|
1614
|
+
null,
|
|
1615
|
+
null,
|
|
1616
|
+
)
|
|
1617
|
+
if (!(project instanceof RObject))
|
|
1618
|
+
throw new Error(`${className}.new returned no object`)
|
|
1619
|
+
return project
|
|
1620
|
+
}
|
|
1621
|
+
|
|
1622
|
+
/** `project`'s objects table as the facade holds it now. */
|
|
1623
|
+
function facadeTable(interp: Interpreter, project: RObject): PbxTable {
|
|
1624
|
+
const objects = toJson(interp, project.ivars.get('@objects') ?? null)
|
|
1625
|
+
if (!isRecord(objects)) throw new Error('the project facade lost its objects')
|
|
1626
|
+
const root = project.ivars.get('@root_object')
|
|
1627
|
+
const rootUuid = root instanceof RObject ? root.ivars.get('@uuid') : null
|
|
1628
|
+
if (!(rootUuid instanceof RString))
|
|
1629
|
+
throw new Error('the project facade lost its root object')
|
|
1630
|
+
// project.pbxproj writes a scalar a hook set, such as USE_HERMES = true, as its text
|
|
1631
|
+
const plistValue = (value: unknown, at: string): PlistValue => {
|
|
1632
|
+
if (typeof value === 'string') return value
|
|
1633
|
+
if (typeof value === 'number' || typeof value === 'boolean') return String(value)
|
|
1634
|
+
if (Array.isArray(value)) return value.map((item) => plistValue(item, at))
|
|
1635
|
+
if (isRecord(value))
|
|
1636
|
+
return Object.fromEntries(
|
|
1637
|
+
Object.entries(value).map(([key, item]) => [
|
|
1638
|
+
key,
|
|
1639
|
+
plistValue(item, `${at}.${key}`),
|
|
1640
|
+
]),
|
|
1641
|
+
)
|
|
1642
|
+
throw new Error(`an install hook left ${at} with a value no project.pbxproj holds`)
|
|
1643
|
+
}
|
|
1644
|
+
const table = new PbxTable({}, rootUuid.s)
|
|
1645
|
+
for (const [uuid, object] of Object.entries(objects)) {
|
|
1646
|
+
const value = plistValue(object, uuid)
|
|
1647
|
+
if (!isDict(value)) throw new Error(`${uuid} is no object`)
|
|
1648
|
+
table.objects[uuid] = value
|
|
1649
|
+
}
|
|
1650
|
+
return table
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
/** `project`'s objects as Xcodeproj saves what the hooks left: those the project refers to, with array settings normalized. */
|
|
1654
|
+
export function projectObjects(
|
|
1655
|
+
interp: Interpreter,
|
|
1656
|
+
project: RObject,
|
|
1657
|
+
): Record<string, PlistDict> {
|
|
1658
|
+
const objectVersion = project.ivars.get('@object_version')
|
|
1659
|
+
if (!(objectVersion instanceof RString))
|
|
1660
|
+
throw new Error('the project facade lost its object version')
|
|
1661
|
+
const objects = facadeTable(interp, project).reachable()
|
|
1662
|
+
for (const object of Object.values(objects)) {
|
|
1663
|
+
if (object.isa === 'XCBuildConfiguration' && isDict(object.buildSettings))
|
|
1664
|
+
normalizeArraySettings(object.buildSettings, objectVersion.s)
|
|
1665
|
+
// PBXProject#to_ascii_plist leaves out these lists when they are empty
|
|
1666
|
+
if (object.isa === 'PBXProject')
|
|
1667
|
+
for (const key of ['projectReferences', 'packageReferences'])
|
|
1668
|
+
if (Array.isArray(object[key]) && object[key].length === 0) delete object[key]
|
|
1669
|
+
}
|
|
1670
|
+
return objects
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
/** what pod install holds once it has generated the Pods project. */
|
|
1674
|
+
export interface GeneratedInstall {
|
|
1675
|
+
/** the analysis installer. */
|
|
1676
|
+
installer: RObject
|
|
1677
|
+
podsProject: RObject
|
|
1678
|
+
/** the application's project the analysis read. */
|
|
1679
|
+
userProject: RObject
|
|
1680
|
+
results: InstallationResults
|
|
1681
|
+
targets: PodTargets
|
|
1682
|
+
settings: PodsBuildSettings
|
|
1683
|
+
aggregates: AnalyzedAggregateTarget[]
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* runs what pod install does after generating the Pods project: the Podfile's
|
|
1688
|
+
* post_install hooks, the integration of the application's targets, with what
|
|
1689
|
+
* plugins prepend onto it, the post_integrate hooks and the actions plugins
|
|
1690
|
+
* add after install. the hooks edit both projects in memory and may rewrite
|
|
1691
|
+
* xcconfigs and plists in the app.
|
|
1692
|
+
*/
|
|
1693
|
+
export function runInstallHooks(
|
|
1694
|
+
interp: Interpreter,
|
|
1695
|
+
file: string,
|
|
1696
|
+
install: GeneratedInstall,
|
|
1697
|
+
): void {
|
|
1698
|
+
const { targets, settings } = install
|
|
1699
|
+
rubyFailures(file, () => {
|
|
1700
|
+
loadFacade(interp)
|
|
1701
|
+
interp.evalString(INSTALLER, 'cocoapods/installer/post_install')
|
|
1702
|
+
const pathname = interp.object.consts.get('Pathname') ?? null
|
|
1703
|
+
const call = (receiver: Value, name: string, args: Value[]) =>
|
|
1704
|
+
interp.callMethod(receiver, name, args, null, null, null, null)
|
|
1705
|
+
const configClass = interp.evalString('Xcodeproj::Config', 'peach/post_install')
|
|
1706
|
+
const accessorClass = interp.evalString(
|
|
1707
|
+
'Pod::Sandbox::FileAccessor',
|
|
1708
|
+
'peach/post_install',
|
|
1709
|
+
)
|
|
1710
|
+
const rubyXcconfigs = (byName: [string, XcodeConfig][]) =>
|
|
1711
|
+
RHash.from(
|
|
1712
|
+
byName.map(([name, config]) => [
|
|
1713
|
+
str(name),
|
|
1714
|
+
call(configClass, 'new', [
|
|
1715
|
+
RHash.from(
|
|
1716
|
+
[...config.toHash()].map(([key, value]) => [str(key), str(value)]),
|
|
1717
|
+
),
|
|
1718
|
+
]),
|
|
1719
|
+
]),
|
|
1720
|
+
)
|
|
1721
|
+
const aggregateXcconfigs = RHash.from(
|
|
1722
|
+
targets.aggregateTargets.map((target) => [
|
|
1723
|
+
str(target.label),
|
|
1724
|
+
rubyXcconfigs(
|
|
1725
|
+
Object.keys(target.userBuildConfigurations).map((name) => [
|
|
1726
|
+
name,
|
|
1727
|
+
settings.aggregate(target, name).xcconfig(),
|
|
1728
|
+
]),
|
|
1729
|
+
),
|
|
1730
|
+
]),
|
|
1731
|
+
)
|
|
1732
|
+
const podXcconfigs = RHash.from(
|
|
1733
|
+
targets.podTargets.map((target) => [
|
|
1734
|
+
str(target.label),
|
|
1735
|
+
rubyXcconfigs(
|
|
1736
|
+
Object.entries(target.userBuildConfigurations).map(([name, type]) => [
|
|
1737
|
+
name,
|
|
1738
|
+
settings.pod(target, type).xcconfig(),
|
|
1739
|
+
]),
|
|
1740
|
+
),
|
|
1741
|
+
]),
|
|
1742
|
+
)
|
|
1743
|
+
const accessors = RHash.from(
|
|
1744
|
+
targets.podTargets.map((target) => [
|
|
1745
|
+
str(target.label),
|
|
1746
|
+
target.fileAccessors.map((accessor) =>
|
|
1747
|
+
call(accessorClass, 'new', [
|
|
1748
|
+
str(accessor.specName),
|
|
1749
|
+
RHash.from(
|
|
1750
|
+
Object.entries(accessor.resourceBundles).map(([bundle, files]) => [
|
|
1751
|
+
str(bundle),
|
|
1752
|
+
files.map((resource) => call(pathname, 'new', [str(resource)])),
|
|
1753
|
+
]),
|
|
1754
|
+
),
|
|
1755
|
+
]),
|
|
1756
|
+
),
|
|
1757
|
+
]),
|
|
1758
|
+
)
|
|
1759
|
+
integrations.set(interp, (labels) => {
|
|
1760
|
+
const table = facadeTable(interp, install.userProject)
|
|
1761
|
+
const objectVersion = install.userProject.ivars.get('@object_version')
|
|
1762
|
+
if (!(objectVersion instanceof RString))
|
|
1763
|
+
throw new Error('the user project facade lost its object version')
|
|
1764
|
+
const project = new UserProject(
|
|
1765
|
+
table,
|
|
1766
|
+
interp.toS(call(call(install.userProject, 'path', []), 'to_s', [])),
|
|
1767
|
+
objectVersion.s,
|
|
1768
|
+
)
|
|
1769
|
+
integrateUserTargets(
|
|
1770
|
+
project,
|
|
1771
|
+
labels.map((label) => {
|
|
1772
|
+
const target = targets.aggregateTargets.find(
|
|
1773
|
+
(aggregate) => aggregate.label === label,
|
|
1774
|
+
)
|
|
1775
|
+
const analyzed = install.aggregates.find(
|
|
1776
|
+
(aggregate) => aggregate.label === label,
|
|
1777
|
+
)
|
|
1778
|
+
if (!target || !analyzed)
|
|
1779
|
+
throw new Error(`pod install integrates an unknown target ${label}`)
|
|
1780
|
+
return {
|
|
1781
|
+
target,
|
|
1782
|
+
userTargets: analyzed.userTargets,
|
|
1783
|
+
scriptPhases: analyzed.scriptPhases,
|
|
1784
|
+
}
|
|
1785
|
+
}),
|
|
1786
|
+
)
|
|
1787
|
+
call(install.userProject, 'peach_reload', [fromJson(table.reachable())])
|
|
1788
|
+
})
|
|
1789
|
+
call(install.installer, 'peach_install', [
|
|
1790
|
+
install.podsProject,
|
|
1791
|
+
RHash.from(
|
|
1792
|
+
Object.entries(install.results.pods).map(([label, result]) => [
|
|
1793
|
+
str(label),
|
|
1794
|
+
[
|
|
1795
|
+
str(result.nativeTarget),
|
|
1796
|
+
result.resourceBundleTargets.map((uuid) => str(uuid)),
|
|
1797
|
+
],
|
|
1798
|
+
]),
|
|
1799
|
+
),
|
|
1800
|
+
RHash.from(
|
|
1801
|
+
Object.entries(install.results.aggregates).map(([label, result]) => [
|
|
1802
|
+
str(label),
|
|
1803
|
+
str(result.nativeTarget),
|
|
1804
|
+
]),
|
|
1805
|
+
),
|
|
1806
|
+
aggregateXcconfigs,
|
|
1807
|
+
podXcconfigs,
|
|
1808
|
+
accessors,
|
|
1809
|
+
])
|
|
1810
|
+
})
|
|
1811
|
+
}
|