2***@qq.com
2***@qq.com
  • 发布:2026-07-17 17:07
  • 更新:2026-07-17 17:09
  • 阅读:49

error: 'UTSSourceMapPosition' is unavailable: cannot find Swift declaration for this class‌

分类:uts

‌⁠error: 'UniNativeViewElement' is unavailable: cannot find Swift declaration for this protocol‌
at uni_modules/jiannor-sckd-amap/utssdk/app-ios/AMapDelegate.swift:7:27
5 |
6 | public class AMapDelegate: NSObject, MAMapViewDelegate, UIGestureRecognizerDelegate {
7 | private var _element: UniNativeViewElement
| ^
8 | private var isUserAction: Bool = false
9 | private var isFirst: Bool = false
‌⁠error: 'UniNativeViewElement' is unavailable: cannot find Swift declaration for this protocol‌
at uni_modules/jiannor-sckd-amap/utssdk/app-ios/AMapDelegate.swift:11:32
9 | private var isFirst: Bool = false
10 |
11 | @objc public init(element: UniNativeViewElement) {
| ^
12 | self._element = element
13 | super.init()
‌⁠error: 'UniNativeViewElement' is unavailable: cannot find Swift declaration for this protocol‌
at uni_modules/jiannor-sckd-amap/utssdk/app-ios/AMapMarkerDelegate.swift:19:26
17 |
18 | public class AMapMarkerDelegate: AMapDelegate, CLLocationManagerDelegate {
19 | private var element: UniNativeViewElement
| ^
20 | private let customInfoWindowTag = 99001
21 | private var markerViewMap: [String: MAAnnotationView] = [:]
‌⁠error: 'UniNativeViewElement' is unavailable: cannot find Swift declaration for this protocol‌
at uni_modules/jiannor-sckd-amap/utssdk/app-ios/AMapMarkerDelegate.swift:30:35
28 | private var headingManager: CLLocationManager?
29 |
30 | public override init(element: UniNativeViewElement) {
| ^
31 | self.element = element
32 | super.init(element: element)
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/AMapMarkerDelegate.swift:86:38
84 | private var polygonRendererMap: [ObjectIdentifier: MAPolygonRenderer] = [:]
85 |
86 | public func addMarker(
options: UTSJSONObject, map: MAMapView, success: MarkerCallback?) {
| ^
87 | let ann = CustomAnnotation()
88 | if let lat = options["latitude"] as? Double, let lon = options["longitude"] as? Double {
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/Tools.swift:167:48
165| }
166|
167| @objc public class func createPolyline(
obj: UTSJSONObject?) -> MAPolyline? {
| ^
168| guard let obj = obj else { return nil }
169| let rawAny = obj.getAny("points") ?? obj.getAny("point")
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/Tools.swift:215:47
213| }
214|
215| @objc public class func createPolygon(
obj: UTSJSONObject?) -> MAPolygon? {
| ^
216| guard let obj = obj else { return nil }
217| let rawAny = obj.getAny("points") ?? obj.getAny("point")
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/Tools.swift:263:54
261| }
262|
263| @objc public class func calculatePolygonArea(
obj: UTSJSONObject?) -> NSNumber {
| ^
264| guard let obj = obj else { return NSNumber(value: 0) }
265| let rawAny = obj.getAny("points") ?? obj.getAny("point")
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/Tools.swift:311:77
309| }
310|
311| @objc public class func updatePolyline(
polyline: MAPolyline?, pointsObj: UTSJSONObject?) {
| ^
312| guard let polyline = polyline, let obj = pointsObj else { return }
313| let rawAny = obj.getAny("points") ?? obj.getAny("point")
‌⁠error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌
at unimodules/jiannor-sckd-amap/utssdk/app-ios/Tools.swift:357:74
355| }
356|
357| @objc public class func updatePolygon(
polygon: MAPolygon?, pointsObj: UTSJSONObject?) {
| ^
358| guard let polygon = polygon, let obj = pointsObj else { return }
359| let rawAny = obj.getAny("points") ?? obj.getAny("point")
‌⁠error: cannot find type 'UTSObject' in scope‌
at uni_modules/jiannor-sckd-amap/utssdk/interface.uts:29:12
27 |
28 |
29 | export type UniLatLng = {
| ^
30 | latitude : number,
31 | longitude : number
‌⁠error: cannot find type 'IUTSSourceMap' in scope‌
at uni_modules/jiannor-sckd-amap/utssdk/interface.uts:29:12
27 |
28 |
29 | export type UniLatLng = {
| ^
30 | latitude : number,
31 | longitude : number
‌⁠error: uni_modules/jiannor-sckd-amap/utssdk/app-ios/src/index.swift:18:45: error: 'UTSSourceMapPosition' is unavailable: cannot find Swift declaration for this class‌
‌⁠error: uni_modules/jiannor-sckd-amap/utssdk/app-ios/src/index.swift:41:24: error: 'UTSJSONObject' is unavailable: cannot find Swift declaration for this class‌

2026-07-17 17:07 负责人:无 分享
已邀请:
Ask小助手

Ask小助手 - Ask社区AI助手

欢迎到专业群( uni-app x技术交流群 ) 咨询,群中有相关专业的管理员和群友。

这个错误的核心原因是 ios 端 uts 插件编译时,swift 编译器无法找到 DCloudUniappRuntime 框架中的类型声明(如 UTSSourceMapPositionUniNativeViewElementUTSJSONObject 等),导致所有依赖这些类型的代码都报 "unavailable: cannot find swift declaration" 错误。

根据 issue 系统中的相关记录,这类问题通常与 xcode 版本与 hbuilderx 打包环境不匹配 有关。官方在 issue 24338 中明确回复:"这个是很明显的开发者 xcode 版本低于打包机 xcode 版本的问题,升级一下 xcode 就可以。"

同时,根据 issue 19450 的记录,在 ios 端 uts 插件通过 config.json 配置了 cocoapods 远程依赖后,也出现了完全相同的 'UTSSourceMapPosition' is unavailable 错误,该 issue 被标记为"误报",说明问题出在本地环境配置而非代码本身。

排查步骤:

  1. 检查 xcode 版本:在终端执行 xcodebuild -version,确认版本是否为 xcode 15.2 或更高。如果版本过低,升级 xcode 后重新编译。

  2. 检查 hbuilderx 的 ios 运行环境配置:在 hbuilderx 的设置 - 运行配置中,确认 ios 运行环境是否正确配置,包括 sdkDirtargettool 等参数是否指向正确的 xcode 路径。

  3. 确认 cocoapods 依赖的影响:如果该插件(jiannor-sckd-amap)的 config.json 中配置了 dependencies-pods,尝试暂时移除 pods 依赖后重新编译,确认是否是 cocoapods 配置导致编译环境异常。对话知识库中有用户遇到完全相同的问题——不添加第三方依赖时正常,添加后即报此错。

  4. 检查 command line tools 路径:执行 xcode-select -p,确认路径指向 /Applications/Xcode.app/Contents/Developer 而非 /Library/Developer/CommandLineTools。如果不正确,执行 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer 修正。

  5. 清理编译缓存:删除项目 unpackage 目录下的 ios 编译缓存,重新运行。

如果以上步骤均无法解决,建议直接提交 issue 到 https://issues.dcloud.net.cn/ ,并附上完整的复现工程(包括 hbuilderx 版本、xcode 版本、插件配置信息),以便官方定位问题。

内容为 AI 生成,仅供参考

要回复问题请先登录注册