I have a react native app and I am trying to figure out whether updating certain pods broke parts of the application. When I run pod install, I can in the podfile.lock that over a dozen pods updated, but none of these pods are listed in the actual podfile? I imagine they are dependencies of the pods that I HAVE listed there, but the podfile.lock does not appear to specify that(as opposed to, for example, a package-lock.json file in npm which more clearly shows a depdency tree). I know how to pin pods to versions to prevent updates with breaking changes to my app from occuring automatically,but based on the lock I am not sure which pods to pin...
Here is my podfile:
platform :ios, '10.0'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
target 'my_mobileapp' do
rn_maps_path = '../node_modules/react-native-maps'
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
# react-native-maps dependencies
pod 'react-native-google-maps', path: rn_maps_path
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
target 'my_mobileappTests' do
inherit! :search_paths
# Pods for testing
end
use_unimodules!
use_native_modules!
end
post_install do |installer|
## Fix for XCode 12.5
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm", "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm", "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
if target.name == "React"
target.remove_from_project
end
if target.name == 'yoga'
target.remove_from_project
target.build_configurations.each do |config|
config.build_settings['GCC_TREAT_WARNINGS_AS_ERRORS'] = 'NO'
config.build_settings['GCC_WARN_64_TO_32_BIT_CONVERSION'] = 'NO'
end
end
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
puts "Updating #{target.name}"
end
# https://github.com/microsoft/react-native-code-push/issues/1597
# uncomment this to do a new pod install locally - do not commit or it will not build on the server
# work_dir = Dir.pwd
# Dir.glob("Pods/Target Support Files/Pods-my_mobileapp/*.xcconfig") do |xc_config_filename|
# xcconfig_path = "#{work_dir}/#{xc_config_filename}"
# read from xcconfig to build_settings dictionary
# build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.split(/\s*=\s*/, 2)}.flatten]
# modify OTHER_LDFLAGS to prevent certain libraries from (double) linking
# build_settings['OTHER_LDFLAGS'] = build_settings['OTHER_LDFLAGS'].sub('-l"Base64"', '').sub('-l"SSZipArchive"', '').sub('-l"JWT"', '')
# write build_settings dictionary to xcconfig
# File.open(xcconfig_path, "w") {
# |file| build_settings.each do |key,value| file.puts "#{key} = #{value}" end
# }
# end
end
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir '*/'].each(&method(:find_and_replace))
end
And here is a screengrab of some of the pods that are updating, none of which are directly listed in the podfile:
CodePudding user response:
Libraries with native iOS code will have their own Podfile and Podfile.lock. You can find these inside node_modules/<package>/ios
. You could write a shell script to go through your dependencies and add any pods it finds.
However, that shouldn't be necessary, because when pods update, it means the package that depends on them has updated. So you should be able to look for changes/ revert to previous versions in your package.json
and test that. I don't recommend going in and changing dependencies' dependencies - it's pretty likely to break something. If it does fix your issue, you have to patch the package, at which point it's not really supported by the maintainers.
Final note, make sure you're using exact version numbers in package.json, i.e.
...
"packageName", "2.0.0", // like this
..., "~2.0.0", // not this
..., ">2.0.0", // or this
This will ensure you always get the same version when you're switching around.