Skip to content

Commit 4f4bbd7

Browse files
fix: Unable to run app on iOS in Sidekick
When trying to run application on iOS in Sidekick for the first time (when the iOS platform is not added yet to the project), the run fails with error "Cannot read property version of undefined". The problem is in the call to `platformLiveSyncService.prepareForLiveSync` which tries to start parsing device logs before starting the liveSync action. However, at this point, the application does not have the platform added yet and the code that tries to get the version of `tns-ios` from project's package.json fails. In order to resolve this, ensure the code for getting framework version from package.json will return undefined instead of failing. When undefined is returned, we know CLI will add the latest compatible iOS runtime version. We know that this version will print the port for debugging in the logs, so we can safely start parsing the logs.
1 parent f96bfae commit 4f4bbd7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/services/ios-debugger-port-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class IOSDebuggerPortService implements IIOSDebuggerPortService {
5151
private canStartLookingForDebuggerPort(data: IProjectDir): boolean {
5252
const projectData = this.$projectDataService.getProjectData(data && data.projectDir);
5353
const frameworkVersion = this.$iOSProjectService.getFrameworkVersion(projectData);
54-
return semver.gt(frameworkVersion, IOSDebuggerPortService.MIN_REQUIRED_FRAMEWORK_VERSION);
54+
return !frameworkVersion || semver.gt(frameworkVersion, IOSDebuggerPortService.MIN_REQUIRED_FRAMEWORK_VERSION);
5555
}
5656

5757
@cache()

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export abstract class PlatformProjectServiceBase extends EventEmitter implements
1313
}
1414

1515
public getFrameworkVersion(projectData: IProjectData): string {
16-
return this.$projectDataService.getNSValue(projectData.projectDir, this.getPlatformData(projectData).frameworkPackageName).version;
16+
const frameworkData = this.$projectDataService.getNSValue(projectData.projectDir, this.getPlatformData(projectData).frameworkPackageName);
17+
return frameworkData && frameworkData.version;
1718
}
1819

1920
protected getAllNativeLibrariesForPlugin(pluginData: IPluginData, platform: string, filter: (fileName: string, _pluginPlatformsFolderPath: string) => boolean): string[] {

0 commit comments

Comments
 (0)