-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathPBXFileReference.test.ts
More file actions
739 lines (605 loc) · 22.9 KB
/
PBXFileReference.test.ts
File metadata and controls
739 lines (605 loc) · 22.9 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
import path from "path";
import {
PBXContainerItemProxy,
PBXFileReference,
XcodeProject,
PBXGroup,
PBXBuildFile,
PBXNativeTarget,
} from "..";
const WORKING_FIXTURE = path.join(
__dirname,
"../../json/__tests__/fixtures/AFNetworking.pbxproj"
);
const MULTITARGET_FIXTURE = path.join(
__dirname,
"../../json/__tests__/fixtures/project-multitarget.pbxproj"
);
const WATCH_FIXTURE = path.join(
__dirname,
"../../json/__tests__/fixtures/watch.pbxproj"
);
describe("PBXFileReference", () => {
describe("creation and UUIDs", () => {
it("adds deterministic UUIDs without collision", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
// @ts-expect-error: Prove that adding a random UUID to the project doesn't change the UUIDs of other objects
xcproj.set(Math.random().toString(), {});
const containerItemProxy = PBXContainerItemProxy.create(xcproj, {
containerPortal: xcproj.rootObject,
proxyType: 1,
remoteGlobalIDString: "xxx",
remoteInfo: "xxx",
});
expect(containerItemProxy.uuid).toBe("XX6D16E1EEB44DF363DCC9XX");
const ref = PBXFileReference.create(xcproj, {
path: "a.swift",
});
expect(ref.uuid).toBe("XXDBE740AD7C410FE2DF44XX");
expect(
PBXFileReference.create(xcproj, {
path: "a.swift",
}).uuid
).toBe("XX5BBE738DD91F7523452AXX");
});
it("should create file reference with minimal options", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "TestFile.swift",
});
expect(ref).toBeDefined();
expect(ref.props.path).toBe("TestFile.swift");
expect(ref.props.isa).toBe("PBXFileReference");
});
});
describe("setupDefaults", () => {
it("adds framework file with correct defaults for name", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "System/Library/Frameworks/SwiftUI.framework",
});
expect(ref.uuid).toBe("XX4DFF38D47332D6BF0183XX");
expect(ref.props).toEqual({
isa: "PBXFileReference",
name: "SwiftUI.framework",
path: "System/Library/Frameworks/SwiftUI.framework",
lastKnownFileType: "wrapper.framework",
sourceTree: "SDKROOT",
});
});
// Note: fileEncoding and includeInIndex are no longer set by default
// to avoid adding properties when round-tripping projects.
// Users can set these explicitly if needed.
it("should not set fileEncoding by default", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
expect(ref.props.fileEncoding).toBeUndefined();
});
it("should not set includeInIndex by default", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
expect(ref.props.includeInIndex).toBeUndefined();
});
it("should set name from path basename when different", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "folder/subfolder/test.swift",
});
expect(ref.props.name).toBe("test.swift");
});
it("should not set name when same as path", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
// When path basename equals path, name should NOT be set (this is the actual behavior)
expect(ref.props.name).toBeUndefined();
});
});
describe("file type detection", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
it("adds swift file", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky.swift",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
lastKnownFileType: "sourcecode.swift",
name: "funky.swift",
path: "fun/funky.swift",
sourceTree: "<group>",
});
});
it("adds css file", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky.css",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
lastKnownFileType: "text.css",
name: "funky.css",
path: "fun/funky.css",
sourceTree: "<group>",
});
});
it("adds html file", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky.html",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
lastKnownFileType: "text.html",
name: "funky.html",
path: "fun/funky.html",
sourceTree: "<group>",
});
});
it("adds json file", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky.json",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
lastKnownFileType: "text.json",
name: "funky.json",
path: "fun/funky.json",
sourceTree: "<group>",
});
});
it("adds js file", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky.js",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
lastKnownFileType: "sourcecode.javascript",
name: "funky.js",
path: "fun/funky.js",
sourceTree: "<group>",
});
});
it("adds random file without extension", () => {
const ref = PBXFileReference.create(xcproj, {
path: "fun/funky",
});
expect(ref.props).toEqual({
isa: "PBXFileReference",
name: "funky",
path: "fun/funky",
sourceTree: "<group>",
});
});
it("should handle .m Objective-C files", () => {
const ref = PBXFileReference.create(xcproj, {
path: "TestFile.m",
});
expect(ref.props.lastKnownFileType).toBe("sourcecode.c.objc");
});
it("should handle .h header files", () => {
const ref = PBXFileReference.create(xcproj, {
path: "TestFile.h",
});
expect(ref.props.lastKnownFileType).toBe("sourcecode.c.h");
});
});
describe("setLastKnownFileType", () => {
it("should set file type manually", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.unknown",
});
ref.setLastKnownFileType("sourcecode.swift");
expect(ref.props.lastKnownFileType).toBe("sourcecode.swift");
});
it("should detect file type from extension", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.unknown",
});
// Clear the automatically set type
ref.props.lastKnownFileType = undefined;
// Change path and detect type
ref.props.path = "test.swift";
ref.setLastKnownFileType();
expect(ref.props.lastKnownFileType).toBe("sourcecode.swift");
});
it("should handle files without extensions", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "README",
});
ref.setLastKnownFileType();
expect(ref.props.lastKnownFileType).toBeUndefined();
});
});
describe("setExplicitFileType", () => {
it("should set explicit file type manually", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
ref.setExplicitFileType("wrapper.application");
expect(ref.props.explicitFileType).toBe("wrapper.application");
expect(ref.props.lastKnownFileType).toBeUndefined();
});
it("should detect explicit file type from extension", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.app",
});
ref.setExplicitFileType();
expect(ref.props.explicitFileType).toBe("wrapper.application");
expect(ref.props.lastKnownFileType).toBeUndefined();
});
it("should clear lastKnownFileType when explicitFileType is set", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
expect(ref.props.lastKnownFileType).toBe("sourcecode.swift");
ref.setExplicitFileType("wrapper.application");
expect(ref.props.explicitFileType).toBe("wrapper.application");
expect(ref.props.lastKnownFileType).toBeUndefined();
});
});
describe("getDisplayName", () => {
it("should return name property when set", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "folder/test.swift",
name: "CustomName.swift",
});
expect(ref.getDisplayName()).toBe("CustomName.swift");
});
it("should return path for BUILT_PRODUCTS_DIR", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyApp.app",
sourceTree: "BUILT_PRODUCTS_DIR",
});
expect(ref.getDisplayName()).toBe("MyApp.app");
});
it("should return basename of path when no name", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "folder/subfolder/test.swift",
});
// Remove name to test fallback
ref.props.name = undefined;
expect(ref.getDisplayName()).toBe("test.swift");
});
it("should return fallback ISA name when no path or name", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
// Remove both name and path
ref.props.name = undefined;
ref.props.path = undefined;
expect(ref.getDisplayName()).toBe("FileReference");
});
});
describe("path management", () => {
it("should get parent group", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "test.swift",
});
const parent = ref.getParent();
expect(parent).toBe(mainGroup);
});
it("should get all parents", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const subGroup = mainGroup.createGroup({
name: "SubGroup",
sourceTree: "<group>",
});
const ref = subGroup.createFile({
path: "test.swift",
});
const parents = ref.getParents();
expect(parents).toContain(subGroup);
expect(parents).toContain(mainGroup);
});
it("should move to different parent", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const group1 = mainGroup.createGroup({
name: "Group1",
sourceTree: "<group>",
});
const group2 = mainGroup.createGroup({
name: "Group2",
sourceTree: "<group>",
});
const ref = group1.createFile({
path: "test.swift",
});
expect(ref.getParent()).toBe(group1);
ref.move(group2);
expect(ref.getParent()).toBe(group2);
expect(group1.props.children).not.toContain(ref);
expect(group2.props.children).toContain(ref);
});
it("should set path with source tree", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "test.swift",
});
ref.setPath("new/path/test.swift");
// The setPath method resolves paths to absolute paths for most source trees
expect(ref.props.path).toContain("new/path/test.swift");
});
it("should clear path when undefined", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
ref.setPath(undefined);
expect(ref.props.path).toBeUndefined();
});
});
describe("getBuildFiles", () => {
it("should return build files that reference this file", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const target = xcproj.rootObject.getMainAppTarget();
expect(target).toBeDefined();
// Create a file reference
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "TestFile.swift",
});
// Add it to sources build phase
const sourcesPhase = target!.getSourcesBuildPhase();
const buildFile = sourcesPhase.ensureFile({ fileRef: ref });
const buildFiles = ref.getBuildFiles();
expect(buildFiles).toContain(buildFile);
expect(buildFiles.length).toBeGreaterThan(0);
});
it("should return empty array for files not in build phases", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "UnusedFile.swift",
});
const buildFiles = ref.getBuildFiles();
expect(buildFiles).toEqual([]);
});
});
describe("getTargetReferrers", () => {
it("should return targets that reference this file as product", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const target = xcproj.rootObject.getMainAppTarget();
expect(target).toBeDefined();
if (target!.props.productReference) {
const productRef = target!.props.productReference;
const targetReferrers = productRef.getTargetReferrers();
expect(targetReferrers).toContain(target);
}
});
it("should return empty array for non-product files", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "RegularFile.swift",
});
const targetReferrers = ref.getTargetReferrers();
expect(targetReferrers).toEqual([]);
});
});
describe("isAppExtension", () => {
it("should return true for app extension files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyExtension.appex",
lastKnownFileType: "wrapper.app-extension",
sourceTree: "BUILT_PRODUCTS_DIR",
});
expect(ref.isAppExtension()).toBe(true);
});
it("should return true for ExtensionKit extension files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyExtension.appex",
lastKnownFileType: "wrapper.extensionkit-extension",
sourceTree: "BUILT_PRODUCTS_DIR",
});
expect(ref.isAppExtension()).toBe(true);
});
it("should return true for explicit file type app extensions", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyExtension.appex",
explicitFileType: "wrapper.app-extension",
sourceTree: "BUILT_PRODUCTS_DIR",
});
expect(ref.isAppExtension()).toBe(true);
});
it("should return false for app extension files not in BUILT_PRODUCTS_DIR", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyExtension.appex",
lastKnownFileType: "wrapper.app-extension",
sourceTree: "<group>",
});
expect(ref.isAppExtension()).toBe(false);
});
it("should return false for regular application files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyApp.app",
lastKnownFileType: "wrapper.application",
sourceTree: "BUILT_PRODUCTS_DIR",
});
expect(ref.isAppExtension()).toBe(false);
});
it("should return false for source files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
lastKnownFileType: "sourcecode.swift",
sourceTree: "<group>",
});
expect(ref.isAppExtension()).toBe(false);
});
});
describe("proxy and container methods", () => {
it("should return empty array for getProxyContainers on regular files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
const containers = ref.getProxyContainers();
expect(containers).toEqual([]);
});
it("should return empty array for getTargetDependencyProxies on regular files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
const proxies = ref.getTargetDependencyProxies();
expect(proxies).toEqual([]);
});
it("should return empty array for getFileReferenceProxies on regular files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "test.swift",
});
const proxies = ref.getFileReferenceProxies();
expect(proxies).toEqual([]);
});
});
describe("removeFromProject", () => {
it("should remove file and all related build files", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const target = xcproj.rootObject.getMainAppTarget();
expect(target).toBeDefined();
// Create a file reference and add to build phase
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "ToBeRemoved.swift",
});
const sourcesPhase = target!.getSourcesBuildPhase();
const buildFile = sourcesPhase.ensureFile({ fileRef: ref });
expect(sourcesPhase.props.files).toContain(buildFile);
expect(mainGroup.props.children).toContain(ref);
// Store the build file UUID for checking
const buildFileUuid = buildFile.uuid;
// Remove the file reference
ref.removeFromProject();
// Should be removed from group
expect(mainGroup.props.children).not.toContain(ref);
// Check that build file is removed from the project entirely
expect(xcproj.get(buildFileUuid)).toBeUndefined();
});
it("should remove file without build files", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "UnusedFile.swift",
});
expect(mainGroup.props.children).toContain(ref);
ref.removeFromProject();
expect(mainGroup.props.children).not.toContain(ref);
});
});
describe("source tree handling", () => {
it("should use SDKROOT for system frameworks", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "System/Library/Frameworks/UIKit.framework",
});
expect(ref.props.sourceTree).toBe("SDKROOT");
});
it("should use <group> for regular source files", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "ViewController.swift",
});
expect(ref.props.sourceTree).toBe("<group>");
});
it("should use BUILT_PRODUCTS_DIR for explicit file type", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const ref = PBXFileReference.create(xcproj, {
path: "MyApp.app",
explicitFileType: "wrapper.application",
});
expect(ref.props.sourceTree).toBe("BUILT_PRODUCTS_DIR");
});
});
describe("integration tests", () => {
it("should handle complete file lifecycle", () => {
const xcproj = XcodeProject.open(MULTITARGET_FIXTURE);
const target = xcproj.rootObject.getMainAppTarget();
const mainGroup = xcproj.rootObject.props.mainGroup;
// Create file
const ref = mainGroup.createFile({
path: "CompleteTest.swift",
});
// Verify creation
expect(ref.getDisplayName()).toBe("CompleteTest.swift");
expect(ref.props.lastKnownFileType).toBe("sourcecode.swift");
expect(ref.getParent()).toBe(mainGroup);
// Add to build phase
const sourcesPhase = target!.getSourcesBuildPhase();
sourcesPhase.ensureFile({ fileRef: ref });
// Verify it's in build files
expect(ref.getBuildFiles().length).toBeGreaterThan(0);
// Move to different group
const newGroup = mainGroup.createGroup({
name: "NewGroup",
sourceTree: "<group>",
});
ref.move(newGroup);
expect(ref.getParent()).toBe(newGroup);
// Modify file type
ref.setLastKnownFileType("text.json");
expect(ref.props.lastKnownFileType).toBe("text.json");
// Remove from project
ref.removeFromProject();
expect(newGroup.props.children).not.toContain(ref);
});
it("should work across different project fixtures", () => {
const fixtures = [WORKING_FIXTURE, MULTITARGET_FIXTURE, WATCH_FIXTURE];
fixtures.forEach((fixture) => {
const xcproj = XcodeProject.open(fixture);
// Create a test file in each project
const mainGroup = xcproj.rootObject.props.mainGroup;
const ref = mainGroup.createFile({
path: "CrossProjectTest.swift",
});
// Basic functionality should work
expect(ref.getDisplayName()).toBe("CrossProjectTest.swift");
expect(ref.props.lastKnownFileType).toBe("sourcecode.swift");
expect(ref.getParent()).toBe(mainGroup);
expect(typeof ref.isAppExtension()).toBe("boolean");
expect(Array.isArray(ref.getBuildFiles())).toBe(true);
expect(Array.isArray(ref.getTargetReferrers())).toBe(true);
});
});
it("should handle different file types properly", () => {
const xcproj = XcodeProject.open(WORKING_FIXTURE);
const fileTypes = [
{ path: "test.swift", expectedType: "sourcecode.swift" },
{ path: "test.m", expectedType: "sourcecode.c.objc" },
{ path: "test.h", expectedType: "sourcecode.c.h" },
{ path: "test.js", expectedType: "sourcecode.javascript" },
{ path: "test.css", expectedType: "text.css" },
{ path: "test.html", expectedType: "text.html" },
{ path: "test.json", expectedType: "text.json" },
{ path: "TestFramework.framework", expectedType: "wrapper.framework" },
];
fileTypes.forEach(({ path, expectedType }) => {
const ref = PBXFileReference.create(xcproj, { path });
expect(ref.props.lastKnownFileType).toBe(expectedType);
});
});
});
});