YandexMapsMobile

Latest release

contact: @lexkraev Telegram Group

Yandex 移动地图(完整版)的 Swift Package 二进制框架。

Yandex 移动地图 NaviKit SDK 版本可以在这里找到。

Yandex 移动地图 Lite 版本可以在这里找到。

🎉 在 Apple Silicon 上无需 Rosetta 模式即可运行(您可以在这里找到手动配置指南)。

要求

Swift Package Manager

要使用 SwiftPM 将 YandexMapsMobile 集成到您的项目中,请执行以下操作 👇🏻

或者将以下代码添加到您的 Package.swift 文件中

dependencies: [
    .package(url: "https://github.com/c-villain/YandexMapsMobile", from: "4.2.2"),
],

或者通过 XcodeGen 插入到您的 project.yml 文件中

name: YourProjectName
options:
  deploymentTarget:
    iOS: 13.0
packages:
  YandexMapsMobile:
    url: https://github.com/c-villain/YandexMapsMobile
    from: 4.2.2
targets:
  YourTarget:
    type: application
    ...
    dependencies:
       - package: YandexMapsMobile

推荐用法

在 Apple Silicon 上无需 Rosetta 模式运行
  1. 您应该使用 vulkanPreferred: true 初始化 YMKMapView
YMKMapView.init(frame: .zero, vulkanPreferred: isM1Simulator())

....

    #if targetEnvironment(simulator)
    public static func isM1Simulator() -> Bool {
        return TARGET_CPU_ARM64 != 0
    }
    #else
    public static func isM1Simulator() -> Bool { false }
    #endif
  1. AppDelegate 中调用 YMKMapKit.sharedInstance(),如示例所示
/**
If you create instance of YMKMapKit not in application:didFinishLaunchingWithOptions: 
you should also explicitly call YMKMapKit.sharedInstance().onStart()
*/
YMKMapKit.sharedInstance()
项目设置的最新建议

要构建项目,您应该在Build Settings (构建设置)选项卡中添加以下linker flags (链接器标志)

frameworks:
    "CoreFoundation",
    "Foundation",
    "CoreLocation",
    "UIKit",
    "OpenGLES",
    "SystemConfiguration",
    "CoreGraphics",
    "QuartzCore",
    "Security",
    "CoreTelephony",
    "CoreMotion",
    "DeviceCheck"
libraries:
    "resolv",
    "c++"

如屏幕截图所示

Screenshot 2024-02-09 at 23 33 46
YandexMapsMobile 作为子包

如果您在您自己的 package 中使用 YandexMapsMobile 作为子依赖,您可能需要将 linkerSettings 添加到目标以成功构建

targets: [
    .target(
        name: "Your target",
        dependencies: [
            .product(name: "YandexMapsMobile", package: "YandexMapsMobile")
        ],
        linkerSettings: [ // <===== ‼️LOOK HERE‼️
            .linkedFramework("CoreLocation"),
            .linkedFramework("CoreTelephony"),
            .linkedFramework("SystemConfiguration"),
            .linkedLibrary("c++"),
            .unsafeFlags(["-ObjC"]),
        ]),
]

或者在项目设置中添加 -ObjC 和 framework "DeviceCheck"

Screenshot 2024-08-14 at 12 50 31

或者通过 XcodeGen 插入 到您的 project.yml 文件中

settings:
  OTHER_LDFLAGS: -ObjC -framework "DeviceCheck"

有关更多详细信息,请查看这里

特别感谢

感谢 Igor Makarovv.4.0.1 版本的贡献

沟通

👨🏻‍💻 欢迎订阅 telegram 中的频道 SwiftUI dev

如果您喜欢这个存储库,请 ⭐ 鼓励一下,让它对其他人有用。