Skip to content

Commit a086726

Browse files
authored
Merge pull request #1892 from NativeScript/jasssonpet/ios-deployment-target
Deprecate iOS deployment target check for frameworks
2 parents 07f22f1 + 0d3bcdd commit a086726

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

lib/definitions/xcode.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ declare module "xcode" {
2323
addToHeaderSearchPaths(options?: Options): void;
2424
removeFromHeaderSearchPaths(options?: Options): void;
2525
updateBuildProperty(key: string, value: any): void;
26+
27+
pbxXCBuildConfigurationSection(): any;
2628
}
2729
}

lib/services/ios-project-service.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,34 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
360360
return Future.fromResult();
361361
}
362362

363+
private getDeploymentTarget(project: xcode.project): string {
364+
let configurations = project.pbxXCBuildConfigurationSection();
365+
366+
for (let configName in configurations) {
367+
if (!Object.prototype.hasOwnProperty.call(configurations, configName)) {
368+
continue;
369+
}
370+
371+
let configuration = configurations[configName];
372+
if (typeof configuration !== "object") {
373+
continue;
374+
}
375+
376+
let buildSettings = configuration.buildSettings;
377+
if (buildSettings["IPHONEOS_DEPLOYMENT_TARGET"]) {
378+
return buildSettings["IPHONEOS_DEPLOYMENT_TARGET"];
379+
}
380+
}
381+
}
382+
383+
private ensureIos8DeploymentTarget(project: xcode.project) {
384+
// [email protected]+ has a default deployment target of 8.0 so this is not needed there
385+
if (this.getDeploymentTarget(project) === "7.0") {
386+
project.updateBuildProperty("IPHONEOS_DEPLOYMENT_TARGET", "8.0");
387+
this.$logger.info("The iOS Deployment Target is now 8.0 in order to support Cocoa Touch Frameworks.");
388+
}
389+
}
390+
363391
private addDynamicFramework(frameworkPath: string): IFuture<void> {
364392
return (() => {
365393
this.validateFramework(frameworkPath).wait();
@@ -378,8 +406,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
378406

379407
if (isDynamic) {
380408
frameworkAddOptions["embed"] = true;
381-
project.updateBuildProperty("IPHONEOS_DEPLOYMENT_TARGET", "8.0");
382-
this.$logger.info("The iOS Deployment Target is now 8.0 in order to support Cocoa Touch Frameworks.");
409+
this.ensureIos8DeploymentTarget(project);
383410
}
384411

385412
let frameworkRelativePath = this.getLibSubpathRelativeToProjectPath(path.basename(frameworkPath));
@@ -910,8 +937,7 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
910937
this.$fs.writeFile(this.projectPodFilePath, contentToWrite).wait();
911938

912939
let project = this.createPbxProj();
913-
project.updateBuildProperty("IPHONEOS_DEPLOYMENT_TARGET", "8.0");
914-
this.$logger.info("The iOS Deployment Target is now 8.0 in order to support Cocoa Touch Frameworks in CocoaPods.");
940+
this.ensureIos8DeploymentTarget(project);
915941
this.savePbxProj(project).wait();
916942
}
917943
}

test/ios-project-service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ describe("Cocoapods support", () => {
293293
};
294294
iOSProjectService.createPbxProj = () => {
295295
return {
296-
updateBuildProperty: () => { return {}; }
296+
updateBuildProperty: () => { return {}; },
297+
pbxXCBuildConfigurationSection: () => { return {}; },
297298
};
298299
};
299300
iOSProjectService.savePbxProj = (): IFuture<void> => Future.fromResult();
@@ -362,7 +363,8 @@ describe("Cocoapods support", () => {
362363
};
363364
iOSProjectService.createPbxProj = () => {
364365
return {
365-
updateBuildProperty: () => { return {}; }
366+
updateBuildProperty: () => { return {}; },
367+
pbxXCBuildConfigurationSection: () => { return {}; },
366368
};
367369
};
368370
iOSProjectService.savePbxProj = (): IFuture<void> => Future.fromResult();

0 commit comments

Comments
 (0)