Skip to content

Commit 02212a9

Browse files
committed
chore: patches until PRs merged
1 parent ea84aee commit 02212a9

2 files changed

Lines changed: 248 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
diff --git a/dist/ios/spm.js b/dist/ios/spm.js
2+
index 1c1e4af26c2475d803f5c5eaaa957b333d0453df..bba232f88674ee831bcf678a22b24c4a727107c6 100644
3+
--- a/dist/ios/spm.js
4+
+++ b/dist/ios/spm.js
5+
@@ -138,14 +138,14 @@ function addSPMPackageToProject(project, targetId, pkg, projectRoot) {
6+
comment: packageReferenceComment,
7+
});
8+
for (const lib of pkg.libs) {
9+
- const { uuid: spmProductDependencyUUID } = helper.addOrUpdateEntry('XCSwiftPackageProductDependency', lib, {
10+
+ const { uuid: spmProductDependencyUUID } = helper.addEntry('XCSwiftPackageProductDependency', lib, {
11+
isa: 'XCSwiftPackageProductDependency',
12+
package: spmPackageReferenceUUID,
13+
package_comment: spmPackageReferenceComment,
14+
productName: lib,
15+
});
16+
const libComment = `${lib} in Frameworks`;
17+
- const { uuid: spmBuildFileUuid } = helper.addOrUpdateEntry('PBXBuildFile', libComment, {
18+
+ const { uuid: spmBuildFileUuid } = helper.addEntry('PBXBuildFile', libComment, {
19+
isa: 'PBXBuildFile',
20+
productRef: spmProductDependencyUUID,
21+
productRef_comment: lib,
22+
@@ -184,6 +184,17 @@ class SPMHelper {
23+
comment: entryComment,
24+
};
25+
}
26+
+ addEntry(section, entryComment, entry) {
27+
+ const pbxSection = this.getOrCreateSection(section);
28+
+ const entryUuid = this.pbxProject.generateUuid();
29+
+ const entryCommentKey = `${entryUuid}_comment`;
30+
+ pbxSection[entryCommentKey] = entryComment;
31+
+ pbxSection[entryUuid] = entry;
32+
+ return {
33+
+ uuid: entryUuid,
34+
+ comment: entryComment,
35+
+ };
36+
+ }
37+
getExistingOrGenerateUUID(section, comment) {
38+
var _a;
39+
const existingUUID = (_a = Object.keys(this.pbxProject.hash.project.objects[section])
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
diff --git a/lib/pbxFile.js b/lib/pbxFile.js
2+
index 1b52d259bc4b5b3dcf935cb3f8c2f789bb5ddbc7..1c140853dd05dc94681b53bc02c7aa54a702603a 100644
3+
--- a/lib/pbxFile.js
4+
+++ b/lib/pbxFile.js
5+
@@ -128,9 +128,9 @@ function pbxFile(filepath, opt) {
6+
if (opt.explicitFileType) {
7+
this.explicitFileType = opt.explicitFileType;
8+
this.basename = this.basename + '.' + defaultExtension(this);
9+
- delete this.path;
10+
+ // delete this.path;
11+
delete this.lastKnownFileType;
12+
- delete this.group;
13+
+ // delete this.group;
14+
delete this.defaultEncoding;
15+
}
16+
17+
diff --git a/lib/pbxProject.js b/lib/pbxProject.js
18+
index 70f82ea1a1c41de3ea18b66e4d89584c16a79e88..aa0096f47d9111c7d6e0abdaf5749348cd3da8f1 100644
19+
--- a/lib/pbxProject.js
20+
+++ b/lib/pbxProject.js
21+
@@ -119,8 +119,8 @@ pbxProject.prototype.addPluginFile = function(path, opt) {
22+
file.plugin = true; // durr
23+
correctForPluginsPath(file, this);
24+
25+
- // null is better for early errors
26+
- if (this.hasFile(file.path)) return null;
27+
+ const existingFile = this.hasFile(file.path);
28+
+ if (existingFile) return file;
29+
30+
file.fileRef = this.generateUuid();
31+
32+
@@ -184,8 +184,9 @@ pbxProject.prototype.addSourceFile = function (path, opt, group) {
33+
34+
file.target = opt ? opt.target : undefined;
35+
file.uuid = this.generateUuid();
36+
-
37+
- this.addToPbxBuildFileSection(file); // PBXBuildFile
38+
+ if(file.fileRef) {
39+
+ this.addToPbxBuildFileSection(file); // PBXBuildFile
40+
+ }
41+
this.addToPbxSourcesBuildPhase(file); // PBXSourcesBuildPhase
42+
43+
return file;
44+
@@ -256,19 +257,23 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
45+
opt = opt || {};
46+
47+
var file;
48+
-
49+
+ var fileIsAlreadyAdded = false;
50+
if (opt.plugin) {
51+
file = this.addPluginFile(path, opt);
52+
if (!file) return false;
53+
} else {
54+
file = new pbxFile(path, opt);
55+
- if (this.hasFile(file.path)) return false;
56+
+ const existingFile = this.hasFile(file.path);
57+
+ fileIsAlreadyAdded = !!existingFile;
58+
+ if (existingFile) {
59+
+ file.fileRef = existingFile.fileRef;
60+
+ }
61+
}
62+
63+
file.uuid = this.generateUuid();
64+
file.target = opt ? opt.target : undefined;
65+
66+
- if (!opt.plugin) {
67+
+ if (!opt.plugin && !fileIsAlreadyAdded) {
68+
correctForResourcesPath(file, this);
69+
file.fileRef = this.generateUuid();
70+
}
71+
@@ -278,7 +283,7 @@ pbxProject.prototype.addResourceFile = function(path, opt, group) {
72+
this.addToPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
73+
}
74+
75+
- if (!opt.plugin) {
76+
+ if (!opt.plugin && !fileIsAlreadyAdded) {
77+
this.addToPbxFileReferenceSection(file); // PBXFileReference
78+
if (group) {
79+
if (this.getPBXGroupByKey(group)) {
80+
@@ -859,20 +864,20 @@ pbxProject.prototype.removeFromPluginsPbxGroup = function(file) {
81+
}
82+
}
83+
84+
-pbxProject.prototype.addToResourcesPbxGroup = function(file) {
85+
- var pluginsGroup = this.pbxGroupByName('Resources');
86+
+pbxProject.prototype.addToResourcesPbxGroup = function(file, groupName = 'Resources') {
87+
+ var pluginsGroup = this.pbxGroupByName(groupName);
88+
if (!pluginsGroup) {
89+
- this.addPbxGroup([file.path], 'Resources');
90+
+ this.addPbxGroup([file.path], groupName);
91+
} else {
92+
pluginsGroup.children.push(pbxGroupChild(file));
93+
}
94+
}
95+
96+
-pbxProject.prototype.removeFromResourcesPbxGroup = function(file) {
97+
- if (!this.pbxGroupByName('Resources')) {
98+
+pbxProject.prototype.removeFromResourcesPbxGroup = function(file, groupName = 'Resources') {
99+
+ if (!this.pbxGroupByName(groupName)) {
100+
return null;
101+
}
102+
- var pluginsGroupChildren = this.pbxGroupByName('Resources').children, i;
103+
+ var pluginsGroupChildren = this.pbxGroupByName(groupName).children, i;
104+
for (i in pluginsGroupChildren) {
105+
if (pbxGroupChild(file).value == pluginsGroupChildren[i].value &&
106+
pbxGroupChild(file).comment == pluginsGroupChildren[i].comment) {
107+
@@ -916,6 +921,7 @@ function getReferenceInPbxBuildFile(buildFileReferences, fileReference) {
108+
}
109+
110+
pbxProject.prototype.addToPbxEmbedFrameworksBuildPhase = function (file) {
111+
+ console.error('addToPbxEmbedFrameworksBuildPhase', JSON.stringify(file));
112+
var sources = this.pbxEmbedFrameworksBuildPhaseObj(file.target);
113+
114+
if (sources) {
115+
@@ -1363,7 +1369,6 @@ pbxProject.prototype.buildPhaseObject = function(name, group, target) {
116+
var section = this.hash.project.objects[name],
117+
obj, sectionKey, key;
118+
var buildPhase = this.buildPhase(group, target);
119+
-
120+
for (key in section) {
121+
122+
// only look for comments
123+
@@ -1680,7 +1685,7 @@ pbxProject.prototype.hasFile = function(filePath) {
124+
for (id in files) {
125+
file = files[id];
126+
if (file.path == filePath || file.path == ('"' + filePath + '"')) {
127+
- return file;
128+
+ return {...file, fileRef: id};
129+
}
130+
}
131+
132+
@@ -1700,11 +1705,21 @@ pbxProject.prototype.getFileKey = function(filePath) {
133+
return false;
134+
}
135+
136+
-pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
137+
+pbxProject.prototype.getProductFile = function(target) {
138+
+ var productReferenceUuid = target.pbxNativeTarget.productReference;
139+
+ const fileReferenceSection = this.pbxFileReferenceSection();
140+
+ const productReference = fileReferenceSection[productReferenceUuid];
141+
+ const productFile = new pbxFile(productReference.path);
142+
+ productFile.fileRef = productReferenceUuid;
143+
+ productFile.uuid = productReferenceUuid;
144+
+ return productFile;
145+
+}
146+
+pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget, productTargetType) {
147+
148+
// Setup uuid and name of new target
149+
var targetUuid = this.generateUuid(),
150+
targetType = type,
151+
+ productTargetType = productTargetType || targetType,
152+
targetSubfolder = subfolder || name,
153+
targetName = name.trim();
154+
155+
@@ -1753,7 +1768,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
156+
157+
// Product: Create
158+
var productName = targetName,
159+
- productType = producttypeForTargettype(targetType),
160+
+ productType = producttypeForTargettype(productTargetType),
161+
productFileType = filetypeForProducttype(productType),
162+
productFile = this.addProductFile(productName, { group: 'Copy Files', 'target': targetUuid, 'explicitFileType': productFileType}),
163+
productFileName = productFile.basename;
164+
@@ -1781,10 +1796,10 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
165+
// Target: Add to PBXNativeTarget section
166+
this.addToPbxNativeTargetSection(target);
167+
168+
- if (targetType === 'app_extension' || targetType === 'watch_extension' || targetType === 'watch_app') {
169+
- const isWatchApp = targetType === 'watch_app';
170+
+ if (productTargetType === 'app_extension' || productTargetType === 'watch_extension' || productTargetType === 'watch_app') {
171+
+ const isWatchApp = productTargetType === 'watch_app';
172+
const copyTargetUuid = parentTarget || this.getFirstTarget().uuid;
173+
- const phaseComment = targetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files';
174+
+ const phaseComment = productTargetType === 'watch_app' ? 'Embed Watch Content' : 'Copy Files';
175+
let destination;
176+
177+
if(isWatchApp) {
178+
@@ -1792,7 +1807,7 @@ pbxProject.prototype.addTarget = function(name, type, subfolder, parentTarget) {
179+
}
180+
181+
// Create CopyFiles phase in parent target
182+
- this.addBuildPhase([], 'PBXCopyFilesBuildPhase', phaseComment, copyTargetUuid, targetType, destination);
183+
+ this.addBuildPhase([], 'PBXCopyFilesBuildPhase', phaseComment, copyTargetUuid, productTargetType, destination);
184+
185+
// Add product to CopyFiles phase
186+
this.addToPbxCopyfilesBuildPhase(productFile, phaseComment, copyTargetUuid);
187+
@@ -2058,7 +2073,7 @@ function pbxFileReferenceObj(file) {
188+
fileObject.name = "\"" + fileObject.name + "\"";
189+
}
190+
191+
- if(!file.path.match(NO_SPECIAL_SYMBOLS)) {
192+
+ if(file.path && !file.path.match(NO_SPECIAL_SYMBOLS)) {
193+
fileObject.path = "\"" + fileObject.path + "\"";
194+
}
195+
196+
@@ -2525,10 +2540,11 @@ pbxProject.prototype.getPBXObject = function(name) {
197+
pbxProject.prototype.addFile = function (path, group, opt) {
198+
var file = new pbxFile(path, opt);
199+
200+
- // null is better for early errors
201+
- if (this.hasFile(file.path)) return null;
202+
+ const existingFile = this.hasFile(file.path);
203+
+ if (existingFile) return {...file, fileRef: existingFile.fileRef};
204+
205+
file.fileRef = this.generateUuid();
206+
+ file.target = opt ? opt.target : undefined;
207+
208+
this.addToPbxFileReferenceSection(file); // PBXFileReference
209+

0 commit comments

Comments
 (0)