From f486fc1d767e95f7695d4c00131db0739efd70b2 Mon Sep 17 00:00:00 2001 From: Jakub Kasprzyk Date: Mon, 14 Sep 2026 14:40:01 +0200 Subject: [PATCH 1/2] fix(ios): make podspec helpers visible inside the spec block CocoaPods loads a podspec with `eval` from `Pod._eval_podspec`, so a top-level `def` in the file becomes an instance method of the `Pod` module and is not callable from the `Pod::Spec.new` block, where `self` is that module. Since #51 every `pod install` of this package failed with `undefined method 'better_maps_ios_google_provider_enabled?' for module Pod` on every Ruby and CocoaPods version, so a release cut from main could not be installed on iOS. Define the Podfile.properties helpers as local lambdas instead. This is the podspec hunk from #67, applied byte-identically so that branch rebases cleanly. --- package/react-native-better-maps.podspec | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/package/react-native-better-maps.podspec b/package/react-native-better-maps.podspec index a0dfe50..357b462 100644 --- a/package/react-native-better-maps.podspec +++ b/package/react-native-better-maps.podspec @@ -2,12 +2,16 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) -def better_maps_podfile_properties +# Helpers are lambdas in local variables rather than top-level `def`s: CocoaPods +# evaluates a podspec with `eval`, and a method defined that way is not visible +# from inside the `Pod::Spec.new` block on every Ruby / CocoaPods combination +# (Ruby 4.0 + CocoaPods 1.17 raises `undefined method ... for module Pod`). +better_maps_podfile_properties = lambda do installation_root = Pod::Config.instance.installation_root - return {} if installation_root.nil? + next {} if installation_root.nil? podfile_properties_path = File.join(installation_root, 'Podfile.properties.json') - return {} unless File.exist?(podfile_properties_path) + next {} unless File.exist?(podfile_properties_path) JSON.parse(File.read(podfile_properties_path)) rescue StandardError => e @@ -15,10 +19,9 @@ rescue StandardError => e {} end -def better_maps_ios_google_provider_enabled? - # Must match IOS_GOOGLE_PROVIDER_PODFILE_PROPERTY in plugin/src/ios.ts - better_maps_podfile_properties['betterMaps.iosGoogleProvider'] == 'true' -end +# Must match IOS_GOOGLE_PROVIDER_PODFILE_PROPERTY in plugin/src/ios.ts +better_maps_ios_google_provider_enabled = + better_maps_podfile_properties.call['betterMaps.iosGoogleProvider'] == 'true' Pod::Spec.new do |s| s.name = 'react-native-better-maps' @@ -48,7 +51,7 @@ Pod::Spec.new do |s| s.dependency 'React-jsi' s.dependency 'React-callinvoker' - if better_maps_ios_google_provider_enabled? + if better_maps_ios_google_provider_enabled s.dependency 'GoogleMaps' end From df1f5a97050e9e52e8cb85cd1dc4997d2f62cea5 Mon Sep 17 00:00:00 2001 From: Jakub Kasprzyk Date: Mon, 14 Sep 2026 14:50:37 +0200 Subject: [PATCH 2/2] fix(ios): rescue ::StandardError and ignore non-object Podfile.properties.json The podspec runs with module `Pod` as its lexical scope, so a bare `rescue StandardError` resolved to `Pod::StandardError` and never caught `JSON::ParserError`; a malformed Podfile.properties.json still broke `pod install`. Qualify the constant, and treat a valid JSON document that is not an object (`null`, an array, a scalar) as no properties instead of raising on the key lookup. --- package/react-native-better-maps.podspec | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package/react-native-better-maps.podspec b/package/react-native-better-maps.podspec index 357b462..fdb0dd2 100644 --- a/package/react-native-better-maps.podspec +++ b/package/react-native-better-maps.podspec @@ -13,8 +13,14 @@ better_maps_podfile_properties = lambda do podfile_properties_path = File.join(installation_root, 'Podfile.properties.json') next {} unless File.exist?(podfile_properties_path) - JSON.parse(File.read(podfile_properties_path)) -rescue StandardError => e + properties = JSON.parse(File.read(podfile_properties_path)) + next properties if properties.is_a?(Hash) + + Pod::UI.warn "[react-native-better-maps] Podfile.properties.json is not a JSON object. iOS Google Maps provider will be disabled." + {} +# `::` is required: this file is evaluated inside module `Pod`, where a bare +# `StandardError` resolves to `Pod::StandardError` and would not catch JSON errors. +rescue ::StandardError => e Pod::UI.warn "[react-native-better-maps] Failed to read Podfile.properties.json: #{e.message}. iOS Google Maps provider will be disabled." {} end