Skip to content

Instantly share code, notes, and snippets.

@bizz84
Last active October 5, 2023 01:42
Show Gist options
  • Save bizz84/f22883c3d8292344cab1b0caa3debcdd to your computer and use it in GitHub Desktop.
Save bizz84/f22883c3d8292344cab1b0caa3debcdd to your computer and use it in GitHub Desktop.
macOS Podfile template for Flutter apps
# Set the platform at the top
platform :osx, '10.15'
# Rest of the pod file
# Update post_install step
post_install do |installer|
# Ensure pods use the minimum deployment target set above
# https://stackoverflow.com/a/64385584/436422
pods_project = installer.pods_project
deployment_target_key = 'MACOSX_DEPLOYMENT_TARGET'
deployment_targets = pods_project.build_configurations.map{ |config| config.build_settings[deployment_target_key] }
minimum_deployment_target = deployment_targets.min_by{ |version| Gem::Version.new(version) }
puts 'Setting each pod deployment target to ' + minimum_deployment_target
installer.pods_project.targets.each do |target|
flutter_additional_macos_build_settings(target)
target.build_configurations.each do |config|
config.build_settings[deployment_target_key] = minimum_deployment_target
# DT_TOOLCHAIN_DIR fix for Xcode 15
# https://stackoverflow.com/a/77142190
xcconfig_path = config.base_configuration_reference.real_path
xcconfig = File.read(xcconfig_path)
xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment