Skip to content

Commit 895ceb8

Browse files
authored
fix: visionos overrides for build flags (#5967)
1 parent f243b5d commit 895ceb8

File tree

5 files changed

+118
-93
lines changed

5 files changed

+118
-93
lines changed

lib/services/ios-entitlements-service.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class IOSEntitlementsService {
1313
private $logger: ILogger,
1414
private $devicePlatformsConstants: Mobile.IDevicePlatformsConstants,
1515
private $mobileHelper: Mobile.IMobileHelper,
16-
private $pluginsService: IPluginsService
16+
private $pluginsService: IPluginsService,
1717
) {}
1818

1919
public static readonly DefaultEntitlementsName: string = "app.entitlements";
@@ -23,28 +23,31 @@ export class IOSEntitlementsService {
2323
const entitlementsPath = path.join(
2424
projectData.appResourcesDirectoryPath,
2525
this.$mobileHelper.normalizePlatformName(
26-
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS
26+
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
2727
),
28-
entitlementsName
28+
entitlementsName,
2929
);
3030
return entitlementsPath;
3131
}
3232

3333
public getPlatformsEntitlementsPath(projectData: IProjectData): string {
3434
return path.join(
3535
projectData.platformsDir,
36-
this.$options.platformOverride ??
37-
this.$devicePlatformsConstants.iOS.toLowerCase(),
36+
this.$mobileHelper
37+
.normalizePlatformName(
38+
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
39+
)
40+
.toLowerCase(),
3841
projectData.projectName,
39-
projectData.projectName + ".entitlements"
42+
projectData.projectName + ".entitlements",
4043
);
4144
}
4245
public getPlatformsEntitlementsRelativePath(
43-
projectData: IProjectData
46+
projectData: IProjectData,
4447
): string {
4548
return path.join(
4649
projectData.projectName,
47-
projectData.projectName + ".entitlements"
50+
projectData.projectName + ".entitlements",
4851
);
4952
}
5053

@@ -71,7 +74,7 @@ export class IOSEntitlementsService {
7174
for (const plugin of allPlugins) {
7275
const pluginInfoPlistPath = path.join(
7376
plugin.pluginPlatformsFolderPath(this.$devicePlatformsConstants.iOS),
74-
IOSEntitlementsService.DefaultEntitlementsName
77+
IOSEntitlementsService.DefaultEntitlementsName,
7578
);
7679
makePatch(pluginInfoPlistPath);
7780
}
@@ -85,17 +88,17 @@ export class IOSEntitlementsService {
8588
const plistContent = session.build();
8689
this.$logger.trace(
8790
"App.entitlements: Write to: " +
88-
this.getPlatformsEntitlementsPath(projectData)
91+
this.getPlatformsEntitlementsPath(projectData),
8992
);
9093
this.$fs.writeFile(
9194
this.getPlatformsEntitlementsPath(projectData),
92-
plistContent
95+
plistContent,
9396
);
9497
}
9598
}
9699

97100
private getAllInstalledPlugins(
98-
projectData: IProjectData
101+
projectData: IProjectData,
99102
): Promise<IPluginData[]> {
100103
return this.$pluginsService.getAllInstalledPlugins(projectData);
101104
}

lib/services/ios-project-service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
130130
}
131131

132132
private _platformsDirCache: string = null;
133+
private _platformOverrideCache: string = null;
133134
private _platformData: IPlatformData = null;
134135

135136
public getPlatformData(projectData: IProjectData): IPlatformData {
@@ -139,10 +140,12 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
139140
);
140141
}
141142

143+
const currentOverride = this.$options.platformOverride ?? null;
142144
if (
143145
projectData &&
144146
projectData.platformsDir &&
145-
this._platformsDirCache !== projectData.platformsDir
147+
(this._platformsDirCache !== projectData.platformsDir ||
148+
this._platformOverrideCache !== currentOverride)
146149
) {
147150
const platform = this.$mobileHelper.normalizePlatformName(
148151
this.$options.platformOverride ?? this.$devicePlatformsConstants.iOS,
@@ -231,6 +234,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
231234
".xbm",
232235
], // https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/
233236
};
237+
this._platformsDirCache = projectData.platformsDir;
238+
this._platformOverrideCache = currentOverride;
234239
}
235240

236241
return this._platformData;
@@ -659,13 +664,10 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
659664
projectData: IProjectData,
660665
prepareData: IOSPrepareData,
661666
): Promise<void> {
667+
const platformData = this.getPlatformData(projectData);
662668
const projectRoot = this.$options.hostProjectPath
663669
? this.$options.hostProjectPath
664-
: path.join(
665-
projectData.platformsDir,
666-
this.$devicePlatformsConstants.iOS.toLowerCase(),
667-
);
668-
const platformData = this.getPlatformData(projectData);
670+
: platformData.projectRoot;
669671

670672
const pluginsData = this.getAllProductionPlugins(projectData);
671673
const pbxProjPath = this.getPbxProjPath(projectData);

0 commit comments

Comments
 (0)