NativeScript 6.5.1 至 8.2:找不到名称 CLLocationManager、CLLocationManagerDelegate

发布于 2025-01-13 17:41:38 字数 4783 浏览 0 评论 0原文

我是 NativeScript 和 webpack 的新手,我已将本机脚本应用程序从 6.5.1 迁移到 8.2 版本并使用 @nativescript/geolocation : "8.0.2" 并且我的引用已损坏,无法构建我的 NativeScript 应用程序。

输入图片此处描述

在此处输入图像描述

代码

import { Injectable } from "@angular/core";
import * as geoLocation from "@nativescript/geolocation";
import { Logger } from "../../shared/default-logger.service";
import { LocationServiceBase } from "./location.service.common";

@Injectable()
export class LocationService extends LocationServiceBase {

    private iosLocManager: CLLocationManager;
    private locManagerDelegate: LocationMangerDelegate;

    constructor(private logger: Logger) {
        super(logger);
        this.iosLocManager = new CLLocationManager();
        this.locManagerDelegate = new LocationMangerDelegate();
        this.iosLocManager.desiredAccuracy = 3;
        this.iosLocManager.distanceFilter = 0.1;
        this.logger.log("before setting delegate");
        this.iosLocManager.delegate = this.locManagerDelegate;
        this.logger.log("after setting delegate");
    }


    protected getDirection(location: geoLocation.Location): number {
        return this.locManagerDelegate.currentHeading;
    }

    startUpdatingHeading(): void {
        this.locManagerDelegate.currentHeading = null;
        this.iosLocManager.startUpdatingHeading();
    }

    stopUpdatingHeading(): void {
        this.iosLocManager.stopUpdatingHeading();
    }
}

export class LocationMangerDelegate extends NSObject implements CLLocationManagerDelegate {
    public static ObjCProtocols = [CLLocationManagerDelegate]; // tslint:disable-line:variable-name

    currentHeading: number;

    locationManagerDidUpdateHeading(locationManager: CLLocationManager, heading: CLHeading): void {
        this.currentHeading = heading.trueHeading;
    }

}

我在谷歌搜索上没有任何运气,我花了几个小时在这上面。你能让我知道如何解决这些参考问题吗?我被困在这里,不确定我是否错过了什么。

包.json

{
  
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "base-64": "^0.1.0",
    "cross-env": "^5.2.0",
    "lodash": "^4.17.11",
    "@nativescript/camera": "5.0.10",
    "nativescript-couchbase": "^1.0.18",
    "nativescript-appversion": "1.4.4",
    "@nativescript/email": "2.0.5",
    "@nativescript/geolocation": "8.0.2",
    "nativescript-phone": "3.0.3",
    "nativescript-screen-orientation": "^2.0.0",
    "nativescript-orientation-free": "2.2.5",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.13",
    "rxjs": "~7.5.0",
    "rxjs-compat": "^6.4.0",
    "utf8": "^3.0.0",
    "zone.js": "~0.11.5",
    "@nativescript/core": "~8.2.0",
    "@nativescript/angular": "^13.0.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.2.0",
    "@angular/compiler-cli": "~13.2.0",
    "@nativescript/ios": "8.2.1",
    "@nativescript/schematics": "~0.5.0",
    "@nativescript/types": "~8.2.0",
    "@nativescript/webpack": "5.0.6",
    "@ngtools/webpack": "~13.2.0",
    "typescript": "~4.5.5"
  },
  "readme": "NativeScript Application",
  "main": "./src/main.ts"
}

tsconfig.json

