From ecfe62010827f93732aae1209948b7b14bfdc6ea Mon Sep 17 00:00:00 2001 From: fatme Date: Thu, 27 Jun 2019 13:59:54 +0300 Subject: [PATCH 1/2] fix: fix "Could not open file Library/Application Support/LiveSync/app/tns_modules/tns-core-modules/inspector_modules.js for writing" error on iOS device when hmr fails NativeScript CLI zips all files from application except the files from tns-modules. When the runtime unzip the uploaded archive on device, it symlinks the tns_modules folder. When hmr fails, CLI transfers fallback files on device in order to apply the change. The `inspector_modules.js` file is part of these fallback files which is located in `tns_modules` folder. In this situation CLI tries to write the file inside /Library/Application Support/LiveSync/app/tns_modules which is symlinked to app's bundle folder. As CLI is not able to write directly to app's bundle folder, the above error is thrown. --- lib/services/livesync/ios-livesync-service.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/services/livesync/ios-livesync-service.ts b/lib/services/livesync/ios-livesync-service.ts index df2d34e063..d6bd6e5984 100644 --- a/lib/services/livesync/ios-livesync-service.ts +++ b/lib/services/livesync/ios-livesync-service.ts @@ -3,7 +3,7 @@ import * as temp from "temp"; import { IOSDeviceLiveSyncService } from "./ios-device-livesync-service"; import { PlatformLiveSyncServiceBase } from "./platform-livesync-service-base"; -import { APP_FOLDER_NAME, TNS_MODULES_FOLDER_NAME } from "../../constants"; +import { APP_FOLDER_NAME } from "../../constants"; import { performanceLog } from "../../common/decorators"; export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements IPlatformLiveSyncService { @@ -34,8 +34,6 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I this.$logger.trace("Creating zip file: " + tempZip); this.$fs.copyFile(path.join(path.dirname(projectFilesPath), `${APP_FOLDER_NAME}/*`), tempApp); - this.$fs.deleteDirectory(path.join(tempApp, TNS_MODULES_FOLDER_NAME)); - await this.$fs.zipFiles(tempZip, this.$fs.enumerateFilesInDirectorySync(tempApp), (res) => { return path.join(APP_FOLDER_NAME, path.relative(tempApp, res)); }); From 61ca7539c9dc4554bfddc5c2a043c9e4ed32ab1e Mon Sep 17 00:00:00 2001 From: fatme Date: Fri, 28 Jun 2019 08:23:03 +0300 Subject: [PATCH 2/2] fix: don't create tempApp when zipping the application --- lib/services/livesync/ios-livesync-service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/services/livesync/ios-livesync-service.ts b/lib/services/livesync/ios-livesync-service.ts index d6bd6e5984..fddd52e561 100644 --- a/lib/services/livesync/ios-livesync-service.ts +++ b/lib/services/livesync/ios-livesync-service.ts @@ -30,12 +30,10 @@ export class IOSLiveSyncService extends PlatformLiveSyncServiceBase implements I temp.track(); const tempZip = temp.path({ prefix: "sync", suffix: ".zip" }); - const tempApp = temp.mkdirSync("app"); this.$logger.trace("Creating zip file: " + tempZip); - this.$fs.copyFile(path.join(path.dirname(projectFilesPath), `${APP_FOLDER_NAME}/*`), tempApp); - await this.$fs.zipFiles(tempZip, this.$fs.enumerateFilesInDirectorySync(tempApp), (res) => { - return path.join(APP_FOLDER_NAME, path.relative(tempApp, res)); + await this.$fs.zipFiles(tempZip, this.$fs.enumerateFilesInDirectorySync(projectFilesPath), (res) => { + return path.join(APP_FOLDER_NAME, path.relative(projectFilesPath, res)); }); await device.fileSystem.transferFiles(deviceAppData, [{