react_native_util 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +71 -47
- data/lib/assets/templates/Podfile-target.erb +5 -0
- data/lib/assets/templates/Podfile.erb +27 -15
- data/lib/react_native_util/converter.rb +11 -7
- data/lib/react_native_util/core_ext/xcodeproj.rb +14 -2
- data/lib/react_native_util/metadata.rb +3 -1
- data/lib/react_native_util/project.rb +57 -10
- metadata +3 -3
- data/lib/assets/patches/version.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa319e0b3ab7bd33e291b6419ca22f7bd242232ab76ee8092ddb8a8c431efcfa
|
4
|
+
data.tar.gz: 5344825ec01dfd74ac223a49dc4967baac3ed11ed1681725771280f3d143f316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8e5d7f9bff4dc2588a67514404ef1dec9c4a3969ed8f2dd0e4823f01b093ed4a5580cba81c9fb456b50b27301886afec7c33c6a45bb48a2a2d2e697bb66115d
|
7
|
+
data.tar.gz: dce01aeb806ecefeeabb787cd698ff63197e8a3c3b3eaf426ee4229eee9b1c86fcddbd8f3f8ae2f7580f55103ab8f89dc52145a787f8a69a6877cbfbb44def1d
|
data/README.md
CHANGED
@@ -135,52 +135,75 @@ git status
|
|
135
135
|
|
136
136
|
_Typical command output:_
|
137
137
|
```
|
138
|
-
2019-05-
|
139
|
-
2019-05-
|
140
|
-
2019-05-
|
141
|
-
2019-05-
|
142
|
-
2019-05-
|
143
|
-
2019-05-
|
144
|
-
2019-05-
|
145
|
-
2019-05-
|
146
|
-
2019-05-
|
147
|
-
2019-05-
|
148
|
-
2019-05-
|
149
|
-
2019-05-
|
150
|
-
2019-05-
|
151
|
-
2019-05-
|
152
|
-
2019-05-
|
153
|
-
2019-05-
|
154
|
-
2019-05-
|
155
|
-
[✔] react-native unlink react-native-webview success in 0.
|
156
|
-
2019-05-
|
157
|
-
2019-05-
|
158
|
-
2019-05-
|
159
|
-
2019-05-
|
160
|
-
2019-05-
|
161
|
-
2019-05-
|
162
|
-
2019-05-
|
163
|
-
2019-05-
|
164
|
-
2019-05-
|
165
|
-
2019-05-
|
166
|
-
2019-05-
|
167
|
-
2019-05-
|
168
|
-
2019-05-
|
169
|
-
2019-05-
|
170
|
-
2019-05-
|
171
|
-
2019-05-
|
172
|
-
2019-05-
|
173
|
-
2019-05-
|
174
|
-
|
175
|
-
2019-05-
|
176
|
-
2019-05-
|
177
|
-
2019-05-
|
178
|
-
2019-05-
|
179
|
-
2019-05-
|
180
|
-
2019-05-
|
181
|
-
|
182
|
-
2019-05-
|
183
|
-
2019-05-
|
138
|
+
2019-05-15T19:48:43-07:00 react_native_util react_pod v0.6.0
|
139
|
+
2019-05-15T19:48:46-07:00 Darwin 18.5.0 x86_64
|
140
|
+
2019-05-15T19:48:46-07:00 Ruby 2.6.3: ~/.rvm/rubies/ruby-2.6.3/bin/ruby
|
141
|
+
2019-05-15T19:48:46-07:00 RubyGems 3.0.3: ~/.rvm/rubies/ruby-2.6.3/bin/gem
|
142
|
+
2019-05-15T19:48:46-07:00 Bundler 2.0.1: ~/.rvm/gems/ruby-2.6.3/bin/bundle
|
143
|
+
2019-05-15T19:48:46-07:00 react-native-cli: ~/.nvm/versions/node/v10.15.0/bin/react-native
|
144
|
+
2019-05-15T19:48:46-07:00 react-native-cli: 2.0.1
|
145
|
+
2019-05-15T19:48:46-07:00 react-native: 0.59.8
|
146
|
+
2019-05-15T19:48:46-07:00 yarn 1.16.0: /usr/local/bin/yarn
|
147
|
+
2019-05-15T19:48:47-07:00 cocoapods 1.6.2: ~/.rvm/gems/ruby-2.6.3/bin/pod
|
148
|
+
2019-05-15T19:48:47-07:00 cocoapods-core: 1.6.2
|
149
|
+
2019-05-15T19:48:47-07:00 package.json:
|
150
|
+
2019-05-15T19:48:47-07:00 app name: "TestApp"
|
151
|
+
2019-05-15T19:48:47-07:00 Found Xcode project at ~/github/$USER/react_native_util/examples/TestApp/ios/TestApp.xcodeproj
|
152
|
+
2019-05-15T19:48:47-07:00 Dependencies:
|
153
|
+
2019-05-15T19:48:47-07:00 react-native-webview
|
154
|
+
2019-05-15T19:48:47-07:00 Unlinking dependencies
|
155
|
+
[✔] react-native unlink react-native-webview success in 0.7 s
|
156
|
+
2019-05-15T19:48:48-07:00 Generating ios/Podfile
|
157
|
+
2019-05-15T19:48:48-07:00 Removing Libraries from TestApp
|
158
|
+
2019-05-15T19:48:48-07:00 Removing libRCTBlob.a
|
159
|
+
2019-05-15T19:48:48-07:00 Removing libRCTAnimation.a
|
160
|
+
2019-05-15T19:48:48-07:00 Removing libReact.a
|
161
|
+
2019-05-15T19:48:48-07:00 Removing libRCTActionSheet.a
|
162
|
+
2019-05-15T19:48:48-07:00 Removing libRCTGeolocation.a
|
163
|
+
2019-05-15T19:48:48-07:00 Removing libRCTImage.a
|
164
|
+
2019-05-15T19:48:48-07:00 Removing libRCTLinking.a
|
165
|
+
2019-05-15T19:48:48-07:00 Removing libRCTNetwork.a
|
166
|
+
2019-05-15T19:48:48-07:00 Removing libRCTSettings.a
|
167
|
+
2019-05-15T19:48:48-07:00 Removing libRCTText.a
|
168
|
+
2019-05-15T19:48:48-07:00 Removing libRCTVibration.a
|
169
|
+
2019-05-15T19:48:48-07:00 Removing libRCTWebSocket.a
|
170
|
+
2019-05-15T19:48:48-07:00 Removing Libraries from TestAppTests
|
171
|
+
2019-05-15T19:48:48-07:00 Removing libReact.a
|
172
|
+
2019-05-15T19:48:48-07:00 Removing Libraries from TestApp-tvOS
|
173
|
+
2019-05-15T19:48:48-07:00 Removing libReact.a
|
174
|
+
2019-05-15T19:48:48-07:00 Removing libRCTAnimation.a
|
175
|
+
2019-05-15T19:48:48-07:00 Removing libRCTImage-tvOS.a
|
176
|
+
2019-05-15T19:48:48-07:00 Removing libRCTLinking-tvOS.a
|
177
|
+
2019-05-15T19:48:48-07:00 Removing libRCTNetwork-tvOS.a
|
178
|
+
2019-05-15T19:48:48-07:00 Removing libRCTSettings-tvOS.a
|
179
|
+
2019-05-15T19:48:48-07:00 Removing libRCTText-tvOS.a
|
180
|
+
2019-05-15T19:48:48-07:00 Removing libRCTWebSocket-tvOS.a
|
181
|
+
2019-05-15T19:48:48-07:00 Removing Libraries from TestApp-tvOSTests
|
182
|
+
2019-05-15T19:48:48-07:00 Removing libReact.a
|
183
|
+
2019-05-15T19:48:48-07:00 Removing RCTAnimation.xcodeproj from Libraries group.
|
184
|
+
2019-05-15T19:48:48-07:00 Removing React.xcodeproj from Libraries group.
|
185
|
+
2019-05-15T19:48:48-07:00 Removing RCTActionSheet.xcodeproj from Libraries group.
|
186
|
+
2019-05-15T19:48:48-07:00 Removing RCTBlob.xcodeproj from Libraries group.
|
187
|
+
2019-05-15T19:48:48-07:00 Removing RCTGeolocation.xcodeproj from Libraries group.
|
188
|
+
2019-05-15T19:48:48-07:00 Removing RCTImage.xcodeproj from Libraries group.
|
189
|
+
2019-05-15T19:48:48-07:00 Removing RCTLinking.xcodeproj from Libraries group.
|
190
|
+
2019-05-15T19:48:48-07:00 Removing RCTNetwork.xcodeproj from Libraries group.
|
191
|
+
2019-05-15T19:48:48-07:00 Removing RCTSettings.xcodeproj from Libraries group.
|
192
|
+
2019-05-15T19:48:48-07:00 Removing RCTText.xcodeproj from Libraries group.
|
193
|
+
2019-05-15T19:48:48-07:00 Removing RCTVibration.xcodeproj from Libraries group.
|
194
|
+
2019-05-15T19:48:48-07:00 Removing RCTWebSocket.xcodeproj from Libraries group.
|
195
|
+
2019-05-15T19:48:48-07:00 Removing Libraries group.
|
196
|
+
2019-05-15T19:48:48-07:00 Linking dependencies
|
197
|
+
[✔] react-native link react-native-webview success in 0.5 s
|
198
|
+
2019-05-15T19:48:48-07:00 Generating Pods project and ios/TestApp.xcworkspace
|
199
|
+
2019-05-15T19:48:48-07:00 Once pod install is complete, your project will be part of this workspace.
|
200
|
+
2019-05-15T19:48:48-07:00 From now on, you should build the workspace with Xcode instead of the project.
|
201
|
+
2019-05-15T19:48:48-07:00 Always add the workspace and Podfile.lock to SCM.
|
202
|
+
2019-05-15T19:48:48-07:00 It is common practice also to add the Pods directory.
|
203
|
+
2019-05-15T19:48:48-07:00 The workspace will be automatically opened when pod install completes.
|
204
|
+
[✔] pod install success in 10.6 s
|
205
|
+
2019-05-15T19:48:59-07:00 Conversion complete ✅
|
206
|
+
2019-05-15T19:48:59-07:00 $ open ios/TestApp.xcworkspace
|
184
207
|
```
|
185
208
|
|
186
209
|
## Convert your own app with Rake
|
@@ -253,4 +276,5 @@ https://www.rubydoc.info/gems/react_native_util.
|
|
253
276
|
|
254
277
|
## Successfully converted apps:
|
255
278
|
|
256
|
-
|
279
|
+
https://github.com/azhavrid/movie-swiper
|
280
|
+
([gist](https://gist.github.com/jdee/58746c8484d508fa318df8642ec99da8))
|
@@ -1,25 +1,37 @@
|
|
1
|
-
|
1
|
+
# Generated by <%= NAME %> react_pod v<%= VERSION %> at <%= Time.now %>
|
2
|
+
# <%= GITHUB_REPO %>
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
path: '../node_modules/react-native',
|
6
|
-
subspecs: %w[
|
7
|
-
Core
|
8
|
-
CxxBridge
|
9
|
-
DevSupport
|
10
|
-
<%= app_target.subspecs_from_libraries.join("\n ") %>
|
11
|
-
]
|
12
|
-
pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
|
13
|
-
pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
|
4
|
+
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
|
5
|
+
# use_frameworks!
|
14
6
|
|
7
|
+
pod 'yoga', path: '../node_modules/react-native/ReactCommon/yoga'
|
8
|
+
pod 'Folly', podspec: '../node_modules/react-native/third-party-podspecs/Folly.podspec'
|
9
|
+
|
10
|
+
target '<%= app_target.name %>' do
|
11
|
+
platform :ios, '<%= app_target.deployment_target %>'
|
12
|
+
<%= app_target.podfile_excerpt %>
|
15
13
|
# --- react-native link adds pods below this line. ---
|
16
14
|
|
17
15
|
end
|
18
16
|
|
19
17
|
<% if test_target %>
|
20
18
|
target '<%= test_target.name %>' do
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
platform :ios, '<%= app_target.deployment_target %>'
|
20
|
+
<%= test_target.podfile_excerpt %>
|
21
|
+
end
|
22
|
+
<% end %>
|
23
|
+
|
24
|
+
# As of 0.59.8, the React pod does not compile for tvOS
|
25
|
+
<% if app_target :tvos %>
|
26
|
+
target '<%= app_target(:tvos).name %>' do
|
27
|
+
platform :tvos, '<%= app_target(:tvos).deployment_target %>'
|
28
|
+
<%= app_target(:tvos).podfile_excerpt %>
|
29
|
+
end
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
<% if test_target :tvos %>
|
33
|
+
target '<%= test_target(:tvos).name %>' do
|
34
|
+
platform :tvos, '<%= app_target(:tvos).deployment_target %>'
|
35
|
+
<%= test_target(:tvos).podfile_excerpt %>
|
24
36
|
end
|
25
37
|
<% end %>
|
@@ -281,8 +281,8 @@ module ReactNativeUtil
|
|
281
281
|
end
|
282
282
|
|
283
283
|
def load_react_podspec!
|
284
|
-
podspec_dir =
|
285
|
-
podspec_contents = File.read
|
284
|
+
podspec_dir = File.dirname react_podspec_path
|
285
|
+
podspec_contents = File.read react_podspec_path
|
286
286
|
podspec_contents.gsub!(/__dir__/, podspec_dir.inspect)
|
287
287
|
|
288
288
|
require 'cocoapods-core'
|
@@ -291,18 +291,22 @@ module ReactNativeUtil
|
|
291
291
|
# rubocop: enable Security/Eval
|
292
292
|
end
|
293
293
|
|
294
|
+
def react_podspec_path
|
295
|
+
File.expand_path 'node_modules/react-native/React.podspec'
|
296
|
+
end
|
297
|
+
|
294
298
|
# The name of the app as specified in package.json
|
295
299
|
# @return [String] the app name
|
296
300
|
def app_name
|
297
301
|
@app_name ||= package_json['name']
|
298
302
|
end
|
299
303
|
|
300
|
-
def app_target
|
301
|
-
project.app_target
|
304
|
+
def app_target(platform = :ios)
|
305
|
+
project.app_target platform
|
302
306
|
end
|
303
307
|
|
304
|
-
def test_target
|
305
|
-
project.test_target
|
308
|
+
def test_target(platform = :ios)
|
309
|
+
project.test_target platform
|
306
310
|
end
|
307
311
|
|
308
312
|
def podfile_path
|
@@ -312,7 +316,7 @@ module ReactNativeUtil
|
|
312
316
|
# Generate a Podfile from a template.
|
313
317
|
def generate_podfile!
|
314
318
|
log "Generating #{podfile_path}"
|
315
|
-
podfile_contents = ERB.new(File.read(PODFILE_TEMPLATE_PATH)).result binding
|
319
|
+
podfile_contents = ERB.new(File.read(PODFILE_TEMPLATE_PATH), nil, '<>').result binding
|
316
320
|
File.open podfile_path, 'w' do |file|
|
317
321
|
file.write podfile_contents
|
318
322
|
end
|
@@ -4,6 +4,14 @@ module Xcodeproj
|
|
4
4
|
class Project
|
5
5
|
module Object
|
6
6
|
class AbstractTarget
|
7
|
+
PODFILE_TARGET_TEMPLATE_PATH = File.expand_path '../../assets/templates/Podfile-target.erb', __dir__
|
8
|
+
|
9
|
+
def podfile_excerpt(commented_out: false)
|
10
|
+
text = ERB.new(File.read(PODFILE_TARGET_TEMPLATE_PATH), nil, '-').result binding
|
11
|
+
text = text.split("\n").map { |line| "# #{line}" }.join("\n") if commented_out
|
12
|
+
"#{text}\n"
|
13
|
+
end
|
14
|
+
|
7
15
|
def subspecs_from_libraries
|
8
16
|
libs = frameworks_build_phase.files.select do |file|
|
9
17
|
path = file.file_ref.pretty_print
|
@@ -12,11 +20,15 @@ module Xcodeproj
|
|
12
20
|
|
13
21
|
# project is a ReactNativeUtil::Project
|
14
22
|
# #static_libs is from the Libraries group
|
15
|
-
project.static_libs.include?(path)
|
23
|
+
project.static_libs(platform_name).include?(path)
|
16
24
|
end
|
17
25
|
|
18
|
-
|
26
|
+
react_project_subspecs = %w[Core CxxBridge DevSupport]
|
27
|
+
react_project_subspecs << 'tvOS' if platform_name == :tvos
|
28
|
+
|
29
|
+
react_project_subspecs + libs.map do |lib|
|
19
30
|
root = lib.file_ref.pretty_print.sub(/^lib(.*)\.a$/, '\1')
|
31
|
+
root.sub!(/-tvOS/, '')
|
20
32
|
|
21
33
|
case root
|
22
34
|
when 'RCTLinking'
|
@@ -1,11 +1,13 @@
|
|
1
1
|
# Conversion tools for React Native projects
|
2
2
|
module ReactNativeUtil
|
3
3
|
NAME = 'react_native_util'
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '0.6.0'
|
5
5
|
SUMMARY = 'Community utility CLI for React Native projects'
|
6
6
|
DESCRIPTION = 'Converts a project created with react-native init to use CocoaPods with the ' \
|
7
7
|
'React pod from node_modules. This preserves compatibility with ' \
|
8
8
|
'react-native link. A converted project will still start the Metro packager ' \
|
9
9
|
'automatically via a Run Script build phase in the Xcode project. This is an ' \
|
10
10
|
'alternative to performing manual surgery on a project in Xcode.'
|
11
|
+
GITHUB_ORG = 'jdee'
|
12
|
+
GITHUB_REPO = "https://github.com/#{GITHUB_ORG}/#{NAME}"
|
11
13
|
end
|
@@ -29,12 +29,12 @@ module ReactNativeUtil
|
|
29
29
|
|
30
30
|
attr_accessor :app_name
|
31
31
|
|
32
|
-
def app_target
|
33
|
-
targets.find { |t| t.platform_name ==
|
32
|
+
def app_target(platform = :ios)
|
33
|
+
targets.find { |t| t.platform_name == platform && t.product_type == 'com.apple.product-type.application' }
|
34
34
|
end
|
35
35
|
|
36
|
-
def test_target
|
37
|
-
targets.select(&:test_target_type?).select { |t| t.platform_name ==
|
36
|
+
def test_target(platform = :ios)
|
37
|
+
targets.select(&:test_target_type?).select { |t| t.platform_name == platform }.first
|
38
38
|
end
|
39
39
|
|
40
40
|
# Validate an assumption about the project. TODO: Provide override option.
|
@@ -49,19 +49,58 @@ module ReactNativeUtil
|
|
49
49
|
self['Libraries']
|
50
50
|
end
|
51
51
|
|
52
|
+
def targets_linking_with(root)
|
53
|
+
targets_matching do |r|
|
54
|
+
if root.respond_to?(:include?)
|
55
|
+
root.include? r
|
56
|
+
else
|
57
|
+
log "r = #{r}, root = #{root}"
|
58
|
+
r == root
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def targets_matching(&block)
|
64
|
+
targets.reject do |target|
|
65
|
+
file_refs = target.frameworks_build_phase.files.map(&:file_ref).reject(&:nil?).map(&:pretty_print)
|
66
|
+
|
67
|
+
libs_from_libraries_group = file_refs.select do |lib|
|
68
|
+
lib = lib.sub(/-tvOS/, '')
|
69
|
+
matches = /^lib(.+)\.a$/.match lib
|
70
|
+
next false unless matches
|
71
|
+
|
72
|
+
yield matches[1]
|
73
|
+
end
|
74
|
+
|
75
|
+
libs_from_libraries_group.empty?
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
52
79
|
# Remove the Libraries group from the xcodeproj in memory.
|
53
80
|
def remove_libraries_group
|
54
|
-
# Remove links against these static libraries
|
55
|
-
targets.
|
81
|
+
# Remove links against these static libraries from all targets
|
82
|
+
targets.each do |t|
|
56
83
|
remove_libraries_from_target t
|
57
84
|
end
|
58
85
|
|
59
|
-
|
86
|
+
# Remove any unused projects from the Libraries group
|
87
|
+
library_roots.each do |root|
|
88
|
+
next unless targets_linking_with(root).empty?
|
89
|
+
|
90
|
+
# Remove this lib from the Libraries group. Nothing is linking against it
|
91
|
+
# anymore.
|
92
|
+
child = libraries_group.children.find { |c| c.path =~ /#{root}\.xcodeproj/ }
|
93
|
+
log "Removing #{root}.xcodeproj from Libraries group."
|
94
|
+
child.remove_from_project
|
95
|
+
end
|
96
|
+
|
97
|
+
# Remove the Libraries group if it's empty. Or report that it's not.
|
98
|
+
unless library_roots.empty?
|
60
99
|
log 'Libraries group not empty. Not removing.'
|
61
100
|
return
|
62
101
|
end
|
63
102
|
|
64
|
-
log 'Removing Libraries group'
|
103
|
+
log 'Removing Libraries group.'
|
65
104
|
libraries_group.remove_from_project
|
66
105
|
end
|
67
106
|
|
@@ -70,6 +109,7 @@ module ReactNativeUtil
|
|
70
109
|
path = file.file_ref.pretty_print
|
71
110
|
next false unless /^lib(.+)\.a$/.match?(path)
|
72
111
|
|
112
|
+
path = path.sub(/-tvOS\.a$/, '.a')
|
73
113
|
static_libs.include?(path)
|
74
114
|
end
|
75
115
|
|
@@ -152,8 +192,15 @@ module ReactNativeUtil
|
|
152
192
|
|
153
193
|
# All static libraries from the Libraries group
|
154
194
|
# @return [Array<String>] an array of filenames
|
155
|
-
def static_libs
|
156
|
-
library_roots.map
|
195
|
+
def static_libs(platform = :ios)
|
196
|
+
library_roots.map do |root|
|
197
|
+
case platform
|
198
|
+
when :tvos
|
199
|
+
"lib#{root}-tvOS.a"
|
200
|
+
else
|
201
|
+
"lib#{root}.a"
|
202
|
+
end
|
203
|
+
end
|
157
204
|
end
|
158
205
|
|
159
206
|
# Returns the original Start Packager build phase (from the React.xcodeproj
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: react_native_util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Dee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -237,7 +237,7 @@ files:
|
|
237
237
|
- README.md
|
238
238
|
- bin/react_native_util
|
239
239
|
- bin/rn
|
240
|
-
- lib/assets/
|
240
|
+
- lib/assets/templates/Podfile-target.erb
|
241
241
|
- lib/assets/templates/Podfile.erb
|
242
242
|
- lib/react_native_util.rb
|
243
243
|
- lib/react_native_util/cli.rb
|