{
    "compilerOptions": {
        "module": "esnext",
        "target": "es2017",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true,
       "skipLibCheck": true,
       "skipDefaultLibCheck": true,
        "lib": [
            "dom",
            "es2017"
        ],
        "baseUrl": ".",
        "paths": {
            "~/*": ["src/*"],
            "@/*": ["src/*"]
          },
        "moduleResolution": "node",
        "removeComments": false
    },
    "include": [ "src/**/*.ios.ts"],
    "files": ["./src/main.ts", "./reference.d.ts","./src/polyfills.ts"],
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

I am new to NativeScript and webpack , i have migrated my native script app from 6.5.1 to 8.2 version and using @nativescript/geolocation : "8.0.2" and my references are broken and unable to build my NativeScript App.

enter image description here

enter image description here

Code

import { Injectable } from "@angular/core";
import * as geoLocation from "@nativescript/geolocation";
import { Logger } from "../../shared/default-logger.service";
import { LocationServiceBase } from "./location.service.common";

@Injectable()
export class LocationService extends LocationServiceBase {

    private iosLocManager: CLLocationManager;
    private locManagerDelegate: LocationMangerDelegate;

    constructor(private logger: Logger) {
        super(logger);
        this.iosLocManager = new CLLocationManager();
        this.locManagerDelegate = new LocationMangerDelegate();
        this.iosLocManager.desiredAccuracy = 3;
        this.iosLocManager.distanceFilter = 0.1;
        this.logger.log("before setting delegate");
        this.iosLocManager.delegate = this.locManagerDelegate;
        this.logger.log("after setting delegate");
    }


    protected getDirection(location: geoLocation.Location): number {
        return this.locManagerDelegate.currentHeading;
    }

    startUpdatingHeading(): void {
        this.locManagerDelegate.currentHeading = null;
        this.iosLocManager.startUpdatingHeading();
    }

    stopUpdatingHeading(): void {
        this.iosLocManager.stopUpdatingHeading();
    }
}

export class LocationMangerDelegate extends NSObject implements CLLocationManagerDelegate {
    public static ObjCProtocols = [CLLocationManagerDelegate]; // tslint:disable-line:variable-name

    currentHeading: number;

    locationManagerDidUpdateHeading(locationManager: CLLocationManager, heading: CLHeading): void {
        this.currentHeading = heading.trueHeading;
    }

}

I did not have any luck on google searches and i have spent hours on this .can you please let me know how can I fix these reference issues ? i am stuck here, not sure if i am missing anything.

Package.json

{
  
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "base-64": "^0.1.0",
    "cross-env": "^5.2.0",
    "lodash": "^4.17.11",
    "@nativescript/camera": "5.0.10",
    "nativescript-couchbase": "^1.0.18",
    "nativescript-appversion": "1.4.4",
    "@nativescript/email": "2.0.5",
    "@nativescript/geolocation": "8.0.2",
    "nativescript-phone": "3.0.3",
    "nativescript-screen-orientation": "^2.0.0",
    "nativescript-orientation-free": "2.2.5",
    "nativescript-theme-core": "~1.0.4",
    "reflect-metadata": "~0.1.13",
    "rxjs": "~7.5.0",
    "rxjs-compat": "^6.4.0",
    "utf8": "^3.0.0",
    "zone.js": "~0.11.5",
    "@nativescript/core": "~8.2.0",
    "@nativescript/angular": "^13.0.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.2.0",
    "@angular/compiler-cli": "~13.2.0",
    "@nativescript/ios": "8.2.1",
    "@nativescript/schematics": "~0.5.0",
    "@nativescript/types": "~8.2.0",
    "@nativescript/webpack": "5.0.6",
    "@ngtools/webpack": "~13.2.0",
    "typescript": "~4.5.5"
  },
  "readme": "NativeScript Application",
  "main": "./src/main.ts"
}

tsconfig.json

{
    "compilerOptions": {
        "module": "esnext",
        "target": "es2017",
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true,
        "noEmitHelpers": true,
        "noEmitOnError": true,
       "skipLibCheck": true,
       "skipDefaultLibCheck": true,
        "lib": [
            "dom",
            "es2017"
        ],
        "baseUrl": ".",
        "paths": {
            "~/*": ["src/*"],
            "@/*": ["src/*"]
          },
        "moduleResolution": "node",
        "removeComments": false
    },
    "include": [ "src/**/*.ios.ts"],
    "files": ["./src/main.ts", "./reference.d.ts","./src/polyfills.ts"],
    "exclude": [
        "node_modules",
        "platforms"
    ]
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洛阳烟雨空心柳 2025-01-20 17:41:38

通过将包降级为“@nativescript/types”来修复此问题:“~8.1.1”

fixed this by downgrading the package to "@nativescript/types": "~8.1.1"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文