cocoapods-fix-react-native 2018.05.08.12 → 2018.05.15.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d452130716e5b82aea3c9aa20b5bd298c85d791ae01ec3235878d9391cfbe4e
4
- data.tar.gz: 64c364164538ce87679fe68f8e2b80ab5096fd19951b9440e26362fe4c15bdb5
3
+ metadata.gz: f0c24a7e0935483ebcfb923f5c77113726c4911bc194909c1c0bb06e0db44b50
4
+ data.tar.gz: 51757c7b80287a270844c41ac7fd58ac68abe2ae6db438a2994346e5b81b836a
5
5
  SHA512:
6
- metadata.gz: b51d3d997cbfd1a166dd3785a13766fc6ebd01300dd0adae369a8bffb27060a4636ae3b776e54a275b5e82cce4e559881681d6789f75e46e92ece544bdb3341d
7
- data.tar.gz: 4d84dc504f859de11658f7f6790595c40e649442c07f4b1028985ce121a9ab0ea28cf9cb473d9205edc9b3aea445328ba71cce8df3a6496cdb876082eed6f01c
6
+ metadata.gz: 71d0bc6687243ed39896e4bda09dcb1aa600bf9b6aa4078bd8925574bdd377aa1b2df21a28edee47b48e23ade184a6b16a71426df5fa1a91f48b8f57d236fffa
7
+ data.tar.gz: 2110e976a1e16ad18c73400a1adc327e9c0b6d9520339b10e1e9848429d9324ffaca2c635275ee4d2c6b0c189d79670cdcb6f6907e295c24c4202c25f9bdea55
@@ -0,0 +1,141 @@
1
+ require 'cocoapods'
2
+
3
+ # Notes:
4
+ #
5
+ # - All file paths should be relative to the React repo, rather than the Pods dir, or node_modules
6
+ #
7
+
8
+ # Are you using :path based Pods?
9
+ dev_pods_react = !File.directory?('Pods/React/React')
10
+
11
+ # Detect CocoaPods + Frameworks
12
+ $has_frameworks = File.exists?'Pods/Target Support Files/React/React-umbrella.h'
13
+
14
+ # Check for whether we're in a project that uses relative paths
15
+ same_repo_node_modules = File.directory?('node_modules/react-native')
16
+ previous_repo_node_modules = File.directory?('../node_modules/react-native')
17
+
18
+ # Find out where the files could be rooted
19
+ $root = 'Pods/React'
20
+ if dev_pods_react
21
+ $root = 'node_modules/react-native' if same_repo_node_modules
22
+ $root = '../node_modules/react-native' if previous_repo_node_modules
23
+ end
24
+
25
+ # TODO: move to be both file in pods and file in node_mods?
26
+ def patch_pod_file(path, old_code, new_code)
27
+ file = File.join($root, path)
28
+ unless File.exist?(file)
29
+ Pod::UI.warn "#{file} does not exist so was not patched.."
30
+ return
31
+ end
32
+ code = File.read(file)
33
+ if code.include?(old_code)
34
+ Pod::UI.message "Patching #{file}", '- '
35
+ FileUtils.chmod('+w', file)
36
+ File.write(file, code.sub(old_code, new_code))
37
+ end
38
+ end
39
+
40
+ def fix_unused_yoga_headers
41
+ filepath = 'Pods/Target Support Files/yoga/yoga-umbrella.h'
42
+ # This only exists when using CocoaPods + Frameworks
43
+ return unless File.exists?(filepath)
44
+
45
+ contents = []
46
+ file = File.open(filepath, 'r')
47
+ file.each_line do |line|
48
+ contents << line
49
+ end
50
+ file.close
51
+
52
+ if contents[12].include? 'Utils.h'
53
+ Pod::UI.message "Patching #{filepath}", '- '
54
+ contents.delete_at(14) # #import "YGLayout.h"
55
+ contents.delete_at(15) # #import "YGNode.h"
56
+ contents.delete_at(15) # #import "YGNodePrint.h"
57
+ contents.delete_at(15) # #import "YGStyle.h"
58
+ contents.delete_at(15) # #import "Yoga-internal.h"
59
+ contents.delete_at(12) # #import "Utils.h"
60
+
61
+ file = File.open(filepath, 'w') do |f|
62
+ f.puts(contents)
63
+ end
64
+ end
65
+ end
66
+
67
+ # Detect source file dependency in the generated Pods.xcodeproj workspace sub-project
68
+ def has_pods_project_source_file(source_filename)
69
+ pods_project = 'Pods/Pods.xcodeproj/project.pbxproj'
70
+ File.open(pods_project).grep(/#{source_filename}/).any?
71
+ end
72
+
73
+ # Detect dependent source file required for building when the given source file is present
74
+ def meets_pods_project_source_dependency(source_filename, dependent_source_filename)
75
+ has_pods_project_source_file(source_filename) ? has_pods_project_source_file(dependent_source_filename) : true
76
+ end
77
+
78
+ def detect_missing_subspec_dependency(subspec_name, source_filename, dependent_source_filename)
79
+ unless meets_pods_project_source_dependency(source_filename, dependent_source_filename)
80
+ Pod::UI.warn "#{subspec_name} subspec may be required given your current dependencies"
81
+ end
82
+ end
83
+
84
+ def detect_missing_subspecs
85
+ return unless $has_frameworks
86
+
87
+ # For CocoaPods + Frameworks, RCTNetwork and CxxBridge subspecs are necessary for DevSupport.
88
+ # When the React pod is generated it must include all the required source, and see umbrella deps.
89
+ detect_missing_subspec_dependency('RCTNetwork', 'RCTBlobManager.mm', 'RCTNetworking.mm')
90
+ detect_missing_subspec_dependency('CxxBridge', 'RCTJavaScriptLoader.mm', 'RCTCxxBridge.mm')
91
+
92
+ # RCTText itself shouldn't require DevSupport, but it depends on Core -> RCTDevSettings -> RCTPackagerClient
93
+ detect_missing_subspec_dependency('DevSupport', 'RCTDevSettings.mm', 'RCTPackagerClient.m')
94
+ end
95
+
96
+ fix_unused_yoga_headers
97
+ detect_missing_subspecs
98
+
99
+ # # https://github.com/facebook/react-native/pull/14664
100
+ animation_view_file = 'Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h'
101
+ animation_view_old_code = 'import <RCTAnimation/RCTValueAnimatedNode.h>'
102
+ animation_view_new_code = 'import "RCTValueAnimatedNode.h"'
103
+ patch_pod_file animation_view_file, animation_view_old_code, animation_view_new_code
104
+
105
+ # https://github.com/facebook/react-native/issues/13198
106
+ # Only needed when you have the DevSupport subspec
107
+ has_dev_support = File.exist?(File.join($root, 'Libraries/WebSocket/RCTReconnectingWebSocket.m'))
108
+
109
+ if has_dev_support
110
+ # Move Fishhook to be based on RN's imports
111
+ websocket = 'Libraries/WebSocket/RCTReconnectingWebSocket.m'
112
+ websocket_old_code = 'import <fishhook/fishhook.h>'
113
+ websocket_new_code = 'import <React/fishhook.h>'
114
+ patch_pod_file websocket, websocket_old_code, websocket_new_code
115
+ else
116
+ # There's a link in the DevSettings to dev-only import
117
+ filepath = "#{$root}/React/Modules/RCTDevSettings.mm"
118
+ contents = []
119
+ file = File.open(filepath, 'r')
120
+ found = false
121
+ file.each_line do |line|
122
+ contents << line
123
+ end
124
+ file.close
125
+
126
+ comment_start = '#if ENABLE_PACKAGER_CONNECTION'
127
+ comment_end = '#endif'
128
+
129
+ if contents[20].include? 'RCTPackagerClient.h'
130
+ Pod::UI.message "Patching #{filepath}", '- '
131
+ contents.insert(20, comment_start)
132
+ contents.insert(22, comment_end)
133
+
134
+ contents.insert(205, comment_start)
135
+ contents.insert(229, comment_end)
136
+
137
+ file = File.open(filepath, 'w') do |f|
138
+ f.puts(contents)
139
+ end
140
+ end
141
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-fix-react-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 2018.05.08.12
4
+ version: 2018.05.15.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Orta Therox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-08 00:00:00.000000000 Z
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,6 +59,7 @@ files:
59
59
  - lib/cocoapods-fix-react-native/versions/0_54_2-post.rb
60
60
  - lib/cocoapods-fix-react-native/versions/0_54_4-post.rb
61
61
  - lib/cocoapods-fix-react-native/versions/0_55_3-post.rb
62
+ - lib/cocoapods-fix-react-native/versions/0_55_4-post.rb
62
63
  - lib/cocoapods_plugin.rb
63
64
  - spec/command/native_spec.rb
64
65
  - spec/spec_helper.rb