Skip to content

Commit 71e4e71

Browse files
authored
Merge branch 'NativeScript:main' into fix-doctor-issue-with-asdf
2 parents 888159e + 86cb6a5 commit 71e4e71

16 files changed

Lines changed: 1786 additions & 203 deletions

.github/workflows/scorecard.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,10 @@ jobs:
4242
with:
4343
results_file: results.sarif
4444
results_format: sarif
45-
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
45+
# (Optional) PAT token. Add `repo_token: ${{ secrets.SCORECARD_TOKEN }}` if:
4646
# - you want to enable the Branch-Protection check on a *public* repository, or
4747
# - you are installing Scorecards on a *private* repository
4848
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
49-
repo_token: ${{ secrets.SCORECARD_TOKEN }}
5049

5150
# Public repositories:
5251
# - Publish results to OpenSSF REST API for easy access by consumers
@@ -70,4 +69,4 @@ jobs:
7069
- name: "Upload to code-scanning"
7170
uses: github/codeql-action/upload-sarif@87557b9c84dde89fdd9b10e88954ac2f4248e463 # v4.36.1
7271
with:
73-
sarif_file: results.sarif
72+
sarif_file: results.sarif

lib/common/definitions/mobile.d.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ declare global {
258258
* Describes different options for filtering device logs.
259259
*/
260260
interface IDeviceLogOptions
261-
extends IDictionary<string | boolean>,
262-
Partial<IProjectDir> {
261+
extends IDictionary<string | boolean>, Partial<IProjectDir> {
263262
/**
264263
* Process id of the application on the device.
265264
*/
@@ -284,8 +283,7 @@ declare global {
284283
* Describes required methods for getting iOS Simulator's logs.
285284
*/
286285
interface IiOSSimulatorLogProvider
287-
extends NodeJS.EventEmitter,
288-
IShouldDispose {
286+
extends NodeJS.EventEmitter, IShouldDispose {
289287
/**
290288
* Starts the process for getting simulator logs and emits and DEVICE_LOG_EVENT_NAME event.
291289
* @param {string} deviceId The unique identifier of the device.
@@ -429,6 +427,16 @@ declare global {
429427

430428
interface IDeviceFileSystem {
431429
listFiles(devicePath: string, appIdentifier?: string): Promise<any>;
430+
/**
431+
* Returns the entries of a directory inside the application's
432+
* sandbox, or null when the directory cannot be read. Currently
433+
* implemented only for physical iOS devices (AFC), where it backs
434+
* the post-transfer livesync verification.
435+
*/
436+
getDirectoryEntries?(
437+
devicePath: string,
438+
appIdentifier: string,
439+
): Promise<string[] | null>;
432440
getFile(
433441
deviceFilePath: string,
434442
appIdentifier: string,
@@ -533,8 +541,7 @@ declare global {
533541
/**
534542
* Describes options that can be passed to devices service's initialization method.
535543
*/
536-
interface IDevicesServicesInitializationOptions
537-
extends Partial<IDeviceLookingOptions> {
544+
interface IDevicesServicesInitializationOptions extends Partial<IDeviceLookingOptions> {
538545
/**
539546
* If passed will start an emulator if necesasry.
540547
*/
@@ -1261,8 +1268,7 @@ declare global {
12611268
}
12621269

12631270
interface IDeviceLookingOptions
1264-
extends IHasEmulatorOption,
1265-
IHasDetectionInterval {
1271+
extends IHasEmulatorOption, IHasDetectionInterval {
12661272
shouldReturnImmediateResult: boolean;
12671273
platform: string;
12681274
fullDiscovery?: boolean;
@@ -1388,8 +1394,7 @@ declare global {
13881394
/**
13891395
* Describes information about application on device.
13901396
*/
1391-
interface IDeviceApplicationInformation
1392-
extends IDeviceApplicationInformationBase {
1397+
interface IDeviceApplicationInformation extends IDeviceApplicationInformationBase {
13931398
/**
13941399
* The framework of the project (Cordova or NativeScript).
13951400
*/

lib/common/mobile/emulator-helper.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class EmulatorHelper implements Mobile.IEmulatorHelper {
66
// https://developer.android.com/guide/topics/manifest/uses-sdk-element
77
public mapAndroidApiLevelToVersion = {
88
"android-36": "16.0.0",
9+
"android-36.1": "16.0.0",
910
"android-35": "15.0.0",
1011
"android-34": "14.0.0",
1112
"android-33": "13.0.0",

lib/common/mobile/ios/device/ios-device-file-system.ts

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
99
private device: Mobile.IDevice,
1010
private $logger: ILogger,
1111
private $iosDeviceOperations: IIOSDeviceOperations,
12-
private $fs: IFileSystem
12+
private $fs: IFileSystem,
1313
) {}
1414

1515
public async listFiles(
1616
devicePath: string,
17-
appIdentifier: string
17+
appIdentifier: string,
1818
): Promise<void> {
1919
if (!devicePath) {
2020
devicePath = ".";
@@ -31,10 +31,33 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
3131
this.$logger.info(children.join(EOL));
3232
}
3333

34+
public async getDirectoryEntries(
35+
devicePath: string,
36+
appIdentifier: string,
37+
): Promise<string[] | null> {
38+
try {
39+
const result = await this.$iosDeviceOperations.listDirectory([
40+
{
41+
deviceId: this.device.deviceInfo.identifier,
42+
path: devicePath,
43+
appId: appIdentifier,
44+
},
45+
]);
46+
const entries =
47+
result?.[this.device.deviceInfo.identifier]?.[0]?.response;
48+
return Array.isArray(entries) ? entries : null;
49+
} catch (err) {
50+
this.$logger.trace(
51+
`Unable to list directory '${devicePath}' for application ${appIdentifier}: ${err.message}`,
52+
);
53+
return null;
54+
}
55+
}
56+
3457
public async getFile(
3558
deviceFilePath: string,
3659
appIdentifier: string,
37-
outputFilePath?: string
60+
outputFilePath?: string,
3861
): Promise<void> {
3962
if (outputFilePath) {
4063
await this.$iosDeviceOperations.downloadFiles([
@@ -50,14 +73,14 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
5073

5174
const fileContent = await this.getFileContent(
5275
deviceFilePath,
53-
appIdentifier
76+
appIdentifier,
5477
);
5578
this.$logger.info(fileContent);
5679
}
5780

5881
public async getFileContent(
5982
deviceFilePath: string,
60-
appIdentifier: string
83+
appIdentifier: string,
6184
): Promise<string> {
6285
const result = await this.$iosDeviceOperations.readFiles([
6386
{
@@ -73,7 +96,7 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
7396
public async putFile(
7497
localFilePath: string,
7598
deviceFilePath: string,
76-
appIdentifier: string
99+
appIdentifier: string,
77100
): Promise<void> {
78101
await this.uploadFilesCore([
79102
{
@@ -86,7 +109,7 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
86109

87110
public async deleteFile(
88111
deviceFilePath: string,
89-
appIdentifier: string
112+
appIdentifier: string,
90113
): Promise<void> {
91114
await this.$iosDeviceOperations.deleteFiles(
92115
[
@@ -98,25 +121,25 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
98121
],
99122
(err: IOSDeviceLib.IDeviceError) => {
100123
this.$logger.trace(
101-
`Error while deleting file: ${deviceFilePath}: ${err.message} with code: ${err.code}`
124+
`Error while deleting file: ${deviceFilePath}: ${err.message} with code: ${err.code}`,
102125
);
103126

104127
if (err.code !== IOSDeviceFileSystem.AFC_DELETE_FILE_NOT_FOUND_ERROR) {
105128
this.$logger.warn(
106-
`Cannot delete file: ${deviceFilePath}. Reason: ${err.message}`
129+
`Cannot delete file: ${deviceFilePath}. Reason: ${err.message}`,
107130
);
108131
}
109-
}
132+
},
110133
);
111134
}
112135

113136
public async transferFiles(
114137
deviceAppData: Mobile.IDeviceAppData,
115-
localToDevicePaths: Mobile.ILocalToDevicePathData[]
138+
localToDevicePaths: Mobile.ILocalToDevicePathData[],
116139
): Promise<Mobile.ILocalToDevicePathData[]> {
117140
const filesToUpload: Mobile.ILocalToDevicePathData[] = _.filter(
118141
localToDevicePaths,
119-
(l) => this.$fs.getFsStats(l.getLocalPath()).isFile()
142+
(l) => this.$fs.getFsStats(l.getLocalPath()).isFile(),
120143
);
121144
const files: IOSDeviceLib.IFileData[] = filesToUpload.map((l) => ({
122145
source: l.getLocalPath(),
@@ -137,29 +160,43 @@ export class IOSDeviceFileSystem implements Mobile.IDeviceFileSystem {
137160
public async transferDirectory(
138161
deviceAppData: Mobile.IDeviceAppData,
139162
localToDevicePaths: Mobile.ILocalToDevicePathData[],
140-
projectFilesPath: string
163+
projectFilesPath: string,
141164
): Promise<Mobile.ILocalToDevicePathData[]> {
142165
await this.transferFiles(deviceAppData, localToDevicePaths);
143166
return localToDevicePaths;
144167
}
145168

146169
public async updateHashesOnDevice(
147170
hashes: IStringDictionary,
148-
appIdentifier: string
171+
appIdentifier: string,
149172
): Promise<void> {
150173
return;
151174
}
152175

153176
private async uploadFilesCore(
154-
filesToUpload: IOSDeviceLib.IUploadFilesData[]
177+
filesToUpload: IOSDeviceLib.IUploadFilesData[],
155178
): Promise<void> {
156179
await this.$iosDeviceOperations.uploadFiles(
157180
filesToUpload,
158181
(err: IOSDeviceLib.IDeviceError) => {
159-
if (err.deviceId === this.device.deviceInfo.identifier) {
182+
// Previously an error whose deviceId did not exactly match was
183+
// dropped on the floor — including errors with NO deviceId at
184+
// all (some ios-device-lib error paths don't attribute one).
185+
// That left "Successfully synced" printed over a failed
186+
// transfer and the app silently running stale JavaScript.
187+
// Rethrow unless the error is positively attributed to a
188+
// DIFFERENT device; surface even those at warn level so a
189+
// failed upload is never invisible.
190+
if (
191+
!err.deviceId ||
192+
err.deviceId === this.device.deviceInfo.identifier
193+
) {
160194
throw err;
161195
}
162-
}
196+
this.$logger.warn(
197+
`File upload error reported for another device (${err.deviceId}): ${err.message}`,
198+
);
199+
},
163200
);
164201
}
165202
}

lib/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export enum IOSNativeTargetTypes {
409409
watchApp = "watch_app",
410410
watchExtension = "watch_extension",
411411
appExtension = "app_extension",
412+
application = 'application',
412413
}
413414

414415
const pathToLoggerAppendersDir = join(

lib/definitions/nativescript-dev-xcode.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,27 @@ declare module "nativescript-dev-xcode" {
88
}
99

1010
class project {
11+
hash: any;
12+
filepath: string;
1113
constructor(filename: string);
1214

1315
parse(callback: () => void): void;
1416
parseSync(): void;
1517

18+
generateUuid(): string;
19+
1620
writeSync(options: any): string;
1721

1822
addFramework(filepath: string, options?: Options): void;
1923
removeFramework(filePath: string, options?: Options): void;
2024

25+
26+
getProductFile(watchApptarget: target): any;
27+
addToPbxFrameworksBuildPhase(file);
28+
addToPbxCopyfilesBuildPhase(file, comment: string, targetid: string);
29+
pbxFrameworksBuildPhaseObj(targetid: string): any;
30+
pbxBuildFileSection(): {[k: string] : any};
31+
2132
addPbxGroup(
2233
filePathsArray: any[],
2334
name: string,
@@ -27,17 +38,30 @@ declare module "nativescript-dev-xcode" {
2738

2839
removePbxGroup(groupName: string, path: string): void;
2940

41+
addTargetDependency(target: string, dependencyTargets: string[]);
42+
43+
findTargetKey(name: string);
44+
pbxTargetByName(name: string): target;
45+
pbxNativeTargetSection(): {[key: string]: any};
46+
3047
addToHeaderSearchPaths(options?: Options): void;
3148
removeFromHeaderSearchPaths(options?: Options): void;
3249
updateBuildProperty(key: string, value: any): void;
3350

3451
pbxXCBuildConfigurationSection(): any;
3552

53+
buildPhaseObject(
54+
buildPhaseType: string,
55+
comment: string,
56+
target: tstring
57+
)
58+
3659
addTarget(
3760
targetName: string,
3861
targetType: string,
3962
targetPath?: string,
40-
parentTarget?: string
63+
parentTarget?: string,
64+
productTargetType?: string
4165
): target;
4266
addBuildPhase(
4367
filePathsArray: string[],

lib/definitions/project.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ interface IAddExtensionsFromPathOptions extends IAddTargetFromPathOptions {
880880

881881
interface IAddWatchAppFromPathOptions extends IAddTargetFromPathOptions {
882882
watchAppFolderPath: string;
883+
disableStubBinary?: boolean;
883884
}
884885

885886
interface IRemoveExtensionsOptions {
@@ -888,6 +889,37 @@ interface IRemoveExtensionsOptions {
888889

889890
interface IRemoveWatchAppOptions extends IRemoveExtensionsOptions {}
890891

892+
interface IWatchAppJSONConfigModule {
893+
name?: string;
894+
path: string;
895+
targetType?: string;
896+
embed?: boolean;
897+
frameworks?: Array<string | Record<string, string>>;
898+
dependencies?: string[];
899+
headerSearchPaths?: string[];
900+
resources?: string[];
901+
src?: string[];
902+
linkerFlags?: string[];
903+
buildConfigurationProperties?: Record<string, string>;
904+
SPMPackages?: Array<IOSSPMPackage | string>;
905+
}
906+
interface IWatchAppJSONConfig {
907+
targetType?: string;
908+
forceAddEmbedWatchContent?: boolean;
909+
sharedModulesBuildConfigurationProperties?: Record<string, string>;
910+
basedir?: string;
911+
infoPlistPath?: string;
912+
xcprivacyPath?: string;
913+
importSourcesFromMainFolder?: boolean;
914+
importResourcesFromMainFolder?: boolean;
915+
resources?: string[];
916+
src?: string[];
917+
resourcesExclude?: string[];
918+
srcExclude?: string[];
919+
modules: IWatchAppConfigModule[];
920+
SPMPackages?: Array<IOSSPMPackage>;
921+
}
922+
891923
interface IRubyFunction {
892924
functionName: string;
893925
functionParameters?: string;

lib/services/ios-project-service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,6 @@ export class IOSProjectService
877877
}
878878
}
879879

880-
this.$iOSWatchAppService.removeWatchApp({ pbxProjPath });
881880
const addedWatchApp = await this.$iOSWatchAppService.addWatchAppFromPath({
882881
watchAppFolderPath: path.join(
883882
resourcesDirectoryPath,

0 commit comments

Comments
 (0)