peachsim 0.1.2430 → 0.1.2432
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 +15765 -5973
- 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 -4888
- 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 +15464 -5754
- package/dist-lib/host/fetch-proxy-handler.cjs +3204 -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 +3541 -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 +3437 -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 +172 -79
- 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 +16786 -6994
- 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 +74 -6
- package/dist-lib/vite.cjs +3331 -181
- 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,778 @@
|
|
|
1
|
+
// integrates an application's targets with the targets Peach generates for its
|
|
2
|
+
// Podfile, as CocoaPods 1.17's UserProjectIntegrator::TargetIntegrator and
|
|
3
|
+
// XCConfigIntegrator do (MIT, Eloy Durán and the CocoaPods team), over the
|
|
4
|
+
// application project's objects table.
|
|
5
|
+
import fs from 'node:fs'
|
|
6
|
+
import path from 'node:path'
|
|
7
|
+
import { PbxTable, type PlistDict, type PlistValue } from './pbx-table'
|
|
8
|
+
import { xcframeworkIntermediateDir } from './pods-build-settings'
|
|
9
|
+
import { HEADER_EXTENSIONS } from './pods-files'
|
|
10
|
+
import { type AggregateTarget, outputExtensionForResource } from './pods-targets'
|
|
11
|
+
|
|
12
|
+
// Xcodeproj::Constants::PRODUCT_TYPE_UTI
|
|
13
|
+
export const PRODUCT_TYPE_UTI: Record<string, string> = {
|
|
14
|
+
application: 'com.apple.product-type.application',
|
|
15
|
+
application_on_demand_install_capable:
|
|
16
|
+
'com.apple.product-type.application.on-demand-install-capable',
|
|
17
|
+
framework: 'com.apple.product-type.framework',
|
|
18
|
+
dynamic_library: 'com.apple.product-type.library.dynamic',
|
|
19
|
+
static_library: 'com.apple.product-type.library.static',
|
|
20
|
+
bundle: 'com.apple.product-type.bundle',
|
|
21
|
+
octest_bundle: 'com.apple.product-type.bundle',
|
|
22
|
+
unit_test_bundle: 'com.apple.product-type.bundle.unit-test',
|
|
23
|
+
ui_test_bundle: 'com.apple.product-type.bundle.ui-testing',
|
|
24
|
+
app_extension: 'com.apple.product-type.app-extension',
|
|
25
|
+
command_line_tool: 'com.apple.product-type.tool',
|
|
26
|
+
watch_app: 'com.apple.product-type.application.watchapp',
|
|
27
|
+
watch2_app: 'com.apple.product-type.application.watchapp2',
|
|
28
|
+
watch2_app_container: 'com.apple.product-type.application.watchapp2-container',
|
|
29
|
+
watch_extension: 'com.apple.product-type.watchkit-extension',
|
|
30
|
+
watch2_extension: 'com.apple.product-type.watchkit2-extension',
|
|
31
|
+
tv_extension: 'com.apple.product-type.tv-app-extension',
|
|
32
|
+
messages_application: 'com.apple.product-type.application.messages',
|
|
33
|
+
messages_extension: 'com.apple.product-type.app-extension.messages',
|
|
34
|
+
sticker_pack: 'com.apple.product-type.app-extension.messages-sticker-pack',
|
|
35
|
+
xpc_service: 'com.apple.product-type.xpc-service',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Xcodeproj::Constants::FILE_TYPES_BY_EXTENSION
|
|
39
|
+
export const FILE_TYPES_BY_EXTENSION: Record<string, string> = {
|
|
40
|
+
a: 'archive.ar',
|
|
41
|
+
apns: 'text',
|
|
42
|
+
app: 'wrapper.application',
|
|
43
|
+
appex: 'wrapper.app-extension',
|
|
44
|
+
bundle: 'wrapper.plug-in',
|
|
45
|
+
cpp: 'sourcecode.cpp.cpp',
|
|
46
|
+
dylib: 'compiled.mach-o.dylib',
|
|
47
|
+
entitlements: 'text.plist.entitlements',
|
|
48
|
+
framework: 'wrapper.framework',
|
|
49
|
+
gif: 'image.gif',
|
|
50
|
+
gpx: 'text.xml',
|
|
51
|
+
h: 'sourcecode.c.h',
|
|
52
|
+
hpp: 'sourcecode.cpp.h',
|
|
53
|
+
m: 'sourcecode.c.objc',
|
|
54
|
+
markdown: 'text',
|
|
55
|
+
mdimporter: 'wrapper.cfbundle',
|
|
56
|
+
modulemap: 'sourcecode.module',
|
|
57
|
+
mov: 'video.quicktime',
|
|
58
|
+
mp3: 'audio.mp3',
|
|
59
|
+
octest: 'wrapper.cfbundle',
|
|
60
|
+
pch: 'sourcecode.c.h',
|
|
61
|
+
plist: 'text.plist.xml',
|
|
62
|
+
png: 'image.png',
|
|
63
|
+
sh: 'text.script.sh',
|
|
64
|
+
sks: 'file.sks',
|
|
65
|
+
storyboard: 'file.storyboard',
|
|
66
|
+
strings: 'text.plist.strings',
|
|
67
|
+
swift: 'sourcecode.swift',
|
|
68
|
+
xcassets: 'folder.assetcatalog',
|
|
69
|
+
xcconfig: 'text.xcconfig',
|
|
70
|
+
xcdatamodel: 'wrapper.xcdatamodel',
|
|
71
|
+
xcodeproj: 'wrapper.pb-project',
|
|
72
|
+
xctest: 'wrapper.cfbundle',
|
|
73
|
+
xib: 'file.xib',
|
|
74
|
+
zip: 'archive.zip',
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Xcodeproj::Constants::PRODUCT_UTI_EXTENSIONS
|
|
78
|
+
export const PRODUCT_UTI_EXTENSIONS: Record<string, string> = {
|
|
79
|
+
application: 'app',
|
|
80
|
+
application_on_demand_install_capable: 'app',
|
|
81
|
+
framework: 'framework',
|
|
82
|
+
dynamic_library: 'dylib',
|
|
83
|
+
static_library: 'a',
|
|
84
|
+
bundle: 'bundle',
|
|
85
|
+
octest_bundle: 'octest',
|
|
86
|
+
unit_test_bundle: 'xctest',
|
|
87
|
+
ui_test_bundle: 'xctest',
|
|
88
|
+
app_extension: 'appex',
|
|
89
|
+
messages_application: 'app',
|
|
90
|
+
messages_extension: 'appex',
|
|
91
|
+
sticker_pack: 'appex',
|
|
92
|
+
watch2_extension: 'appex',
|
|
93
|
+
watch2_app: 'app',
|
|
94
|
+
watch2_app_container: 'app',
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const BUILD_PHASE_PREFIX = '[CP] '
|
|
98
|
+
const USER_BUILD_PHASE_PREFIX = '[CP-User] '
|
|
99
|
+
const EMBED_FRAMEWORK_TARGET_TYPES = [
|
|
100
|
+
'application',
|
|
101
|
+
'application_on_demand_install_capable',
|
|
102
|
+
'unit_test_bundle',
|
|
103
|
+
'ui_test_bundle',
|
|
104
|
+
'watch2_extension',
|
|
105
|
+
'messages_application',
|
|
106
|
+
]
|
|
107
|
+
const EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES = [
|
|
108
|
+
'app_extension',
|
|
109
|
+
'framework',
|
|
110
|
+
'static_library',
|
|
111
|
+
'messages_extension',
|
|
112
|
+
'watch_extension',
|
|
113
|
+
'xpc_service',
|
|
114
|
+
]
|
|
115
|
+
const MAX_INPUT_OUTPUT_PATHS = 1000
|
|
116
|
+
// Pod::Deintegrator::FRAMEWORK_NAMES
|
|
117
|
+
const FRAMEWORK_NAMES = /^(libPods.*\.a)|(Pods.*\.framework)$/i
|
|
118
|
+
const CHECK_MANIFEST_SCRIPT = `diff "\${PODS_PODFILE_DIR_PATH}/Podfile.lock" "\${PODS_ROOT}/Manifest.lock" > /dev/null
|
|
119
|
+
if [ $? != 0 ] ; then
|
|
120
|
+
# print error to STDERR
|
|
121
|
+
echo "error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation." >&2
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
# This output is used by Xcode 'outputs' to avoid re-running this script phase.
|
|
125
|
+
echo "SUCCESS" > "\${SCRIPT_OUTPUT_FILE_0}"
|
|
126
|
+
`
|
|
127
|
+
const DEFAULT_SHELL_SCRIPT =
|
|
128
|
+
'# Type a script or drag a script file from your workspace to insert its path.\n'
|
|
129
|
+
|
|
130
|
+
/** a Podfile target to integrate, with the user targets and script phases it declares. */
|
|
131
|
+
export interface TargetToIntegrate {
|
|
132
|
+
target: AggregateTarget
|
|
133
|
+
userTargets: string[]
|
|
134
|
+
scriptPhases: Record<string, unknown>[]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const stringList = (value: unknown): string[] | null =>
|
|
138
|
+
Array.isArray(value) && value.every((item) => typeof item === 'string') ? value : null
|
|
139
|
+
|
|
140
|
+
/** an application's project, as its objects table, with the group and phase edits integration makes. */
|
|
141
|
+
export class UserProject {
|
|
142
|
+
constructor(
|
|
143
|
+
readonly table: PbxTable,
|
|
144
|
+
/** the .xcodeproj directory. */
|
|
145
|
+
readonly path: string,
|
|
146
|
+
readonly objectVersion: string,
|
|
147
|
+
) {}
|
|
148
|
+
|
|
149
|
+
get projectDir(): string {
|
|
150
|
+
return path.dirname(this.path)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get root(): PlistDict {
|
|
154
|
+
return this.table.get(this.table.rootObject)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get mainGroup(): string {
|
|
158
|
+
const id = this.root.mainGroup
|
|
159
|
+
if (typeof id !== 'string') throw new Error(`${this.path} has no main group`)
|
|
160
|
+
return id
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
add(seed: string, object: PlistDict): string {
|
|
164
|
+
return this.table.add(`${path.basename(this.path)}/${seed}`, object)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** the object listing `id` among its children, or the project for the main group. */
|
|
168
|
+
parent(id: string): string {
|
|
169
|
+
if (id === this.mainGroup) return this.table.rootObject
|
|
170
|
+
const parents = this.table
|
|
171
|
+
.ids('PBXGroup')
|
|
172
|
+
.concat(this.table.ids('PBXVariantGroup'), this.table.ids('XCVersionGroup'))
|
|
173
|
+
.filter((group) => this.table.list(group, 'children').includes(id))
|
|
174
|
+
if (parents.length !== 1)
|
|
175
|
+
throw new Error(
|
|
176
|
+
`[Xcodeproj] Consistency issue: ${parents.length} parents for ${id} in ${this.path}`,
|
|
177
|
+
)
|
|
178
|
+
return parents[0]!
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// GroupableHelper.source_tree_real_path
|
|
182
|
+
sourceTreeRealPath(id: string): string | null {
|
|
183
|
+
const tree = this.table.string(id, 'sourceTree')
|
|
184
|
+
if (tree === '<group>') {
|
|
185
|
+
const parent = this.parent(id)
|
|
186
|
+
return parent === this.table.rootObject
|
|
187
|
+
? path.join(this.projectDir, this.table.string(parent, 'projectDirPath') ?? '')
|
|
188
|
+
: this.realPath(parent)
|
|
189
|
+
}
|
|
190
|
+
if (tree === 'SOURCE_ROOT') return this.projectDir
|
|
191
|
+
if (tree === '<absolute>') return null
|
|
192
|
+
return `\${${tree}}`
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
realPath(id: string): string {
|
|
196
|
+
const tree = this.sourceTreeRealPath(id)
|
|
197
|
+
const own = this.table.string(id, 'path') ?? ''
|
|
198
|
+
return tree === null ? own : path.join(tree, own)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
displayName(id: string): string {
|
|
202
|
+
const object = this.table.get(id)
|
|
203
|
+
const name = typeof object.name === 'string' ? object.name : undefined
|
|
204
|
+
const own = typeof object.path === 'string' ? object.path : undefined
|
|
205
|
+
if (object.isa === 'PBXFileReference')
|
|
206
|
+
return (
|
|
207
|
+
name ??
|
|
208
|
+
(object.sourceTree === 'BUILT_PRODUCTS_DIR' ? own : own && path.basename(own)) ??
|
|
209
|
+
''
|
|
210
|
+
)
|
|
211
|
+
if (
|
|
212
|
+
object.isa === 'PBXGroup' ||
|
|
213
|
+
object.isa === 'PBXVariantGroup' ||
|
|
214
|
+
object.isa === 'XCVersionGroup'
|
|
215
|
+
)
|
|
216
|
+
return (
|
|
217
|
+
name ?? (own && path.basename(own)) ?? (id === this.mainGroup ? 'Main Group' : '')
|
|
218
|
+
)
|
|
219
|
+
if (name) return name
|
|
220
|
+
return typeof object.isa === 'string' ? object.isa.replace(/^(PBX|XC)/, '') : ''
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
child(group: string, name: string): string | undefined {
|
|
224
|
+
return this.table.list(group, 'children').find((id) => this.displayName(id) === name)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
files(group: string): string[] {
|
|
228
|
+
return this.table
|
|
229
|
+
.list(group, 'children')
|
|
230
|
+
.filter((id) => this.table.get(id).isa === 'PBXFileReference')
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// PBXGroup#new_group
|
|
234
|
+
newGroup(parent: string, name: string, groupPath?: string): string {
|
|
235
|
+
const group = this.add(`${this.realPath(parent)}/${name}`, {
|
|
236
|
+
isa: 'PBXGroup',
|
|
237
|
+
children: [],
|
|
238
|
+
name,
|
|
239
|
+
sourceTree: '<group>',
|
|
240
|
+
})
|
|
241
|
+
this.table.list(parent, 'children').push(group)
|
|
242
|
+
if (groupPath) this.setPath(group, groupPath, '<group>')
|
|
243
|
+
return group
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// FileReferencesFactory.new_reference for a plain file
|
|
247
|
+
newFile(group: string, filePath: string, sourceTree = '<group>'): string {
|
|
248
|
+
const extension = path.extname(filePath).toLowerCase()
|
|
249
|
+
if (extension === '.xcdatamodeld' || extension === '.xcodeproj')
|
|
250
|
+
throw new Error(`Peach adds no ${extension} reference (${filePath})`)
|
|
251
|
+
const ref = this.add(`${this.realPath(group)}/${filePath}`, {
|
|
252
|
+
isa: 'PBXFileReference',
|
|
253
|
+
includeInIndex: '1',
|
|
254
|
+
sourceTree,
|
|
255
|
+
})
|
|
256
|
+
this.table.list(group, 'children').push(ref)
|
|
257
|
+
this.setPath(ref, filePath, sourceTree)
|
|
258
|
+
const object = this.table.get(ref)
|
|
259
|
+
const type = FILE_TYPES_BY_EXTENSION[path.extname(filePath).slice(1)]
|
|
260
|
+
if (type) object.lastKnownFileType = type
|
|
261
|
+
const own = this.table.string(ref, 'path') ?? ''
|
|
262
|
+
if (own.includes('/')) object.name = own.slice(own.lastIndexOf('/') + 1)
|
|
263
|
+
if (path.extname(own).toLowerCase() === '.framework') delete object.includeInIndex
|
|
264
|
+
return ref
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// GroupableHelper.set_path_with_source_tree
|
|
268
|
+
setPath(id: string, filePath: string, sourceTree: string): void {
|
|
269
|
+
const object = this.table.get(id)
|
|
270
|
+
object.sourceTree = sourceTree
|
|
271
|
+
if (sourceTree === '<absolute>') {
|
|
272
|
+
if (!path.isAbsolute(filePath))
|
|
273
|
+
throw new Error(
|
|
274
|
+
`[Xcodeproj] Attempt to set a relative path with an absolute source tree: \`${filePath}\``,
|
|
275
|
+
)
|
|
276
|
+
object.path = filePath
|
|
277
|
+
} else if (sourceTree === '<group>' || sourceTree === 'SOURCE_ROOT') {
|
|
278
|
+
const tree = this.sourceTreeRealPath(id)
|
|
279
|
+
object.path =
|
|
280
|
+
tree !== null && path.isAbsolute(tree) === path.isAbsolute(filePath)
|
|
281
|
+
? path.relative(tree, filePath)
|
|
282
|
+
: filePath
|
|
283
|
+
} else object.path = filePath
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
symbolType(target: string): string | undefined {
|
|
287
|
+
const type = this.table.string(target, 'productType')
|
|
288
|
+
return Object.keys(PRODUCT_TYPE_UTI).find((key) => PRODUCT_TYPE_UTI[key] === type)
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
phases(target: string): string[] {
|
|
292
|
+
return this.table.list(target, 'buildPhases')
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** the target's phase of `isa`, added when it has none. */
|
|
296
|
+
phase(target: string, isa: string): string {
|
|
297
|
+
const found = this.phases(target).find((id) => this.table.get(id).isa === isa)
|
|
298
|
+
if (found) return found
|
|
299
|
+
const phase = this.add(`${target}/${isa}`, {
|
|
300
|
+
isa,
|
|
301
|
+
buildActionMask: '2147483647',
|
|
302
|
+
files: [],
|
|
303
|
+
runOnlyForDeploymentPostprocessing: '0',
|
|
304
|
+
})
|
|
305
|
+
this.phases(target).push(phase)
|
|
306
|
+
return phase
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
shellPhases(target: string): string[] {
|
|
310
|
+
return this.phases(target).filter(
|
|
311
|
+
(id) => this.table.get(id).isa === 'PBXShellScriptBuildPhase',
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** the build file of `phase` for `ref`, added when the phase has none. */
|
|
316
|
+
buildFile(phase: string, ref: string): string {
|
|
317
|
+
const files = this.table.list(phase, 'files')
|
|
318
|
+
const found = files.find((id) => this.table.string(id, 'fileRef') === ref)
|
|
319
|
+
if (found) return found
|
|
320
|
+
const file = this.add(`${phase}/${ref}`, { isa: 'PBXBuildFile', fileRef: ref })
|
|
321
|
+
files.push(file)
|
|
322
|
+
return file
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
remove(id: string): void {
|
|
326
|
+
for (const object of Object.values(this.table.objects))
|
|
327
|
+
for (const [key, value] of Object.entries(object)) {
|
|
328
|
+
if (value === id) delete object[key]
|
|
329
|
+
else if (Array.isArray(value) && value.includes(id))
|
|
330
|
+
value.splice(value.indexOf(id), 1)
|
|
331
|
+
}
|
|
332
|
+
delete this.table.objects[id]
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// TargetIntegrator.input_output_paths_use_filelist?
|
|
337
|
+
function projectUsesFileLists(project: UserProject): boolean {
|
|
338
|
+
const compatibility = project.table.string(
|
|
339
|
+
project.table.rootObject,
|
|
340
|
+
'compatibilityVersion',
|
|
341
|
+
)
|
|
342
|
+
const version = compatibility?.match(/Xcode ([0-9]*\.[0-9]*)/)?.[1]
|
|
343
|
+
if (!version) return Number.parseInt(project.objectVersion, 10) >= 50
|
|
344
|
+
const [major = 0, minor = 0] = version
|
|
345
|
+
.split('.')
|
|
346
|
+
.map((part) => Number.parseInt(part, 10) || 0)
|
|
347
|
+
return major > 9 || (major === 9 && minor >= 3)
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface FileListKey {
|
|
351
|
+
path: string
|
|
352
|
+
relativePath: string
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
class TargetIntegrator {
|
|
356
|
+
readonly target: AggregateTarget
|
|
357
|
+
readonly nativeTargets: string[]
|
|
358
|
+
readonly fileLists: boolean
|
|
359
|
+
|
|
360
|
+
constructor(
|
|
361
|
+
readonly project: UserProject,
|
|
362
|
+
readonly integration: TargetToIntegrate,
|
|
363
|
+
) {
|
|
364
|
+
this.target = integration.target
|
|
365
|
+
this.nativeTargets = integration.userTargets
|
|
366
|
+
this.fileLists = projectUsesFileLists(project)
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
get table(): PbxTable {
|
|
370
|
+
return this.project.table
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
get requiresHostTarget(): boolean {
|
|
374
|
+
const types = [
|
|
375
|
+
...new Set(this.nativeTargets.map((id) => this.project.symbolType(id))),
|
|
376
|
+
]
|
|
377
|
+
if (types.length !== 1)
|
|
378
|
+
throw new Error(
|
|
379
|
+
`Expected single kind of user_target for ${this.target.name}. Found ${types.join(', ')}.`,
|
|
380
|
+
)
|
|
381
|
+
return EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.includes(types[0] ?? '')
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** a path under the sandbox, as `${PODS_ROOT}` names it. */
|
|
385
|
+
podsRootPath(file: string): string {
|
|
386
|
+
return `\${PODS_ROOT}/${path.relative(this.target.sandbox.root, file)}`
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
integrate(): void {
|
|
390
|
+
this.integrateXcconfigs()
|
|
391
|
+
for (const native of this.nativeTargets)
|
|
392
|
+
this.removeScriptPhase(native, 'Prepare Artifacts')
|
|
393
|
+
this.addPodsLibrary()
|
|
394
|
+
this.addEmbedFrameworksScriptPhase()
|
|
395
|
+
if (this.requiresHostTarget)
|
|
396
|
+
for (const native of this.nativeTargets)
|
|
397
|
+
if (
|
|
398
|
+
EMBED_FRAMEWORKS_IN_HOST_TARGET_TYPES.includes(
|
|
399
|
+
this.project.symbolType(native) ?? '',
|
|
400
|
+
)
|
|
401
|
+
)
|
|
402
|
+
this.removeScriptPhase(native, 'Embed Pods Frameworks')
|
|
403
|
+
this.addCopyResourcesScriptPhase()
|
|
404
|
+
this.addCheckManifestLockScriptPhase()
|
|
405
|
+
for (const native of this.nativeTargets) this.updateUserScriptPhases(native)
|
|
406
|
+
for (const pod of this.target.podTargets)
|
|
407
|
+
for (const accessor of pod.fileAccessors)
|
|
408
|
+
if (Object.keys(accessor.consumer.on_demand_resources).length > 0)
|
|
409
|
+
throw new Error(
|
|
410
|
+
`${pod.label} declares on-demand resources, which Peach does not integrate`,
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// XCConfigIntegrator.integrate
|
|
415
|
+
integrateXcconfigs(): void {
|
|
416
|
+
for (const native of this.nativeTargets)
|
|
417
|
+
for (const config of this.table.configurations(native)) {
|
|
418
|
+
const name = this.table.string(config, 'name') ?? ''
|
|
419
|
+
const ref = this.xcconfigRef(name)
|
|
420
|
+
const existing = this.table.string(config, 'baseConfigurationReference')
|
|
421
|
+
if (existing && existing !== ref) {
|
|
422
|
+
if (this.project.realPath(existing).startsWith(`${this.target.sandbox.root}/`))
|
|
423
|
+
this.table.get(config).baseConfigurationReference = ref
|
|
424
|
+
} else this.table.get(config).baseConfigurationReference = ref
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
xcconfigRef(configuration: string): string {
|
|
429
|
+
const main = this.project.mainGroup
|
|
430
|
+
const group =
|
|
431
|
+
this.project.child(main, 'Pods') ??
|
|
432
|
+
this.project.newGroup(
|
|
433
|
+
main,
|
|
434
|
+
'Pods',
|
|
435
|
+
path.relative(this.target.clientRoot, this.target.sandbox.root),
|
|
436
|
+
)
|
|
437
|
+
const xcconfig = this.target.xcconfigPath(configuration)
|
|
438
|
+
const relative = path.relative(this.project.realPath(group), xcconfig)
|
|
439
|
+
const filename = path.basename(relative)
|
|
440
|
+
const ref = this.project
|
|
441
|
+
.files(group)
|
|
442
|
+
.find((id) => this.project.displayName(id) === filename)
|
|
443
|
+
if (ref && this.table.string(ref, 'path') !== relative) {
|
|
444
|
+
const current = this.project.realPath(ref)
|
|
445
|
+
if (
|
|
446
|
+
!fs.existsSync(current) ||
|
|
447
|
+
!fs.existsSync(xcconfig) ||
|
|
448
|
+
fs.realpathSync(current) !== fs.realpathSync(xcconfig)
|
|
449
|
+
)
|
|
450
|
+
this.table.get(ref).path = relative
|
|
451
|
+
}
|
|
452
|
+
return ref ?? this.project.newFile(group, relative)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
addPodsLibrary(): void {
|
|
456
|
+
const main = this.project.mainGroup
|
|
457
|
+
const frameworks =
|
|
458
|
+
this.project.child(main, 'Frameworks') ?? this.project.newGroup(main, 'Frameworks')
|
|
459
|
+
const productName = this.target.productName
|
|
460
|
+
for (const native of this.nativeTargets) {
|
|
461
|
+
const phase = this.project.phase(native, 'PBXFrameworksBuildPhase')
|
|
462
|
+
for (const file of [...this.table.list(phase, 'files')]) {
|
|
463
|
+
const name = this.buildFileName(file)
|
|
464
|
+
if (!FRAMEWORK_NAMES.test(name) || name === productName) continue
|
|
465
|
+
const ref = this.table.string(file, 'fileRef')
|
|
466
|
+
if (ref)
|
|
467
|
+
this.table
|
|
468
|
+
.list(frameworks, 'children')
|
|
469
|
+
.splice(this.table.list(frameworks, 'children').indexOf(ref), 1)
|
|
470
|
+
this.project.remove(file)
|
|
471
|
+
}
|
|
472
|
+
const ref =
|
|
473
|
+
this.project
|
|
474
|
+
.files(frameworks)
|
|
475
|
+
.find((id) => this.table.string(id, 'path') === productName) ??
|
|
476
|
+
this.newProductRef(frameworks)
|
|
477
|
+
this.project.buildFile(phase, ref)
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
buildFileName(file: string): string {
|
|
482
|
+
const product = this.table.string(file, 'productRef')
|
|
483
|
+
if (product) return this.table.string(product, 'productName') ?? ''
|
|
484
|
+
const ref = this.table.string(file, 'fileRef')
|
|
485
|
+
return ref ? this.project.displayName(ref) : 'BuildFile'
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
// FileReferencesFactory.new_product_ref_for_target
|
|
489
|
+
newProductRef(group: string): string {
|
|
490
|
+
const type = this.target.framework ? 'framework' : 'static_library'
|
|
491
|
+
const name = `${type === 'static_library' ? 'lib' : ''}${this.target.productBasename}.${PRODUCT_UTI_EXTENSIONS[type]}`
|
|
492
|
+
const ref = this.project.newFile(group, name, 'BUILT_PRODUCTS_DIR')
|
|
493
|
+
const object = this.table.get(ref)
|
|
494
|
+
object.includeInIndex = '0'
|
|
495
|
+
delete object.lastKnownFileType
|
|
496
|
+
const explicit = FILE_TYPES_BY_EXTENSION[path.extname(name).slice(1)]
|
|
497
|
+
if (explicit) object.explicitFileType = explicit
|
|
498
|
+
return ref
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
removeScriptPhase(native: string, name: string): void {
|
|
502
|
+
const phase = this.project
|
|
503
|
+
.shellPhases(native)
|
|
504
|
+
.find((id) => this.table.string(id, 'name')?.endsWith(name))
|
|
505
|
+
if (phase)
|
|
506
|
+
this.project.phases(native).splice(this.project.phases(native).indexOf(phase), 1)
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
// TargetIntegrator.create_or_update_shell_script_build_phase
|
|
510
|
+
shellPhase(
|
|
511
|
+
native: string,
|
|
512
|
+
name: string,
|
|
513
|
+
showEnvVarsInLog: string | null = '0',
|
|
514
|
+
): string {
|
|
515
|
+
const found = this.project
|
|
516
|
+
.shellPhases(native)
|
|
517
|
+
.find((id) => this.table.string(id, 'name')?.endsWith(name))
|
|
518
|
+
if (found) {
|
|
519
|
+
this.table.get(found).name = name
|
|
520
|
+
return found
|
|
521
|
+
}
|
|
522
|
+
const phase = this.project.add(`${native}/${name}`, {
|
|
523
|
+
isa: 'PBXShellScriptBuildPhase',
|
|
524
|
+
buildActionMask: '2147483647',
|
|
525
|
+
files: [],
|
|
526
|
+
inputFileListPaths: [],
|
|
527
|
+
inputPaths: [],
|
|
528
|
+
name,
|
|
529
|
+
outputFileListPaths: [],
|
|
530
|
+
outputPaths: [],
|
|
531
|
+
runOnlyForDeploymentPostprocessing: '0',
|
|
532
|
+
shellPath: '/bin/sh',
|
|
533
|
+
shellScript: DEFAULT_SHELL_SCRIPT,
|
|
534
|
+
})
|
|
535
|
+
if (showEnvVarsInLog !== null)
|
|
536
|
+
this.table.get(phase).showEnvVarsInLog = showEnvVarsInLog
|
|
537
|
+
this.project.phases(native).push(phase)
|
|
538
|
+
return phase
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
// TargetIntegrator.set_input_output_paths
|
|
542
|
+
setInputOutputPaths(
|
|
543
|
+
phase: string,
|
|
544
|
+
inputs: Map<FileListKey, string[]>,
|
|
545
|
+
outputs: Map<FileListKey, string[]>,
|
|
546
|
+
): void {
|
|
547
|
+
const object = this.table.get(phase)
|
|
548
|
+
if (this.fileLists) {
|
|
549
|
+
for (const lists of [inputs, outputs])
|
|
550
|
+
for (const [key, files] of lists) {
|
|
551
|
+
const content = files.join('\n')
|
|
552
|
+
if (!fs.existsSync(key.path) || fs.readFileSync(key.path, 'utf8') !== content) {
|
|
553
|
+
fs.mkdirSync(path.dirname(key.path), { recursive: true })
|
|
554
|
+
fs.writeFileSync(key.path, content)
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
delete object.inputPaths
|
|
558
|
+
delete object.outputPaths
|
|
559
|
+
object.inputFileListPaths = [
|
|
560
|
+
...new Set([...inputs.keys()].map((key) => key.relativePath)),
|
|
561
|
+
]
|
|
562
|
+
object.outputFileListPaths = [
|
|
563
|
+
...new Set([...outputs.keys()].map((key) => key.relativePath)),
|
|
564
|
+
]
|
|
565
|
+
return
|
|
566
|
+
}
|
|
567
|
+
let inputPaths = [...new Set([...inputs.values()].flat())]
|
|
568
|
+
let outputPaths = [...new Set([...outputs.values()].flat())]
|
|
569
|
+
if (inputPaths.length + outputPaths.length > MAX_INPUT_OUTPUT_PATHS) {
|
|
570
|
+
inputPaths = []
|
|
571
|
+
outputPaths = []
|
|
572
|
+
}
|
|
573
|
+
object.inputPaths = inputPaths
|
|
574
|
+
object.outputPaths = outputPaths
|
|
575
|
+
delete object.inputFileListPaths
|
|
576
|
+
delete object.outputFileListPaths
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
fileListKey(
|
|
580
|
+
script: 'frameworks' | 'resources',
|
|
581
|
+
kind: 'input' | 'output',
|
|
582
|
+
configuration: string,
|
|
583
|
+
): FileListKey {
|
|
584
|
+
const name = (config: string) =>
|
|
585
|
+
`${this.target.label}-${script}-${config}-${kind}-files.xcfilelist`
|
|
586
|
+
return {
|
|
587
|
+
path: path.join(this.target.supportFilesDir, name(configuration)),
|
|
588
|
+
relativePath: this.podsRootPath(
|
|
589
|
+
path.join(this.target.supportFilesDir, name('${CONFIGURATION}')),
|
|
590
|
+
),
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
addEmbedFrameworksScriptPhase(): void {
|
|
595
|
+
const embedIn = this.requiresHostTarget
|
|
596
|
+
? []
|
|
597
|
+
: this.nativeTargets.filter((id) =>
|
|
598
|
+
EMBED_FRAMEWORK_TARGET_TYPES.includes(this.project.symbolType(id) ?? ''),
|
|
599
|
+
)
|
|
600
|
+
const frameworkPaths = this.target.frameworkPathsByConfig()
|
|
601
|
+
const xcframeworks = this.target.xcframeworksByConfig()
|
|
602
|
+
const dynamicXcframeworks = (config: string) =>
|
|
603
|
+
(xcframeworks.get(config) ?? []).filter(
|
|
604
|
+
(xcf) => xcf.dynamic && xcf.packaging === 'framework',
|
|
605
|
+
)
|
|
606
|
+
const anyDynamicXcframework = [...xcframeworks.keys()].some(
|
|
607
|
+
(config) => dynamicXcframeworks(config).length > 0,
|
|
608
|
+
)
|
|
609
|
+
if (!this.target.includesFrameworks && !anyDynamicXcframework) {
|
|
610
|
+
for (const native of embedIn)
|
|
611
|
+
this.removeScriptPhase(native, 'Embed Pods Frameworks')
|
|
612
|
+
return
|
|
613
|
+
}
|
|
614
|
+
const script = this.podsRootPath(this.target.embedFrameworksScriptPath)
|
|
615
|
+
const inputs = new Map<FileListKey, string[]>()
|
|
616
|
+
const outputs = new Map<FileListKey, string[]>()
|
|
617
|
+
for (const config of [
|
|
618
|
+
...new Set([...frameworkPaths.keys(), ...xcframeworks.keys()]),
|
|
619
|
+
].sort()) {
|
|
620
|
+
const frameworks = frameworkPaths.get(config) ?? []
|
|
621
|
+
const dynamic = dynamicXcframeworks(config)
|
|
622
|
+
inputs.set(this.fileListKey('frameworks', 'input', config), [
|
|
623
|
+
script,
|
|
624
|
+
...frameworks.map((paths) => paths.sourcePath),
|
|
625
|
+
...dynamic.map(
|
|
626
|
+
(xcf) => `${xcframeworkIntermediateDir(xcf)}/${xcf.name}.framework/${xcf.name}`,
|
|
627
|
+
),
|
|
628
|
+
])
|
|
629
|
+
outputs.set(this.fileListKey('frameworks', 'output', config), [
|
|
630
|
+
...new Set(
|
|
631
|
+
frameworks.map(
|
|
632
|
+
(paths) =>
|
|
633
|
+
`\${TARGET_BUILD_DIR}/\${FRAMEWORKS_FOLDER_PATH}/${path.basename(paths.sourcePath)}`,
|
|
634
|
+
),
|
|
635
|
+
),
|
|
636
|
+
...dynamic.map(
|
|
637
|
+
(xcf) =>
|
|
638
|
+
`\${TARGET_BUILD_DIR}/\${FRAMEWORKS_FOLDER_PATH}/${xcf.name}.framework`,
|
|
639
|
+
),
|
|
640
|
+
])
|
|
641
|
+
}
|
|
642
|
+
for (const native of embedIn) {
|
|
643
|
+
const phase = this.shellPhase(native, `${BUILD_PHASE_PREFIX}Embed Pods Frameworks`)
|
|
644
|
+
this.table.get(phase).shellScript = `"${script}"\n`
|
|
645
|
+
this.setInputOutputPaths(phase, inputs, outputs)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
addCopyResourcesScriptPhase(): void {
|
|
650
|
+
if (!this.target.includesResources) {
|
|
651
|
+
for (const native of this.nativeTargets)
|
|
652
|
+
this.removeScriptPhase(native, 'Copy Pods Resources')
|
|
653
|
+
return
|
|
654
|
+
}
|
|
655
|
+
const script = this.podsRootPath(this.target.copyResourcesScriptPath)
|
|
656
|
+
const inputs = new Map<FileListKey, string[]>()
|
|
657
|
+
const outputs = new Map<FileListKey, string[]>()
|
|
658
|
+
for (const [config, resources] of this.target.resourcePathsByConfig()) {
|
|
659
|
+
inputs.set(this.fileListKey('resources', 'input', config), [script, ...resources])
|
|
660
|
+
outputs.set(this.fileListKey('resources', 'output', config), [
|
|
661
|
+
...new Set(
|
|
662
|
+
resources.map((resource) => {
|
|
663
|
+
const extension = path.extname(resource)
|
|
664
|
+
const base = extension === '.xcassets' ? 'Assets' : path.basename(resource)
|
|
665
|
+
return `\${TARGET_BUILD_DIR}/\${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${path.basename(base, extension)}${outputExtensionForResource(extension)}`
|
|
666
|
+
}),
|
|
667
|
+
),
|
|
668
|
+
])
|
|
669
|
+
}
|
|
670
|
+
for (const native of this.nativeTargets) {
|
|
671
|
+
if (this.project.symbolType(native) === 'static_library') continue
|
|
672
|
+
const phase = this.shellPhase(native, `${BUILD_PHASE_PREFIX}Copy Pods Resources`)
|
|
673
|
+
this.table.get(phase).shellScript = `"${script}"\n`
|
|
674
|
+
this.setInputOutputPaths(phase, inputs, outputs)
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
addCheckManifestLockScriptPhase(): void {
|
|
679
|
+
for (const native of this.nativeTargets) {
|
|
680
|
+
const phase = this.shellPhase(
|
|
681
|
+
native,
|
|
682
|
+
`${BUILD_PHASE_PREFIX}Check Pods Manifest.lock`,
|
|
683
|
+
)
|
|
684
|
+
const phases = this.project.phases(native)
|
|
685
|
+
if (phases[0] !== phase) {
|
|
686
|
+
phases.splice(phases.indexOf(phase), 1)
|
|
687
|
+
phases.unshift(phase)
|
|
688
|
+
}
|
|
689
|
+
const object = this.table.get(phase)
|
|
690
|
+
object.shellScript = CHECK_MANIFEST_SCRIPT
|
|
691
|
+
object.inputPaths = [
|
|
692
|
+
'${PODS_PODFILE_DIR_PATH}/Podfile.lock',
|
|
693
|
+
'${PODS_ROOT}/Manifest.lock',
|
|
694
|
+
]
|
|
695
|
+
object.outputPaths = [
|
|
696
|
+
`$(DERIVED_FILE_DIR)/${this.target.label}-checkManifestLockResult.txt`,
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
// TargetIntegrator.create_or_update_user_script_phases
|
|
702
|
+
updateUserScriptPhases(native: string): void {
|
|
703
|
+
const declared = this.integration.scriptPhases
|
|
704
|
+
const names = declared.map((phase) => String(phase.name))
|
|
705
|
+
for (const phase of this.project.shellPhases(native)) {
|
|
706
|
+
const name = this.table.string(phase, 'name')
|
|
707
|
+
if (
|
|
708
|
+
name?.startsWith(USER_BUILD_PHASE_PREFIX) &&
|
|
709
|
+
!names.includes(name.replace(USER_BUILD_PHASE_PREFIX, ''))
|
|
710
|
+
)
|
|
711
|
+
this.project.phases(native).splice(this.project.phases(native).indexOf(phase), 1)
|
|
712
|
+
}
|
|
713
|
+
for (const declaration of declared) {
|
|
714
|
+
const phase = this.shellPhase(
|
|
715
|
+
native,
|
|
716
|
+
`${USER_BUILD_PHASE_PREFIX}${String(declaration.name)}`,
|
|
717
|
+
null,
|
|
718
|
+
)
|
|
719
|
+
const object = this.table.get(phase)
|
|
720
|
+
const set = (key: string, value: PlistValue | null) => {
|
|
721
|
+
if (value === null) delete object[key]
|
|
722
|
+
else object[key] = value
|
|
723
|
+
}
|
|
724
|
+
const text = (key: string) =>
|
|
725
|
+
typeof declaration[key] === 'string' ? declaration[key] : null
|
|
726
|
+
set('shellScript', text('script') ?? '')
|
|
727
|
+
set('shellPath', text('shell_path') ?? '/bin/sh')
|
|
728
|
+
set('inputPaths', stringList(declaration.input_files))
|
|
729
|
+
set('outputPaths', stringList(declaration.output_files))
|
|
730
|
+
set('inputFileListPaths', stringList(declaration.input_file_lists))
|
|
731
|
+
set('outputFileListPaths', stringList(declaration.output_file_lists))
|
|
732
|
+
set('dependencyFile', text('dependency_file'))
|
|
733
|
+
set('alwaysOutOfDate', text('always_out_of_date'))
|
|
734
|
+
if ((text('show_env_vars_in_log') ?? '1') === '0') object.showEnvVarsInLog = '0'
|
|
735
|
+
this.reorderScriptPhase(native, phase, text('execution_position'))
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
reorderScriptPhase(native: string, phase: string, position: string | null): void {
|
|
740
|
+
if (position === null || position === '' || position === 'any') return
|
|
741
|
+
const isa = {
|
|
742
|
+
before_compile: 'PBXSourcesBuildPhase',
|
|
743
|
+
after_compile: 'PBXSourcesBuildPhase',
|
|
744
|
+
before_headers: 'PBXHeadersBuildPhase',
|
|
745
|
+
after_headers: 'PBXHeadersBuildPhase',
|
|
746
|
+
}[position]
|
|
747
|
+
if (!isa) throw new Error(`Unknown execution position \`${position}\``)
|
|
748
|
+
const before = position.startsWith('before_')
|
|
749
|
+
const phases = this.project.phases(native)
|
|
750
|
+
const anchor = phases.findIndex((id) => this.table.get(id).isa === isa)
|
|
751
|
+
if (anchor === -1) return
|
|
752
|
+
const name = this.table.string(phase, 'name')
|
|
753
|
+
const index = phases.findIndex(
|
|
754
|
+
(id) =>
|
|
755
|
+
this.table.get(id).isa === 'PBXShellScriptBuildPhase' &&
|
|
756
|
+
this.table.string(id, 'name') === name,
|
|
757
|
+
)
|
|
758
|
+
if ((before && index > anchor) || (!before && index < anchor)) {
|
|
759
|
+
const [moved] = phases.splice(index, 1)
|
|
760
|
+
phases.splice(anchor, 0, moved!)
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** integrates each Podfile target with its user targets, in name order, as `pod install` does. */
|
|
766
|
+
export function integrateUserTargets(
|
|
767
|
+
project: UserProject,
|
|
768
|
+
targets: TargetToIntegrate[],
|
|
769
|
+
): void {
|
|
770
|
+
for (const integration of [...targets].sort((a, b) =>
|
|
771
|
+
a.target.name < b.target.name ? -1 : a.target.name > b.target.name ? 1 : 0,
|
|
772
|
+
))
|
|
773
|
+
new TargetIntegrator(project, integration).integrate()
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/** whether `file` is a header, which Xcodeproj adds to a target's headers phase. */
|
|
777
|
+
export const isHeader = (file: string): boolean =>
|
|
778
|
+
HEADER_EXTENSIONS.includes(path.extname(file).toLowerCase())
|