-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patching `RCTNativeAnimatedNodesManager.h` is not needed anymore.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'cocoapods' | ||
require 'cocoapods-fix-react-native/helpers/root_helper' | ||
|
||
# Obtain the React Native root directory | ||
$root = get_root | ||
|
||
# Detect CocoaPods + Frameworks | ||
$has_frameworks = File.exists?'Pods/Target Support Files/React/React-umbrella.h' | ||
|
||
# TODO: move to be both file in pods and file in node_mods? | ||
def patch_pod_file(path, old_code, new_code) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
koenpunt
Collaborator
|
||
file = File.join($root, path) | ||
unless File.exist?(file) | ||
Pod::UI.warn "#{file} does not exist so was not patched.." | ||
return | ||
end | ||
code = File.read(file) | ||
if code.include?(old_code) | ||
Pod::UI.message "Patching #{file}", '- ' | ||
FileUtils.chmod('+w', file) | ||
File.write(file, code.sub(old_code, new_code)) | ||
end | ||
end | ||
|
||
# Detect source file dependency in the generated Pods.xcodeproj workspace sub-project | ||
def has_pods_project_source_file(source_filename) | ||
pods_project = 'Pods/Pods.xcodeproj/project.pbxproj' | ||
File.open(pods_project).grep(/#{source_filename}/).any? | ||
end | ||
|
||
# Detect dependent source file required for building when the given source file is present | ||
def meets_pods_project_source_dependency(source_filename, dependent_source_filename) | ||
has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true | ||
end | ||
|
||
def detect_missing_subspec_dependency(subspec_name, source_filename, dependent_source_filename) | ||
unless meets_pods_project_source_dependency(source_filename, dependent_source_filename) | ||
Pod::UI.warn "#{subspec_name} subspec may be required given your current dependencies" | ||
end | ||
end | ||
|
||
def detect_missing_subspecs | ||
return unless $has_frameworks | ||
|
||
# For CocoaPods + Frameworks, RCTNetwork and CxxBridge subspecs are necessary for DevSupport. | ||
# When the React pod is generated it must include all the required source, and see umbrella deps. | ||
detect_missing_subspec_dependency('RCTNetwork', 'RCTBlobManager.mm', 'RCTNetworking.mm') | ||
detect_missing_subspec_dependency('CxxBridge', 'RCTJavaScriptLoader.mm', 'RCTCxxBridge.mm') | ||
|
||
# RCTText itself shouldn't require DevSupport, but it depends on Core -> RCTDevSettings -> RCTPackagerClient | ||
detect_missing_subspec_dependency('DevSupport', 'RCTDevSettings.mm', 'RCTPackagerClient.m') | ||
end | ||
|
||
detect_missing_subspecs |
This function is no longer used, so can be removed