├── .gitignore ├── MapLibreTest.playground ├── playground.xcworkspace │ └── contents.xcworkspacedata ├── contents.xcplayground └── Contents.swift ├── Package.swift ├── LICENSE.md ├── README.md └── .github └── workflows └── release.yml /.gitignore: -------------------------------------------------------------------------------- 1 | /.swiftpm 2 | /.build 3 | -------------------------------------------------------------------------------- /MapLibreTest.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MapLibreTest.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let package = Package( 5 | name: "MapLibre Native", 6 | products: [ 7 | .library( 8 | name: "MapLibre", 9 | targets: ["MapLibre"]) 10 | ], 11 | dependencies: [ 12 | ], 13 | targets: [ 14 | .binaryTarget( 15 | name: "MapLibre", 16 | url: "https://github.com/maplibre/maplibre-native/releases/download/ios-v6.21.2/MapLibre.dynamic.xcframework.zip", 17 | checksum: "53c4f80dca4c3827502093268895e94129280e10094a954406f8d78604af0e0d") 18 | ] 19 | ) 20 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2021 MapLibre contributors 4 | 5 | Copyright (c) 2018-2021 MapTiler.com 6 | 7 | Copyright (c) 2014-2020 Mapbox 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are 11 | met: 12 | 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in 17 | the documentation and/or other materials provided with the 18 | distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 21 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MapLibre Native for iOS 2 | 3 | ![Requires Xcode 12](https://img.shields.io/badge/Xcode-12-1575F9.svg?style=flat&logo=xcode&logoColor=1575F9) 4 | [![Requires Swift 5.3](https://img.shields.io/badge/Swift-5.3-FA7343.svg?style=flat&logo=Swift)](https://swift.org/package-manager/) 5 | [![SPM compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-FA7343.svg?style=flat&logo=Swift)](https://swiftpackageindex.com/maplibre/maplibre-gl-native-distribution) 6 | 7 | > **Note** 8 | > This repository only exists for the purpose of binary distribution of MapLibre Native for iOS on the Swift Package Index. 9 | > Please use the [main MapLibre Native repository](https://github.com/maplibre/maplibre-native) to report issues or ask for help. 10 | 11 | [MapLibre Native](https://github.com/maplibre/maplibre-native) is a community-led fork derived from [mapbox-gl-native](https://github.com/mapbox/mapbox-gl-native) before their switch to a non-OSS license. The fork also includes Maps SDK for iOS and macOS (forked from [mapbox-gl-native-ios](https://github.com/mapbox/mapbox-gl-native-ios)) and Android SDK (forked from [mapbox-gl-native-android](https://github.com/mapbox/mapbox-gl-native-android)). 12 | 13 | --- 14 | 15 | ## Add MapLibre to your Project 16 | 17 | To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL. See [Adding Package Dependencies to Your App.](https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app) 18 | 19 | ## Test MapLibre with a Swift Playgrounds 20 | 21 | When you download this repo there is a Swift Playground that allows you to change the style and play around with a very simple rendered map. 22 | 23 | * Download this repo 24 | * Navigate to the folder where you `clone`d, and open `Package.swift` in at least Xcode 12. 25 | * Run Playground by choosing `Editor` > `Run Playground` or `⇧-⌘-⏎` 26 | * See issue [maplibre-gl-native-distribution#8](https://github.com/maplibre/maplibre-gl-native-distribution/issues/8) for screenshots of the MapLibre for Swift Playgrounds in action. 27 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | download_url: 7 | description: URL where zip containing XCFramework can be downloaded 8 | required: true 9 | type: string 10 | version: 11 | description: Version number of release 12 | required: true 13 | type: string 14 | changelog_url: 15 | description: URL for changelog of release 16 | required: false 17 | type: string 18 | 19 | jobs: 20 | release: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v4 24 | 25 | - name: Download zip, compute checksum 26 | run: | 27 | wget ${{ github.event.inputs.download_url }} 28 | echo checksum="$(swift package compute-checksum MapLibre.dynamic.xcframework.zip)" >> "$GITHUB_ENV" 29 | 30 | - name: Insert new checksum in Package.swift 31 | run: | 32 | sed -i 's#\(checksum: "\)\([^"]*\)#\1${{ env.checksum }}#' Package.swift 33 | 34 | - name: Insert download URL in Package.swift 35 | run: | 36 | sed -i 's#\(url: "\)\([^"]*\)#\1${{ github.event.inputs.download_url }}#' Package.swift 37 | 38 | - name: Validate Package.swift 39 | run: swift package describe 40 | 41 | - name: Push Package.swift 42 | run: | 43 | git add Package.swift 44 | git config --global user.email "git@maplibre.org" 45 | git config --global user.name "GitHub Actions" 46 | git commit -m "Release ${{ github.event.inputs.version }}" 47 | git tag -a ${{ github.event.inputs.version }} -m "Release ${{ github.event.inputs.version }}" 48 | git push --atomic origin main ${{ github.event.inputs.version }} 49 | 50 | - name: Download changelog.md 51 | if: github.event.inputs.changelog_url != '' 52 | run: wget -O changelog.md ${{ github.event.inputs.changelog_url }} 53 | 54 | - name: Create empty changelog.md 55 | if: github.event.inputs.changelog_url == '' 56 | run: touch changelog.md 57 | 58 | - name: Make release 59 | uses: softprops/action-gh-release@v1 60 | with: 61 | name: ${{ github.event.inputs.version }} 62 | tag_name: ${{ github.event.inputs.version }} 63 | prerelease: ${{ contains(github.event.inputs.version, 'pre') }} 64 | body_path: changelog.md 65 | -------------------------------------------------------------------------------- /MapLibreTest.playground/Contents.swift: -------------------------------------------------------------------------------- 1 | /*: 2 | * The MapLibre Test Playground demonstrates basic rendering of a Mapbox style using the current MapLibre binary. 3 | * Useful for testing the data in the`binaryTarget[]` in this Swift Package repo. 4 | * Downloads the MapLibre `.xcframework` and creates a simple map, thereby testing the Swift Package Manager workflow. 5 | * Add your style for basic rendering tests. 6 | * Using the same style, demonstrate how to use `MGLMapSnapshotter`. 7 | */ 8 | 9 | import UIKit 10 | import PlaygroundSupport 11 | import MapLibre 12 | 13 | // Create a map set its dimensions 14 | let width: CGFloat = 640 15 | let height: CGFloat = 480 16 | 17 | let mapView = MLNMapView(frame: CGRect(x: 0, y: 0, width: width, height: height)) 18 | mapView.frame = CGRect(x: 0, y: 0, width: width, height: height) 19 | 20 | // shows the result of running the code this far 21 | PlaygroundPage.current.liveView = mapView 22 | 23 | // Hide logo & attribution button 24 | mapView.logoView.isHidden = true 25 | mapView.attributionButton.isHidden = true 26 | 27 | // enable debugging tile features 28 | mapView.debugMask = MLNMapDebugMaskOptions(rawValue: 29 | MLNMapDebugMaskOptions.collisionBoxesMask.rawValue + // Edges of glyphs and symbols 30 | MLNMapDebugMaskOptions.timestampsMask.rawValue + // shows a timestamp indicating when it was loaded. 31 | MLNMapDebugMaskOptions.tileBoundariesMask.rawValue + // Edges of tile boundaries 32 | MLNMapDebugMaskOptions.tileInfoMask.rawValue // tile coordinate (x/y/z) 33 | ) 34 | 35 | // Set Style 36 | var styleJSON = "https://demotiles.maplibre.org/style.json" 37 | 38 | mapView.styleURL = URL(string: styleJSON) 39 | mapView.setCenter(CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0), zoomLevel: 3, animated: false) 40 | 41 | // MGLMapSnapshotter example code 42 | var image: UIImage? 43 | let camera = MLNMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 0, longitude: 0), altitude: 100, pitch: 75, heading: 45) 44 | 45 | let options = MLNMapSnapshotOptions(styleURL: URL(string: styleJSON), camera: camera, size: CGSize(width: width, height: height)) 46 | options.zoomLevel = mapView.zoomLevel 47 | 48 | let snapshotter = MLNMapSnapshotter(options: options) 49 | // Awaiting https://github.com/maplibre/maplibre-native/issues/1979 50 | //snapshotter.start { (snapshot, error) in 51 | // if let error = error { 52 | // fatalError(error.localizedDescription) 53 | // } 54 | // 55 | // image = snapshot?.image 56 | //} 57 | 58 | --------------------------------------------------------------------------------