Skip to content

Commit 004abea

Browse files
committed
Remove xcconfig flag for xcodebuild for tns-ios 1.4+
1 parent 8c8c62d commit 004abea

7 files changed

Lines changed: 49 additions & 11 deletions

File tree

lib/definitions/platform.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interface IPlatformData {
3232
frameworkFilesExtensions: string[];
3333
frameworkDirectoriesExtensions?: string[];
3434
frameworkDirectoriesNames?: string[];
35+
frameworkVersion: string;
3536
targetedOS?: string[];
3637
configurationFileName?: string;
3738
configurationFilePath?: string;

lib/services/android-project-service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
2525
private $hostInfo: IHostInfo,
2626
private $logger: ILogger,
2727
private $options: IOptions,
28-
private $projectData: IProjectData,
28+
$projectData: IProjectData,
2929
private $projectDataService: IProjectDataService,
30-
private $propertiesParser: IPropertiesParser,
3130
private $sysInfo: ISysInfo,
3231
private $mobileHelper: Mobile.IMobileHelper) {
33-
super($fs);
32+
super($fs, $projectData);
3433
this._androidProjectPropertiesManagers = Object.create(null);
3534
}
3635

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

lib/services/ios-project-service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
2323
return this.$injector.resolve("npmInstallationManager");
2424
}
2525

26-
constructor(private $projectData: IProjectData,
26+
constructor($projectData: IProjectData,
2727
$fs: IFileSystem,
2828
private $childProcess: IChildProcess,
2929
private $errors: IErrors,
@@ -33,7 +33,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
3333
private $injector: IInjector,
3434
private $projectDataService: IProjectDataService,
3535
private $prompter: IPrompter) {
36-
super($fs);
36+
super($fs, $projectData);
3737
}
3838

3939
public get platformData(): IPlatformData {
@@ -57,6 +57,7 @@ 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"),
6061
targetedOS: ['darwin'],
6162
configurationFileName: "Info.plist",
6263
configurationFilePath: path.join(projectRoot, this.$projectData.projectName, this.$projectData.projectName+"-Info.plist"),
@@ -157,10 +158,14 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
157158
basicArgs.push("-target", this.$projectData.projectName);
158159
}
159160

161+
// 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")) {
163+
basicArgs.push("-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"));
164+
}
165+
160166
let args: string[] = [];
161167
if(this.$options.forDevice) {
162168
args = basicArgs.concat([
163-
"-xcconfig", path.join(projectRoot, this.$projectData.projectName, "build.xcconfig"),
164169
"-sdk", "iphoneos",
165170
'ARCHS=armv7 arm64',
166171
'VALID_ARCHS=armv7 arm64',

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
"use strict";
33

44
export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
5-
constructor(protected $fs: IFileSystem) { }
5+
constructor(protected $fs: IFileSystem,
6+
protected $projectData: IProjectData) {
7+
}
68

79
public getPluginPlatformsFolderPath(pluginData: IPluginData, platform: string) {
810
return pluginData.pluginPlatformsFolderPath(platform);
@@ -22,4 +24,13 @@ export class PlatformProjectServiceBase implements IPlatformProjectServiceBase {
2224
return nativeLibraries;
2325
}).future<string[]>()();
2426
}
27+
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;
35+
}
2536
}

test/ios-project-service.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,33 @@ function createTestInjector(projectPath: string, projectName: string): IInjector
3333
testInjector.register("options", OptionsLib.Options);
3434
testInjector.register("projectData", {
3535
platformsDir: projectPath,
36-
projectName: projectName
36+
projectName: projectName,
37+
projectPath: projectPath,
38+
projectFilePath: path.join(projectPath, "package.json")
3739
});
3840
testInjector.register("projectHelper", {});
3941
testInjector.register("staticConfig", ConfigLib.StaticConfig);
4042
testInjector.register("projectDataService", {});
4143
testInjector.register("prompter", {});
42-
4344
return testInjector;
4445
}
4546

47+
function createPackageJson(testInjector: IInjector, projectPath: string, projectName: string) {
48+
let packageJsonData = {
49+
"name": projectName,
50+
"version": "0.1.0",
51+
"nativescript": {
52+
"tns-ios": {
53+
"version": "1.0.0"
54+
},
55+
"tns-android": {
56+
"version": "1.0.0"
57+
}
58+
}
59+
};
60+
testInjector.resolve("fs").writeJson(path.join(projectPath, "package.json"), packageJsonData).wait();
61+
}
62+
4663
describe("Cocoapods support", () => {
4764
if (require("os").platform() !== "darwin") {
4865
console.log("Skipping Cocoapods tests. They cannot work on windows");
@@ -59,7 +76,7 @@ describe("Cocoapods support", () => {
5976
"version": "0.1.0",
6077
"nativescript": {
6178
"id": "org.nativescript.myProject",
62-
"tns-android": {
79+
"tns-ios": {
6380
"version": "1.0.0"
6481
}
6582
}
@@ -120,7 +137,7 @@ describe("Cocoapods support", () => {
120137
"version": "0.1.0",
121138
"nativescript": {
122139
"id": "org.nativescript.myProject2",
123-
"tns-android": {
140+
"tns-ios": {
124141
"version": "1.0.0"
125142
}
126143
}
@@ -250,6 +267,7 @@ describe("Relative paths", () => {
250267
let subpath = "sub/path";
251268

252269
let testInjector = createTestInjector(projectPath, projectName);
270+
createPackageJson(testInjector, projectPath, projectName);
253271
let iOSProjectService = testInjector.resolve("iOSProjectService");
254272

255273
let result = iOSProjectService.getLibSubpathRelativeToProjectPath(subpath);

test/platform-commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class PlatformData implements IPlatformData {
2525
deviceBuildOutputPath = "";
2626
validPackageNamesForDevice: string[] = [];
2727
frameworkFilesExtensions = [".jar", ".dat"];
28+
frameworkVersion = "";
2829
appDestinationDirectoryPath = "";
2930
appResourcesDestinationDirectoryPath = "";
3031
}

test/stubs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class PlatformsDataStub implements IPlatformsData {
252252
deviceBuildOutputPath: "",
253253
validPackageNamesForDevice: [],
254254
frameworkFilesExtensions: [],
255+
frameworkVersion: "",
255256
appDestinationDirectoryPath: "",
256257
preparePluginNativeCode: () => Future.fromResult(),
257258
removePluginNativeCode: () => Future.fromResult(),
@@ -275,6 +276,7 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
275276
deviceBuildOutputPath: "",
276277
validPackageNamesForDevice: [],
277278
frameworkFilesExtensions: [],
279+
frameworkVersion: "",
278280
appDestinationDirectoryPath: ""
279281
};
280282
}

0 commit comments

Comments
 (0)