Skip to content

Commit 6ef8665

Browse files
committed
feat(doctor): add sdk 34 support
1 parent 20c735b commit 6ef8665

File tree

7 files changed

+58
-48
lines changed

7 files changed

+58
-48
lines changed

lib/common/mobile/emulator-helper.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { injector } from "../yok";
55
export class EmulatorHelper implements Mobile.IEmulatorHelper {
66
// https://developer.android.com/guide/topics/manifest/uses-sdk-element
77
public mapAndroidApiLevelToVersion = {
8+
"android-34": "14.0.0",
89
"android-33": "13.0.0",
910
"android-32": "12.0.0",
1011
"android-31": "12.0.0",

package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "nativescript",
33
"preferGlobal": true,
4-
"version": "8.6.2",
4+
"version": "8.6.3",
55
"author": "NativeScript <[email protected]>",
66
"description": "Command-line interface for building NativeScript projects",
77
"bin": {
@@ -55,7 +55,7 @@
5555
"mobile"
5656
],
5757
"dependencies": {
58-
"@nativescript/doctor": "2.0.11",
58+
"@nativescript/doctor": "2.0.12",
5959
"@nativescript/schematics-executor": "0.0.2",
6060
"@npmcli/arborist": "^7.2.0",
6161
"@npmcli/move-file": "^2.0.0",

packages/doctor/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/doctor",
3-
"version": "2.0.11",
3+
"version": "2.0.12",
44
"description": "Library that helps identifying if the environment can be used for development of {N} apps.",
55
"main": "src/index.js",
66
"types": "./typings/nativescript-doctor.d.ts",

packages/doctor/src/android-tools-info.ts

+17-13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
3030
"android-31",
3131
"android-32",
3232
"android-33",
33+
"android-34",
3334
];
3435

3536
const isRuntimeVersionLessThan = (targetVersion: string) => {
@@ -75,9 +76,8 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
7576
config: Partial<NativeScriptDoctor.IProjectDir> = {}
7677
): NativeScriptDoctor.IAndroidToolsInfoData {
7778
if (!this.toolsInfo) {
78-
const infoData: NativeScriptDoctor.IAndroidToolsInfoData = Object.create(
79-
null
80-
);
79+
const infoData: NativeScriptDoctor.IAndroidToolsInfoData =
80+
Object.create(null);
8181
infoData.androidHomeEnvVar = this.androidHome;
8282
infoData.installedTargets = this.getInstalledTargets();
8383
infoData.compileSdkVersion = this.getCompileSdk(
@@ -99,14 +99,18 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
9999
const toolsInfoData = this.getToolsInfo(config);
100100
const isAndroidHomeValid = this.isAndroidHomeValid();
101101
if (!toolsInfoData.compileSdkVersion) {
102-
const supportedTargetsForAndroidRuntime = this.getSupportedTargets(config.projectDir)
102+
const supportedTargetsForAndroidRuntime = this.getSupportedTargets(
103+
config.projectDir
104+
);
103105
errors.push({
104106
warning: [
105107
`Cannot find a compatible Android SDK for compilation.`,
106108
`To be able to build for Android with your current android runtime, install one of the following supported Android SDK targets:`,
107-
...supportedTargetsForAndroidRuntime.map(target => ` ${target}`),
108-
`Supported targets vary based on what android runtime you have installed. Currently your app uses @nativescript/android ${this.getRuntimeVersion({ projectDir: config.projectDir })}`
109-
].join('\n'),
109+
...supportedTargetsForAndroidRuntime.map((target) => ` ${target}`),
110+
`Supported targets vary based on what android runtime you have installed. Currently your app uses @nativescript/android ${this.getRuntimeVersion(
111+
{ projectDir: config.projectDir }
112+
)}`,
113+
].join("\n"),
110114
additionalInformation: `Run \`\$ ${this.getPathToSdkManagementTool()}\` to manage your Android SDK versions.`,
111115
platforms: [Constants.ANDROID_PLATFORM_NAME],
112116
});
@@ -530,9 +534,10 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
530534
return !errors && !errors.length;
531535
}
532536

533-
private getAndroidRuntimePackageFromProjectDir(
534-
projectDir: string
535-
): { name: string; version: string } {
537+
private getAndroidRuntimePackageFromProjectDir(projectDir: string): {
538+
name: string;
539+
version: string;
540+
} {
536541
if (!projectDir || !this.fs.exists(projectDir)) {
537542
return null;
538543
}
@@ -542,9 +547,8 @@ export class AndroidToolsInfo implements NativeScriptDoctor.IAndroidToolsInfo {
542547
return null;
543548
}
544549

545-
const content = this.fs.readJson<INativeScriptProjectPackageJson>(
546-
pathToPackageJson
547-
);
550+
const content =
551+
this.fs.readJson<INativeScriptProjectPackageJson>(pathToPackageJson);
548552

549553
if (!content) {
550554
return null;

packages/doctor/test/android-tools-info.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe("androidToolsInfo", () => {
5656
"31.0.0",
5757
"32.0.0",
5858
"33.0.0",
59+
"34.0.0",
5960
];
6061
} else {
6162
return [
@@ -67,6 +68,7 @@ describe("androidToolsInfo", () => {
6768
"android-31",
6869
"android-32",
6970
"android-33",
71+
"android-34",
7072
];
7173
}
7274
},
@@ -91,18 +93,18 @@ describe("androidToolsInfo", () => {
9193
assert.equal(toolsInfo.compileSdkVersion, 30);
9294
});
9395

94-
it("runtime 8.1.1 - 30", () => {
96+
it("runtime < 8.2.0 - 30", () => {
9597
const androidToolsInfo = getAndroidToolsInfo("8.1.1");
9698
const toolsInfo = androidToolsInfo.getToolsInfo({ projectDir: "test" });
9799

98100
assert.equal(toolsInfo.compileSdkVersion, 30);
99101
});
100102

101-
it("runtime 8.2.0 - 32", () => {
103+
it("runtime >8.2.0 - latest", () => {
102104
const androidToolsInfo = getAndroidToolsInfo("8.2.0");
103105
const toolsInfo = androidToolsInfo.getToolsInfo({ projectDir: "test" });
104106

105-
assert.equal(toolsInfo.compileSdkVersion, 33);
107+
assert.equal(toolsInfo.compileSdkVersion, 34);
106108
});
107109
});
108110

@@ -134,9 +136,9 @@ describe("androidToolsInfo", () => {
134136
assertSupportedRange("8.1.0", min, max);
135137
});
136138

137-
it("runtime 8.2.0 should support android-17 - android-33", () => {
139+
it("runtime 8.2.0 should support android-17 - android-34", () => {
138140
const min = 17;
139-
const max = 33;
141+
const max = 34;
140142
assertSupportedRange("8.2.0", min, max);
141143
assertSupportedRange("8.3.0", min, max);
142144
});

test/cocoapods-service.ts

+24-21
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,17 @@ end`,
819819
command: string,
820820
options?: any,
821821
execOptions?: IExecOptions
822-
): Promise<any> => null;
822+
): Promise<any> => {
823+
if (command === "arch -x86_64 pod --version") {
824+
// This is the command that is used to check if cocoapods is installed under Rosetta 2
825+
return {
826+
stdout: "Bad CPU type in executable",
827+
stderr: "",
828+
exitCode: 0,
829+
};
830+
}
831+
return null;
832+
};
823833
childProcess.spawnFromEvent = async (
824834
command: string,
825835
args: string[],
@@ -839,9 +849,8 @@ end`,
839849
}`, async () => {
840850
const config = testInjector.resolve<IConfiguration>("config");
841851
config.USE_POD_SANDBOX = podExecutable === "sandbox-pod";
842-
const childProcess = testInjector.resolve<IChildProcess>(
843-
"childProcess"
844-
);
852+
const childProcess =
853+
testInjector.resolve<IChildProcess>("childProcess");
845854
let commandCalled = "";
846855
childProcess.spawnFromEvent = async (
847856
command: string,
@@ -949,9 +958,10 @@ end`,
949958
projectPodfileContent = "";
950959
});
951960

952-
function setupMocks(
953-
pods: any[]
954-
): { projectData: IProjectData; platformData: any } {
961+
function setupMocks(pods: any[]): {
962+
projectData: IProjectData;
963+
platformData: any;
964+
} {
955965
const podsPaths = pods.map((p) => p.path);
956966
const projectData = testInjector.resolve("projectData");
957967
projectData.getAppResourcesDirectoryPath = () =>
@@ -990,13 +1000,11 @@ end`,
9901000

9911001
const testCasesWithApplyAndRemove = [
9921002
{
993-
name:
994-
"should select the podfile with highest platform after Podfile from App_Resources has been deleted",
1003+
name: "should select the podfile with highest platform after Podfile from App_Resources has been deleted",
9951004
pods: [
9961005
{
9971006
name: "mySecondPluginWithPlatform",
998-
path:
999-
"node_modules/ mypath with spaces/mySecondPluginWithPlatform/Podfile",
1007+
path: "node_modules/ mypath with spaces/mySecondPluginWithPlatform/Podfile",
10001008
content: `platform :ios, '10.0'`,
10011009
},
10021010
{
@@ -1180,8 +1188,7 @@ pod 'myPod' ~> 0.3.4
11801188
end`,
11811189
},
11821190
{
1183-
name:
1184-
"should select the platform with highest version from plugins when no Podfile in App_Resources",
1191+
name: "should select the platform with highest version from plugins when no Podfile in App_Resources",
11851192
pods: [
11861193
{
11871194
name: "pluginWithPlatform",
@@ -1220,8 +1227,7 @@ pod 'myPod' ~> 0.3.4
12201227
end`,
12211228
},
12221229
{
1223-
name:
1224-
"should select the platform without version when no Podfile in App_Resources",
1230+
name: "should select the platform without version when no Podfile in App_Resources",
12251231
pods: [
12261232
{
12271233
name: "myPluginWithoutPlatform",
@@ -1260,8 +1266,7 @@ platform :ios
12601266
end`,
12611267
},
12621268
{
1263-
name:
1264-
"shouldn't replace the platform without version when no Podfile in App_Resources",
1269+
name: "shouldn't replace the platform without version when no Podfile in App_Resources",
12651270
pods: [
12661271
{
12671272
name: "myPluginWithoutPlatform",
@@ -1300,13 +1305,11 @@ platform :ios
13001305
end`,
13011306
},
13021307
{
1303-
name:
1304-
"should select platform from plugins when the podfile in App_Resources/iOS/Podfile has no platform",
1308+
name: "should select platform from plugins when the podfile in App_Resources/iOS/Podfile has no platform",
13051309
pods: [
13061310
{
13071311
name: "mySecondPluginWithPlatform",
1308-
path:
1309-
"node_modules/ mypath with spaces/mySecondPluginWithPlatform/Podfile",
1312+
path: "node_modules/ mypath with spaces/mySecondPluginWithPlatform/Podfile",
13101313
content: `platform :ios, '10.0'`,
13111314
},
13121315
{

0 commit comments

Comments
 (0)