Commit 46b6453
Fix the Redefinition of 'NativeXXXSpecJSI' error with Frameworks (#44005)
Summary:
Pull Request resolved: #44005
When using frameworks on iOS, there is a possibility that modules import the Spec.h file twice and this might end up in a Redefinition of some symbols and duplication of symbols which ends up in build errors, as reported here: #42670.
This change adds some [`#include guards`](https://en.wikipedia.org/wiki/Include_guard) in codegen to avoid the redefinition of those symbols if the header is imported/included multiple times.
Note: I also experimented with `#pragma once`, but it looks like Apple is not happy with that directive. [It seems](https://forums.developer.apple.com/forums/thread/739964) that it started working flakely from Xcode 15.
## Changelog:
[General][Fixed] - Make sure that we can't include Codegen symbols multiple times
Reviewed By: cortinico
Differential Revision: D55925605
fbshipit-source-id: 15ca076aace2ffbd03ab8fa8a68a3d8ce0d1ea651 parent 9433506 commit 46b6453
3 files changed
Lines changed: 82 additions & 7 deletions
File tree
- packages/react-native-codegen
- e2e/__tests__/modules/__snapshots__
- src/generators/modules
- GenerateModuleObjCpp
- __tests__/__snapshots__
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
1341 | 1346 | | |
1342 | 1347 | | |
1343 | 1348 | | |
| 1349 | + | |
1344 | 1350 | | |
1345 | 1351 | | |
1346 | 1352 | | |
| |||
1361 | 1367 | | |
1362 | 1368 | | |
1363 | 1369 | | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1364 | 1375 | | |
1365 | 1376 | | |
1366 | 1377 | | |
| |||
2688 | 2699 | | |
2689 | 2700 | | |
2690 | 2701 | | |
| 2702 | + | |
2691 | 2703 | | |
2692 | 2704 | | |
2693 | 2705 | | |
| |||
Lines changed: 22 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | | - | |
57 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
| |||
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
73 | 83 | | |
74 | 84 | | |
75 | 85 | | |
| |||
82 | 92 | | |
83 | 93 | | |
84 | 94 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
90 | 104 | | |
91 | 105 | | |
92 | 106 | | |
| |||
197 | 211 | | |
198 | 212 | | |
199 | 213 | | |
| 214 | + | |
200 | 215 | | |
201 | 216 | | |
202 | 217 | | |
| |||
Lines changed: 48 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
45 | 50 | | |
46 | 51 | | |
47 | 52 | | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
67 | 73 | | |
68 | 74 | | |
69 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
70 | 81 | | |
71 | 82 | | |
72 | 83 | | |
| |||
304 | 315 | | |
305 | 316 | | |
306 | 317 | | |
| 318 | + | |
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
| |||
326 | 338 | | |
327 | 339 | | |
328 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
329 | 346 | | |
330 | 347 | | |
331 | 348 | | |
| |||
339 | 356 | | |
340 | 357 | | |
341 | 358 | | |
| 359 | + | |
342 | 360 | | |
343 | 361 | | |
344 | 362 | | |
| |||
361 | 379 | | |
362 | 380 | | |
363 | 381 | | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
364 | 387 | | |
365 | 388 | | |
366 | 389 | | |
| |||
388 | 411 | | |
389 | 412 | | |
390 | 413 | | |
| 414 | + | |
391 | 415 | | |
392 | 416 | | |
393 | 417 | | |
| |||
410 | 434 | | |
411 | 435 | | |
412 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
413 | 442 | | |
414 | 443 | | |
415 | 444 | | |
| |||
557 | 586 | | |
558 | 587 | | |
559 | 588 | | |
| 589 | + | |
560 | 590 | | |
561 | 591 | | |
562 | 592 | | |
| |||
579 | 609 | | |
580 | 610 | | |
581 | 611 | | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
582 | 617 | | |
583 | 618 | | |
584 | 619 | | |
| |||
799 | 834 | | |
800 | 835 | | |
801 | 836 | | |
| 837 | + | |
802 | 838 | | |
803 | 839 | | |
804 | 840 | | |
| |||
821 | 857 | | |
822 | 858 | | |
823 | 859 | | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
824 | 865 | | |
825 | 866 | | |
826 | 867 | | |
| |||
910 | 951 | | |
911 | 952 | | |
912 | 953 | | |
| 954 | + | |
913 | 955 | | |
914 | 956 | | |
915 | 957 | | |
| |||
932 | 974 | | |
933 | 975 | | |
934 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
935 | 982 | | |
936 | 983 | | |
937 | 984 | | |
| |||
975 | 1022 | | |
976 | 1023 | | |
977 | 1024 | | |
| 1025 | + | |
978 | 1026 | | |
979 | 1027 | | |
980 | 1028 | | |
0 commit comments