Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ Updated MapLibre on Android to 9.5.2 ([#1780](https://github.com/rnmapbox/maps/p
#### Breaking changes:

The setup was changed - see install instructions for more details. In a nuthsell:
* On both android and ios to select mapbox implementation use `RNMabpoxMapsImpl` variable which can be one of (`maplibre`,`mapbox`(aka v10),`mapbox-gl`)
* Package name was changed from `@react-native-mapbox-gl/maps` to `@rnmapbox/maps`. If you just testing with the v10 branch you can use something like [babel-plugin-transform-rename-import](https://www.npmjs.com/package/babel-plugin-transform-rename-import) to change all your source files.
* On both android/ios to select mapbox implementation use `RNMabpoxMapsImpl`/`$RNMapboxMaps` variable which can be one of (`maplibre`,`mapbox`(aka v10),`mapbox-gl`)
* On Podfile `$RNMBGL.(pre|post)_install` was changed `$RNMapboxMaps.(pre|post)_install`
* Package name was changed from `@react-native-mapbox-gl/maps` to `@rnmapbox/maps`. If you just testing with the v10 version you can use something like [babel-plugin-transform-rename-import](https://www.npmjs.com/package/babel-plugin-transform-rename-import) to keep using the old imports for a while.

#### Changes:

Expand Down
2 changes: 1 addition & 1 deletion android/rctmgl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${safeExtGet('kotlinVersion', '1.4.10')}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : '1.4.10'}"
}
}

Expand Down
4 changes: 0 additions & 4 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ buildscript {
}
}

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

allprojects {
repositories {
mavenCentral()
Expand Down
40 changes: 39 additions & 1 deletion rnmapbox-maps.podspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Customization:
# $RNMapboxMapsImpl - one of (maplibre, mapbox, mapbox-gl)
# $RNMapboxMapsVersion - version specification ("~> 10.4.0", "~> 5.9.0" or "exactVersion 5.12.1" mapblibre/SPM)
# $RNMapboxMapsSwiftPackageManager can be either
# "manual" - you're responsible for the Mapbox lib dependency either using cocoapods or SPM
# Hash - ```
# {
# url: "https://github.com/maplibre/maplibre-gl-native-distribution",
# requirement: {
# kind: 'exactVersion',
# version: 5.12.1,
# },
# product_name: "Mapbox"
# }
# ```

require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Expand Down Expand Up @@ -84,7 +100,6 @@ when 'maplibre'
end

unless $RNMapboxMapsSwiftPackageManager
puts "Init SPM"
$RNMapboxMapsSwiftPackageManager = {
url: "https://github.com/maplibre/maplibre-gl-native-distribution",
requirement: {
Expand All @@ -100,6 +115,18 @@ end

$RNMapboxMaps = Object.new

def $RNMapboxMaps._check_no_mapbox_spm(project)
pkg_class = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
ref_class = Xcodeproj::Project::Object::XCSwiftPackageProductDependency
pkg = project.root_object.package_references.find { |p| p.class == pkg_class && [
"https://github.com/maplibre/maplibre-gl-native-distribution",
"https://github.com/mapbox/mapbox-maps-ios.git"
].include?(p.repositoryURL) }
if pkg
puts "!!! Warning: Duplicate Mapbox dependency found, it's consumed by both SwiftPackageManager and CocoaPods"
end
end

def $RNMapboxMaps._add_spm_to_target(project, target, url, requirement, product_name)
pkg_class = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
ref_class = Xcodeproj::Project::Object::XCSwiftPackageProductDependency
Expand All @@ -121,6 +148,8 @@ end

def $RNMapboxMaps.post_install(installer)
if $RNMapboxMapsSwiftPackageManager
return if $RNMapboxMapsSwiftPackageManager == "manual"

spm_spec = $RNMapboxMapsSwiftPackageManager
project = installer.pods_project
self._add_spm_to_target(
Expand All @@ -144,6 +173,15 @@ def $RNMapboxMaps.post_install(installer)
end
end
end
else
self._check_no_mapbox_spm(installer.pods_project)
installer.aggregate_targets.group_by(&:user_project).each do |project, targets|
targets.each do |target|
target.user_targets.each do |user_target|
self._check_no_mapbox_spm(project)
end
end
end
end
end

Expand Down