Skip to content

Commit b7df627

Browse files
committed
Merge pull request #1032 from NativeScript/fatme/fix-framework-version
Fix frameworkVersion
2 parents 737d2d4 + c2430f9 commit b7df627

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

lib/definitions/platform.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ interface IPlatformData {
3232
frameworkFilesExtensions: string[];
3333
frameworkDirectoriesExtensions?: string[];
3434
frameworkDirectoriesNames?: string[];
35-
frameworkVersion: string;
3635
targetedOS?: string[];
3736
configurationFileName?: string;
3837
configurationFilePath?: string;

lib/services/android-project-service.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
2626
private $logger: ILogger,
2727
private $options: IOptions,
2828
$projectData: IProjectData,
29-
private $projectDataService: IProjectDataService,
29+
$projectDataService: IProjectDataService,
3030
private $sysInfo: ISysInfo,
3131
private $mobileHelper: Mobile.IMobileHelper) {
32-
super($fs, $projectData);
32+
super($fs, $projectData, $projectDataService);
3333
this._androidProjectPropertiesManagers = Object.create(null);
3434
}
3535

@@ -51,7 +51,6 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
5151
`${this.$projectData.projectName}-release.apk`
5252
],
5353
frameworkFilesExtensions: [".jar", ".dat", ".so"],
54-
frameworkVersion: this.getFrameworkVersion("tns-android"),
5554
configurationFileName: "AndroidManifest.xml",
5655
configurationFilePath: path.join(projectRoot, "src", "main", "AndroidManifest.xml"),
5756
mergeXmlConfig: [{ "nodename": "manifest", "attrname": "*" }, {"nodename": "application", "attrname": "*"}]

lib/services/ios-project-service.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3131
private $iOSEmulatorServices: Mobile.IEmulatorPlatformServices,
3232
private $options: IOptions,
3333
private $injector: IInjector,
34-
private $projectDataService: IProjectDataService,
34+
$projectDataService: IProjectDataService,
3535
private $prompter: IPrompter) {
36-
super($fs, $projectData);
36+
super($fs, $projectData, $projectDataService);
3737
}
3838

3939
public get platformData(): IPlatformData {
@@ -57,7 +57,6 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
5757
frameworkFilesExtensions: [".a", ".framework", ".bin"],
5858
frameworkDirectoriesExtensions: [".framework"],
5959
frameworkDirectoriesNames: ["Metadata", "metadataGenerator", "NativeScript", "internal"],
60-
frameworkVersion: this.getFrameworkVersion("tns-ios"),
6160
targetedOS: ['darwin'],
6261
configurationFileName: "Info.plist",
6362
configurationFilePath: path.join(projectRoot, this.$projectData.projectName, this.$projectData.projectName+"-Info.plist"),
@@ -67,8 +66,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
6766

6867
public getAppResourcesDestinationDirectoryPath(): IFuture<string> {
6968
return (() => {
70-
this.$projectDataService.initialize(this.$projectData.projectDir);
71-
let frameworkVersion = this.$projectDataService.getValue(this.platformData.frameworkPackageName).wait()["version"];
69+
let frameworkVersion = this.getFrameworkVersion(this.platformData.frameworkPackageName).wait();
7270

7371
if(semver.lt(frameworkVersion, "1.3.0")) {
7472
return path.join(this.platformData.projectRoot, this.$projectData.projectName, "Resources", "icons");
@@ -159,7 +157,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
159157
}
160158

161159
// Starting from tns-ios 1.4 the xcconfig file is referenced in the project template
162-
if (semver.lt(this.platformData.frameworkVersion, "1.4.0")) {
160+
let frameworkVersion = this.getFrameworkVersion(this.platformData.frameworkPackageName).wait();
161+
if (semver.lt(frameworkVersion, "1.4.0")) {
163162
basicArgs.push("-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"));
164163
}
165164

lib/services/platform-project-service-base.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33

44
export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
55
constructor(protected $fs: IFileSystem,
6-
protected $projectData: IProjectData) {
6+
protected $projectData: IProjectData,
7+
protected $projectDataService: IProjectDataService) {
78
}
89

910
public getPluginPlatformsFolderPath(pluginData: IPluginData, platform: string) {
@@ -25,12 +26,11 @@ export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
2526
}).future<string[]>()();
2627
}
2728

28-
protected getFrameworkVersion(runtimePackageName: string): string {
29-
let frameworkVersion: string;
30-
let jsonData = this.$fs.readJson(this.$projectData.projectFilePath).wait();
31-
if (jsonData && jsonData.nativescript && jsonData.nativescript[runtimePackageName]) {
32-
frameworkVersion = jsonData.nativescript[runtimePackageName].version;
33-
}
34-
return frameworkVersion;
29+
protected getFrameworkVersion(runtimePackageName: string): IFuture<string> {
30+
return (() => {
31+
this.$projectDataService.initialize(this.$projectData.projectDir);
32+
let frameworkVersion = this.$projectDataService.getValue(runtimePackageName).wait().version;
33+
return frameworkVersion;
34+
}).future<string>()();
3535
}
3636
}

0 commit comments

Comments
 (0)