Created
March 13, 2024 03:06
-
-
Save zhenguet/4f85dcfaae5c054f19aff77ce19fe90f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resolve react_native_pods.rb with node to allow for hoisting | |
require Pod::Executable.execute_command('node', ['-p', | |
'require.resolve( | |
"react-native/scripts/react_native_pods.rb", | |
{paths: [process.argv[1]]}, | |
)', __dir__]).strip | |
platform :ios, 13.4 | |
prepare_react_native_project! | |
def share_pods (target_name) | |
# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set. | |
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded | |
# | |
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js` | |
# ```js | |
# module.exports = { | |
# dependencies: { | |
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}), | |
# ``` | |
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled | |
linkage = ENV['USE_FRAMEWORKS'] | |
if linkage != nil | |
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green | |
use_frameworks! :linkage => linkage.to_sym | |
end | |
target target_name do | |
pod 'react-native-google-maps', :path => '../node_modules/react-native-maps' | |
pod 'react-native-maps', :path => '../node_modules/react-native-maps' | |
pod 'RNFS', :path => '../node_modules/react-native-fs' | |
pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' | |
config = use_native_modules! | |
use_react_native!( | |
:path => config[:reactNativePath], | |
# Enables Flipper. | |
# | |
# Note that if you have use_frameworks! enabled, Flipper will not work and | |
# you should disable the next line. | |
:flipper_configuration => flipper_config, | |
# An absolute path to your application root. | |
:app_path => "#{Pod::Config.instance.installation_root}/.." | |
) | |
post_install do |installer| | |
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202 | |
react_native_post_install( | |
installer, | |
config[:reactNativePath], | |
:mac_catalyst_enabled => false | |
) | |
installer.pods_project.targets.each do |target| | |
if target.name == "React-Core.common-AccessibilityResources" | |
target.remove_from_project | |
end | |
target.build_configurations.each do |config| | |
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO' | |
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' | |
config.build_settings['OTHER_SWIFT_FLAGS'] = '-no-verify-emitted-module-interface' | |
end | |
if (target.name&.eql?('FBReactNativeSpec')) | |
target.build_phases.each do |build_phase| | |
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs')) | |
target.build_phases.move(build_phase, 0) | |
end | |
end | |
end | |
end | |
installer.generated_projects.each do |project| | |
project.targets.each do |target| | |
target.build_configurations.each do |config| | |
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.4' | |
end | |
end | |
end | |
xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1` | |
installer.pods_project.targets.each do |target| | |
target.build_configurations.each do |config| | |
# For xcode 15+ only | |
if config.base_configuration_reference && Integer(xcode_base_version) >= 15 | |
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 | |
installer.pods_project.build_configurations.each do |config| | |
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" | |
end | |
end | |
end | |
end | |
share_pods('Demo') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment