cocoapods-fix-react-native 2018.04.01.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 314d6f0a62f11cbac18069634fbaf4311408d67b
4
+ data.tar.gz: 3911c6d6ef9a9b8f81139cf39548216e0800bb94
5
+ SHA512:
6
+ metadata.gz: e8f452b010f5d119fde223563f05e63f56f5f14b718045b39e4afb0abd19b85501194630301e6201765553850c9d228f7a5d14acec75cc1eeea87ed48aa34139
7
+ data.tar.gz: 1b289b261ec0f49eceae8e9afd13bbcab05189858cabbbbb885d8c25ddbaecb82b5be109d98118da3d3099472d3b4b360c2ff50689fcf34771d9b95e88541c0d
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ deploy:
2
+ provider: rubygems
3
+ api_key:
4
+ secure: mEMNAc4oTDd7ZO+AoDmE02WkC6GtpBVV9Xfe2r7+degZyhlbjxUr7QUavUDVsjATjOBhjumHDCjQRo2wjyjyp3Ssa81qW+/HyciSNOduzf5ONQPaMrbZinO+gxNz0gF7wjeu2On2DHERGk90O8pqWRqKXf1F8A0uk2Y13Mo+QnvwrZrf02Tq6YQgZ35jb5N005axliVQx9XNzfTSHYBv3MYnTVmm4Rz7HFpvcMYDYrkKy+8TROPqjuoNXwnSuzelyPODyyH5nMsPMyAZ6VIBKmybZUFQIzbKQtbKGMYVWXms4qKtjxckEUoAx2KNKQTcQfpkHl3FNLdXFxCBk+I1op01PD1+gsCYCwZPmQ6p/j0fdclEO6LKyggM3VWX2dnCeE2q18RcF+7W05GGIIDklflYamtYiC25mYw5oM+GFVv2eeqmnP+HnPQvuuMOFUR3aqH36RU4bhn+hjqsATBAgUso7YDZbin9W68aPZWPx5jtMIAB8NkoCoFj25IGZLle5aKuxTrxn1bdzQe5mq8rlHK1iEtf3c/ojEgBj/ka1l4UtYOPxwsIOrqsP2uU4mejR4IPMQrOJEUw1m6DwHYD0vP1eudt7ZfUlSVHOVKR4Re/Gu8GOtl+8EIQUJPMGXsPsxqwpMw8QjGLz9p2VZVxLnraCd8Ed5SOOd6YbvG6gbY=
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-fix-react-native.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ gem 'pry'
14
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Orta Therox <orta.therox@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,99 @@
1
+ Hi there! This a CocoaPods plugin that _we, the community_, can use to plug the holes in React Native's CocoaPods
2
+ support.
3
+
4
+ CocoaPods allows you to add code to run at the end of the Podfile via a `post_install` hook. You probably already have
5
+ some custom code in there. This plugin allows all that code to be centralized and reasoned about in a single place per
6
+ React Native version.
7
+
8
+ ## Why Does This Need To Exist?
9
+
10
+ React Native is a pragmatic project, it's great Facebook open sources it, but if you want to work with a flow they don't
11
+ use - the onus is on you to make sure it continues to work. Facebook have a big mono-repo, and so they don't need to use
12
+ CocoaPods, and they also use static compilation because they don't use Swift. Meaning if you want to use CocoaPods and
13
+ Swift, you're pretty far from their workflow.
14
+
15
+ In order to get it working for just you app you scour, like, a million issues on React Native (or go look at
16
+ [artsy/eigen][eigen]) to get it compiling on your setup. Again, not optimal.
17
+
18
+ This plugin _tries_ to fix this by centralizing the code needed to modify React Native. This means makes it easy to update
19
+ your versions of React Native, because you can update the gem at the same time.
20
+
21
+ ## Installation
22
+
23
+ Lazy way (bad, but ok if 1 engineer):
24
+
25
+ $ gem install cocoapods-fix-react-native
26
+
27
+ Correct way, edit your gemfile to be:
28
+
29
+ gem "cocoapods"
30
+ gem "cocoapods-fix-react-native"
31
+
32
+ Then remove any React Native related `post_install` code, and add this to the top level of your `Podfile`:
33
+
34
+ plugin 'cocoapods-fix-react-native'
35
+
36
+ For the first time you do this, I'd recommend running `rm -rf Pods; bundle exec pod install`. After that you can
37
+ `bundle exec pod install` like normal.
38
+
39
+ ## How do I Update This?
40
+
41
+ `bundle update cocoapods-fix-react-native`.
42
+
43
+ ## How Does This Work?
44
+
45
+ A CocoaPods plugin can register a `post_install` hook just like you can in your `Podfile`. This hook will first look at
46
+ what version of React Native is installed, and will then run a corresponding script to make changes to the environment.
47
+
48
+ ## Contributing Back
49
+
50
+ You'll note that this repo has issues disabled, I'm not going to make the time to support questions and requests for
51
+ fixes to this. I have a lot of projects, and only so much time. However, I'm happy to handle the mainainance and upkeep
52
+ from code people submit. If you want a change, you'll need to do so yourself, so let's cover how you do that:
53
+
54
+ This project is very specific about what versions of React Native it supports, you can see them in the folder
55
+ [`lib/cocoapods-fix-react-native/versions/`][versions]:
56
+
57
+ ```
58
+ ~/dev/projects/react-native/cocoapods-fix-react-native master*
59
+ ❯ tree lib/cocoapods-fix-react-native/versions/
60
+ lib/cocoapods-fix-react-native/versions/
61
+ └── 0_54_4.rb
62
+ ```
63
+
64
+ There's likely more than just one by the time you read this, but if you want to use a version that isn't supported yet,
65
+ then you're going to want to copy the most recent into a new file. The files are named by converting dots to
66
+ underscores. E.g. `0.54.4` -> `0_54_4.rb`.
67
+
68
+ The scripts itself should be entirely self contained, so that it's easy to understand wthout learning the project.
69
+
70
+ The biggest change you'd need to make from the sort of code you can find inside the issues is that it needs to support
71
+ many different potential roots. So instead of just `Pods/` - it wants to also handle `node_modules/react-native` and
72
+ `../node_modules/react-native`. This can be done by removing `'Pods'` from the path and wrapping it with a
73
+ `File.join(root, 'Path/InReactLib.js')`.
74
+
75
+ ### Getting Setup To Improve
76
+
77
+ Clone this repo:
78
+
79
+ ```
80
+ git clone https://github.com/orta/cocoapods-fix-react-native
81
+ cd cocoapods-fix-react-native
82
+ bundle install
83
+ ```
84
+
85
+ You want to use a `:path` based gem in your project's Gemfile to point to the cloned repo. Make you to your App's
86
+ `Gemfile` something like this:
87
+
88
+ ```ruby
89
+ gem 'cocoapods', '~> 1.4.0'
90
+ gem 'cocoapods-fix-react-native', path: "../../../../react-native/cocoapods-fix-react-native"
91
+ ```
92
+
93
+ Then when you run `bundle exec pod install` in that project, it will use the the code from your cloned copy.
94
+
95
+ As `use_frameworks!` is more strict than static libraries, I'd recommend working on this project using a repo that has
96
+ frameworks.
97
+
98
+ [eigen]: https://github.com/artsy/eigen/
99
+ [versions]: lib/cocoapods-fix-react-native/versions/
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,21 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'cocoapods-fix-react-native'
6
+ spec.version = Time.now.strftime("%Y.%m.%d.%H")
7
+ spec.authors = ['Orta Therox']
8
+ spec.email = ['orta.therox@gmail.com']
9
+ spec.description = "CocoaPods plugin which automates hot-patching React Native"
10
+ spec.summary = "CocoaPods plugin which automates hot-patching React Native"
11
+ spec.homepage = 'https://github.com/orta/cocoapods-fix-react-native'
12
+ spec.license = 'MIT'
13
+
14
+ spec.files = `git ls-files`.split($/)
15
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'rake'
21
+ end
@@ -0,0 +1 @@
1
+ # NOOP
@@ -0,0 +1,26 @@
1
+ class CocoaPodsFixReactNative
2
+ def fix_with_context(context)
3
+ # Get the current version of React Native in your app
4
+ react = nil
5
+ context.umbrella_targets.each do |target|
6
+ react = target.specs.find { |s| s.name == 'React' || s.name.start_with?('React/') }
7
+ react = react if react
8
+ end
9
+
10
+ # 0.44.1 -> 0_44_1
11
+ version = react.version.to_s
12
+ file_to_parse = version.tr('.', '_')
13
+ path_to_fix = File.join(File.dirname(__FILE__), 'versions', file_to_parse + '.rb')
14
+
15
+ # require 'pry'
16
+ # binding.pry
17
+
18
+ if File.exist? path_to_fix
19
+ puts "Patching React Native #{version}"
20
+ require(path_to_fix)
21
+ else
22
+ puts "CP-Fix-React-Native does not support #{version} yet, please send PRs to"
23
+ puts 'https://github.com/orta/cocoapods-fix-react-native'
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,95 @@
1
+ # Are you using :path based Pods?
2
+ dev_pods_react = !File.directory?('Pods/React/React')
3
+
4
+ # Check for whether
5
+ same_repo_node_modules = File.directory?('node_modules/react-native')
6
+ previous_repo_node_modules = File.directory?('../node_modules/react-native')
7
+
8
+ # Find out where the files could be rooted
9
+ root = 'Pods'
10
+ if dev_pods_react
11
+ root = 'node_modules/react-native' if same_repo_node_modules
12
+ root = '../node_modules/react-native' if previous_repo_node_modules
13
+ end
14
+
15
+ # TODO: move to be both file in pods and file in node_mods?
16
+ def edit_pod_file(path, old_code, new_code)
17
+ file = File.join(root, path)
18
+ code = File.read(file)
19
+ if code.include?(old_code)
20
+ FileUtils.chmod('+w', file)
21
+ File.write(file, code.sub(old_code, new_code))
22
+ end
23
+ end
24
+
25
+ def fix_cplusplus_header_compiler_error
26
+ filepath = File.join(root, 'Pods/React/React/Base/Surface/SurfaceHostingView/RCTSurfaceSizeMeasureMode.h')
27
+ FileUtils.chmod('+w', filepath)
28
+
29
+ contents = []
30
+
31
+ file = File.open(filepath, 'r')
32
+ file.each_line do |line|
33
+ contents << line
34
+ end
35
+ file.close
36
+
37
+ if contents[32].include? '&'
38
+ contents.insert(26, '#ifdef __cplusplus')
39
+ contents[36] = '#endif'
40
+
41
+ file = File.open(filepath, 'w') do |f|
42
+ f.puts(contents)
43
+ end
44
+ end
45
+ end
46
+
47
+ def fix_unused_yoga_headers
48
+ filepath = './Pods/Target Support Files/yoga/yoga-umbrella.h'
49
+
50
+ contents = []
51
+
52
+ file = File.open(filepath, 'r')
53
+ file.each_line do |line|
54
+ contents << line
55
+ end
56
+ file.close
57
+
58
+ if contents[12].include? 'Utils.h'
59
+ contents.delete_at(15) # #import "YGNode.h"
60
+ contents.delete_at(15) # #import "YGNodePrint.h"
61
+ contents.delete_at(15) # #import "Yoga-internal.h"
62
+ contents.delete_at(12) # #import "Utils.h"
63
+
64
+ file = File.open(filepath, 'w') do |f|
65
+ f.puts(contents)
66
+ end
67
+ end
68
+ end
69
+
70
+ fix_unused_yoga_headers
71
+ fix_cplusplus_header_compiler_error
72
+
73
+ # https://github.com/facebook/react-native/pull/14664
74
+ animation_view_file = 'React/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h'
75
+ animation_view_old_code = 'import <RCTAnimation/RCTValueAnimatedNode.h>'
76
+ animation_view_new_code = 'import "RCTValueAnimatedNode.h"'
77
+ edit_pod_file animation_view_file, animation_view_old_code, animation_view_new_code
78
+
79
+ # https://github.com/facebook/react-native/issues/13198
80
+ # Only needed when you have the DevSupport subspec
81
+ if File.exist?(File.join(root, 'React/Libraries/WebSocket/RCTReconnectingWebSocket.m'))
82
+ websocket = 'React/Libraries/WebSocket/RCTReconnectingWebSocket.m'
83
+ websocket_old_code = 'import <fishhook/fishhook.h>'
84
+ websocket_new_code = 'import <React/fishhook.h>'
85
+ edit_pod_file websocket, websocket_old_code, websocket_new_code
86
+ end
87
+
88
+ # Newer build of Xcode don't allow you to set a non-obj to be strong,
89
+ # so this instead changes it to be an assign.
90
+ module_data_file = 'React/React/Base/RCTModuleData.h'
91
+ bridge_module_file = 'React/React/Base/RCTBridgeModule.h'
92
+ method_queue_old_code = '(nonatomic, strong, readonly) dispatch_queue_t methodQueue'
93
+ method_queue_new_code = '(nonatomic, assign, readonly) dispatch_queue_t methodQueue'
94
+ edit_pod_file module_data_file, method_queue_old_code, method_queue_new_code
95
+ edit_pod_file bridge_module_file, method_queue_old_code, method_queue_new_code
@@ -0,0 +1,6 @@
1
+ require 'cocoapods-fix-react-native/version_resolver'
2
+
3
+ Pod::HooksManager.register('cocoapods-fix-react-native', :post_install) do |context|
4
+ fixer = CocoaPodsFixReactNative.new
5
+ fixer.fix_with_context(context)
6
+ end
@@ -0,0 +1,12 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ # This project has about 8 LOC of Ruby, I'm
4
+ # not particularly bothered with testing it.
5
+ #
6
+ # It'd need integration really.
7
+ #
8
+ describe 'Empty test' do
9
+ it 'is a pretty chill spec' do
10
+ 23.should.equal 23
11
+ end
12
+ end
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-fix-react-native
3
+ version: !ruby/object:Gem::Version
4
+ version: 2018.04.01.11
5
+ platform: ruby
6
+ authors:
7
+ - Orta Therox
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: CocoaPods plugin which automates hot-patching React Native
42
+ email:
43
+ - orta.therox@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-fix-react-native.gemspec
55
+ - lib/cocoapods-fix-react-native.rb
56
+ - lib/cocoapods-fix-react-native/version_resolver.rb
57
+ - lib/cocoapods-fix-react-native/versions/0_54_4.rb
58
+ - lib/cocoapods_plugin.rb
59
+ - spec/command/native_spec.rb
60
+ - spec/spec_helper.rb
61
+ homepage: https://github.com/orta/cocoapods-fix-react-native
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubyforge_project:
81
+ rubygems_version: 2.6.14
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: CocoaPods plugin which automates hot-patching React Native
85
+ test_files:
86
+ - spec/command/native_spec.rb
87
+ - spec/spec_helper.rb