-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPBXBuildFile.ts
More file actions
77 lines (68 loc) · 2.19 KB
/
PBXBuildFile.ts
File metadata and controls
77 lines (68 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import * as json from "../json/types";
import { AbstractObject } from "./AbstractObject";
import type { PickRequired, SansIsa } from "./utils/util.types";
import type { PBXGroup } from "./AbstractGroup";
import type { XcodeProject } from "./XcodeProject";
import type { PBXFileReference } from "./PBXFileReference";
import type { PBXReferenceProxy } from "./PBXReferenceProxy";
import type { PBXVariantGroup } from "./PBXVariantGroup";
import type { XCSwiftPackageProductDependency } from "./XCSwiftPackageProductDependency";
import type { XCVersionGroup } from "./XCVersionGroup";
export type PBXBuildFileModel = json.PBXBuildFile<
| PBXFileReference
| PBXGroup
| PBXVariantGroup
| XCVersionGroup
| PBXReferenceProxy,
XCSwiftPackageProductDependency
>;
export class PBXBuildFile extends AbstractObject<PBXBuildFileModel> {
static isa = json.ISA.PBXBuildFile as const;
static is(object: any): object is PBXBuildFile {
return object.isa === PBXBuildFile.isa;
}
/**
* Creates a PBXBuildFile with a fileRef for source files, resources, etc.
*/
static create(
project: XcodeProject,
opts: PickRequired<SansIsa<PBXBuildFileModel>, "fileRef">
) {
return project.createModel<PBXBuildFileModel>({
isa: PBXBuildFile.isa,
...opts,
}) as PBXBuildFile;
}
/**
* Creates a PBXBuildFile with a productRef for Swift Package dependencies.
* Use this instead of `create()` when linking a Swift Package product.
*/
static createFromProductRef(
project: XcodeProject,
opts: PickRequired<SansIsa<PBXBuildFileModel>, "productRef">
) {
return project.createModel<PBXBuildFileModel>({
isa: PBXBuildFile.isa,
...opts,
} as PBXBuildFileModel) as PBXBuildFile;
}
protected getObjectProps() {
return {
fileRef: String,
productRef: String,
};
}
isReferencing(uuid: string): boolean {
return [this.props.fileRef?.uuid, this.props.productRef?.uuid].includes(
uuid
);
}
getDisplayName() {
if (this.props.productRef) {
return this.props.productRef.getDisplayName();
} else if (this.props.fileRef) {
return this.props.fileRef.getDisplayName();
}
return super.getDisplayName();
}
}