cocoapods-binary-gcp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de8abf8887f0e40c79c8c1c58f490b54b9eaa772
4
+ data.tar.gz: c4790e48e36e167cf4e47d70af88fc79ec698ce3
5
+ SHA512:
6
+ metadata.gz: 72e9f238d059947a52d375a49ff25c84ebd04c4bf59395c70ec44aede1c03f65c31c5cd2a72903880865d50dd65ffa877a4c7ce936a3c405cb05a94f896b8a7a
7
+ data.tar.gz: f8ad0ff8c700a981f7a4962a701f1110866bc8dea88e9cf37733bd9c82592198cbe6ba3e32eb127cacf096f151417aae6e3430b161fd55bfbc2f1917b0fdb659
@@ -0,0 +1,10 @@
1
+ Thanks for your feedback!
2
+
3
+ If it's a bug:
4
+
5
+ - What's your environment:
6
+ - run ` pod env | egrep 'CocoaPods |Xcode|cocoapods-binary' ` then paste the result here
7
+ - A demo project is helpful:
8
+ - It will be very helpful if provides a demo project that reproduce the problem. A blank project with cocoapods-binary can be downloaded [here](https://github.com/leavez/cocoapods-binary/files/3086250/BinaryDemo.zip), which can be remodeled to a minimal problematic environment. Attach the demo.zip to the comments.
9
+
10
+
@@ -0,0 +1,33 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+
5
+ test/Pods
6
+ test/Gemfile.lock
7
+
8
+ ## Various settings
9
+ *.pbxuser
10
+ !default.pbxuser
11
+ *.mode1v3
12
+ !default.mode1v3
13
+ *.mode2v3
14
+ !default.mode2v3
15
+ *.perspectivev3
16
+ !default.perspectivev3
17
+ xcuserdata/
18
+
19
+ ## Other
20
+ *.moved-aside
21
+ *.xccheckout
22
+ *.xcscmblueprint
23
+
24
+ ### Xcode Patch ###
25
+ *.xcodeproj/*
26
+ !*.xcodeproj/project.pbxproj
27
+ !*.xcodeproj/xcshareddata/
28
+ !*.xcworkspace/contents.xcworkspacedata
29
+ /*.gcno
30
+ test/Binary.xcworkspace/contents.xcworkspacedata
31
+ test/Binary.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
32
+ test/Podfile
33
+ test/Podfile.lock
@@ -0,0 +1,24 @@
1
+ osx_image: xcode9.3
2
+ language: objective-c
3
+ cache:
4
+ - cocoapods
5
+ - bundler
6
+ before_install:
7
+ - gem install cocoapods
8
+ script:
9
+ - rake install
10
+ - cd test
11
+ - bundle exec pod repo update
12
+ - sh test.sh
13
+ - cd ..
14
+
15
+ # auto deploy on tagging
16
+ # automatically set by `travis setup rubygems`
17
+ deploy:
18
+ provider: rubygems
19
+ api_key:
20
+ secure: HglQwElI8cEeKc5oXzoVbBBprgb8k7RUr0YOH1N1fhpNW7HJpJtSLzUBPC5T+Sv5RPSicaxY/oXeYE6x4E7Oadf7Gy2tmM9iwwJQh6YgZ/foh9G9obHZtTerhB4wY2cjguBXDmLqiMRiJzNTZRvoUnESBKakPbK/ODY0mHT+LDdMwZk2QsMjD3fRc5M7JRR29jr56jzVuUdy0lR4TRoc2+yIRqp2vFNtcbKdzKuYgzcdE9xzPh0FQzgiImA5uGDruyAgoNeOlGxDPZdnm7fw/epLmq8fUIZanReI30QnJeIErFwMCVeN1zVqQiWRgv8qGi8Z0ZKOzvcu7oKuaeXo5xSkTfkAc9I0LbcRd3UHCluAr9JHuERNwkn1qx5W0DdngTKrPM65ZABQxk4KUHt+5yd6Dv7lR9GrGD3teNZDga/X8u0tQIkoPIl76ZjXRh0bmCDQM/zWaTKkh7eX/YXQKgrjrEecZMeZfsLds789MK2QO17QlbHTVno+HBr0Rah6nHI0/vl1xqHthHCb/Y9SBXmLQ7+ySNXmj7YxPjpD6m8kEEUDTQQdgjS7vMInqJiSekGBImu2VQA/qZP1+WEBha5nX2ADfvsAWfUdsdQfuTbv07RnIG+3quzSl5U1UPVR9f7EsqpTtxflLJCqVdaz2ndQBO6NXAnRhA90cfAFd9s=
21
+ gem: cocoapods-binary
22
+ on:
23
+ tags: true
24
+ repo: leavez/cocoapods-binary
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-binary.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
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 leavez <gaojiji@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.
@@ -0,0 +1,78 @@
1
+
2
+ <p align="center"><img src="/test/logo.png" width="622"></p>
3
+
4
+ [![Build Status](https://travis-ci.org/leavez/cocoapods-binary.svg?branch=master)](https://travis-ci.org/leavez/cocoapods-binary)
5
+
6
+ A CocoaPods plugin to integrate pods in form of prebuilt frameworks, not source code, by adding **just one flag** in podfile. Speed up compiling dramatically.
7
+
8
+ Good news: Introduction on cocoapods offical site: [Pre-compiling dependencies](http://guides.cocoapods.org/plugins/pre-compiling-dependencies.html) ( NOTE: This plugin is a community work, not official.)
9
+
10
+
11
+ ## Why
12
+
13
+ You may wonder why CocoaPods doesn't have a function to integrate libs in form of binaries, if there are dozens or hundreds of pods in your podfile and compile them for a great many times meaninglessly. Too many source code of libs slow down your compile and the response of IDE (e.g. code completion), and then reduce work efficiency, leaving us time to think about the meaning of life.
14
+
15
+ This plugin implements this simple wish. Replace the source code in pod target with prebuilt frameworks.
16
+
17
+ Why don't use Carthage? While Carthage also integrates libs in form of frameworks, there several reasons to use CocoaPods with this plugin:
18
+
19
+ - Pod is a good simple form to organize files, manage dependencies. (private or local pods)
20
+ - Fast switch between source code and binary, or partial source code, partial binaries.
21
+ - Some libs don't support Carthage.
22
+
23
+ ## How it works
24
+
25
+ It will compile the source code of pods during the pod install process, and make CocoaPods use them. Which pod should be compiled is controlled by the flag in Podfile.
26
+
27
+ #### Under the hood
28
+
29
+ ( You could leave this paragraph for further reading, and try it now. )
30
+
31
+ The plugin will do a separated completed 'Pod install' in the standard pre-install hook. But we filter the pods by the flag in Podfile here. Then build frameworks with this generated project by using xcodebuild. Store the frameworks in `Pods/_Prebuild` and save the manifest.lock file for the next pod install.
32
+
33
+ Then in the flowing normal install process, we hook the integration functions to modify pod specification to using our frameworks.
34
+
35
+ ## Installation
36
+
37
+ $ gem install cocoapods-binary
38
+
39
+ ## Usage
40
+
41
+ ``` ruby
42
+ plugin 'cocoapods-binary'
43
+
44
+ use_frameworks!
45
+ # all_binary!
46
+
47
+ target "HP" do
48
+ pod "ExpectoPatronum", :binary => true
49
+ end
50
+ ```
51
+
52
+ - Add `plugin 'cocoapods-binary'` in the head of Podfile
53
+ - Add `:binary => true` as a option of one specific pod, or add `all_binary!` before all targets, which makes all pods binaries.
54
+ - pod install, and that's all
55
+
56
+ **Note**: cocoapods-binary require `use_frameworks!`. If your worry about the boot time and other problems introduced by dynamic framework, static framework is a good choice. Another [plugin](https://github.com/leavez/cocoapods-static-swift-framework) made by me to make all pods static frameworks is recommended.
57
+
58
+ #### Options
59
+
60
+ If you want to disable binary for a specific pod when using `all_binary!`, place a `:binary => false` to it.
61
+
62
+ If your `Pods` folder is excluded from git, you may add `keep_source_code_for_prebuilt_frameworks!` in the head of Podfile to speed up pod install, as it won't download all the sources every time prebuilt pods have changes.
63
+
64
+ If bitcode is needed, add a `enable_bitcode_for_prebuilt_frameworks!` before all targets in Podfile
65
+
66
+ if you want to share prebuilt frameworks for different projects or for CI builds, you may add `use_shared_cache!` in the head of Podfile to speed up pod install, as it will reuse frameworks from common cache folder(`~Library/Caches/CocoaPods/Prebuilt` by default).
67
+
68
+
69
+ #### Known Issues
70
+
71
+ - doesn't support watchos now
72
+ - ~~dSYM files is missing for dynamic frameworks using this plugin. Workaround: Don't use this plugin for a release build. Add a if condition with ENV around `plugin 'cocoapods-binary'`. [(detail)](https://github.com/leavez/cocoapods-binary/issues/44)~~ (fix in 0.4.2)
73
+
74
+ ## License
75
+
76
+ MIT
77
+
78
+ Appreciate a 🌟 if you like it.
@@ -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,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-binary/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-binary-gcp'
8
+ spec.version = CocoapodsBinary::VERSION
9
+ spec.authors = ['leavez', 'hellocore']
10
+ spec.email = ['gaojiji@gmail.com', 'aukwat@gmail.com']
11
+ spec.description = %q{integrate pods in form of prebuilt frameworks conveniently, reducing compile time}
12
+ spec.summary = %q{A CocoaPods plugin to integrate pods in form of prebuilt frameworks, not source code, by adding just one flag in podfile. Speed up compiling dramatically.}
13
+ spec.homepage = 'https://github.com/HelloCore/cocoapods-binary'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/).reject{|f| f.start_with?("test/") || f.start_with?('demo/')}
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency "cocoapods", ">= 1.5.0", "< 2.0"
22
+ spec.add_dependency "fourflusher", "~> 2.0"
23
+ spec.add_dependency "xcpretty", "~> 0.3.0"
24
+ spec.add_dependency "google-cloud-storage", "~> 1.19"
25
+ spec.add_dependency "rubyzip"
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.3'
28
+ spec.add_development_dependency 'rake'
29
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-binary/gem_version'
@@ -0,0 +1,289 @@
1
+ require_relative 'helper/podfile_options'
2
+ require_relative 'helper/feature_switches'
3
+ require_relative 'helper/prebuild_sandbox'
4
+ require_relative 'helper/passer'
5
+ require_relative 'helper/names'
6
+ require_relative 'helper/target_checker'
7
+
8
+
9
+ # NOTE:
10
+ # This file will only be loaded on normal pod install step
11
+ # so there's no need to check is_prebuild_stage
12
+
13
+
14
+
15
+ # Provide a special "download" process for prebuilded pods.
16
+ #
17
+ # As the frameworks is already exsited in local folder. We
18
+ # just create a symlink to the original target folder.
19
+ #
20
+ module Pod
21
+ class Installer
22
+ class PodSourceInstaller
23
+
24
+ def install_for_prebuild!(standard_sanbox)
25
+ return if standard_sanbox.local? self.name
26
+
27
+ # make a symlink to target folder
28
+ prebuild_sandbox = Pod::PrebuildSandbox.from_standard_sandbox(standard_sanbox)
29
+ # if spec used in multiple platforms, it may return multiple paths
30
+ target_names = prebuild_sandbox.existed_target_names_for_pod_name(self.name)
31
+
32
+ def walk(path, &action)
33
+ return unless path.exist?
34
+ path.children.each do |child|
35
+ result = action.call(child, &action)
36
+ if child.directory?
37
+ walk(child, &action) if result
38
+ end
39
+ end
40
+ end
41
+ def make_link(source, target)
42
+ source = Pathname.new(source)
43
+ target = Pathname.new(target)
44
+ target.parent.mkpath unless target.parent.exist?
45
+ relative_source = source.relative_path_from(target.parent)
46
+ FileUtils.ln_sf(relative_source, target)
47
+ end
48
+ def mirror_with_symlink(source, basefolder, target_folder)
49
+ target = target_folder + source.relative_path_from(basefolder)
50
+ make_link(source, target)
51
+ end
52
+
53
+ target_names.each do |name|
54
+
55
+ # symbol link copy all substructure
56
+ real_file_folder = prebuild_sandbox.framework_folder_path_for_target_name(name)
57
+
58
+ # If have only one platform, just place int the root folder of this pod.
59
+ # If have multiple paths, we use a sperated folder to store different
60
+ # platform frameworks. e.g. AFNetworking/AFNetworking-iOS/AFNetworking.framework
61
+
62
+ target_folder = standard_sanbox.pod_dir(self.name)
63
+ if target_names.count > 1
64
+ target_folder += real_file_folder.basename
65
+ end
66
+ target_folder.rmtree if target_folder.exist?
67
+ target_folder.mkpath
68
+
69
+
70
+ walk(real_file_folder) do |child|
71
+ source = child
72
+ # only make symlink to file and `.framework` folder
73
+ if child.directory? and [".framework", ".dSYM"].include? child.extname
74
+ mirror_with_symlink(source, real_file_folder, target_folder)
75
+ next false # return false means don't go deeper
76
+ elsif child.file?
77
+ mirror_with_symlink(source, real_file_folder, target_folder)
78
+ next true
79
+ else
80
+ next true
81
+ end
82
+ end
83
+
84
+
85
+ # symbol link copy resource for static framework
86
+ hash = Prebuild::Passer.resources_to_copy_for_static_framework || {}
87
+
88
+ path_objects = hash[name]
89
+ if path_objects != nil
90
+ path_objects.each do |object|
91
+ make_link(object.real_file_path, object.target_file_path)
92
+ end
93
+ end
94
+ end # of for each
95
+
96
+ end # of method
97
+
98
+ end
99
+ end
100
+ end
101
+
102
+
103
+ # Let cocoapods use the prebuild framework files in install process.
104
+ #
105
+ # the code only effect the second pod install process.
106
+ #
107
+ module Pod
108
+ class Installer
109
+
110
+
111
+ # Remove the old target files if prebuild frameworks changed
112
+ def remove_target_files_if_needed
113
+
114
+ changes = Pod::Prebuild::Passer.prebuild_pods_changes
115
+ updated_names = []
116
+ if changes == nil
117
+ updated_names = PrebuildSandbox.from_standard_sandbox(self.sandbox).exsited_framework_pod_names
118
+ else
119
+ added = changes.added
120
+ changed = changes.changed
121
+ deleted = changes.deleted
122
+ updated_names = added + changed + deleted
123
+ end
124
+
125
+ updated_names.each do |name|
126
+ root_name = Specification.root_name(name)
127
+ next if self.sandbox.local?(root_name)
128
+
129
+ # delete the cached files
130
+ target_path = self.sandbox.pod_dir(root_name)
131
+ target_path.rmtree if target_path.exist?
132
+
133
+ support_path = sandbox.target_support_files_dir(root_name)
134
+ support_path.rmtree if support_path.exist?
135
+ end
136
+
137
+ end
138
+
139
+
140
+ # Modify specification to use only the prebuild framework after analyzing
141
+ old_method2 = instance_method(:resolve_dependencies)
142
+ define_method(:resolve_dependencies) do
143
+
144
+ # Remove the old target files, else it will not notice file changes
145
+ self.remove_target_files_if_needed
146
+
147
+ # call original
148
+ old_method2.bind(self).()
149
+ # ...
150
+ # ...
151
+ # ...
152
+ # after finishing the very complex orginal function
153
+
154
+ # check the pods
155
+ # Although we have did it in prebuild stage, it's not sufficient.
156
+ # Same pod may appear in another target in form of source code.
157
+ # Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
158
+ self.validate_every_pod_only_have_one_form
159
+
160
+
161
+ # prepare
162
+ cache = []
163
+
164
+ def add_vendered_framework(spec, platform, added_framework_file_path)
165
+ if spec.attributes_hash[platform] == nil
166
+ spec.attributes_hash[platform] = {}
167
+ end
168
+ vendored_frameworks = spec.attributes_hash[platform]["vendored_frameworks"] || []
169
+ vendored_frameworks = [vendored_frameworks] if vendored_frameworks.kind_of?(String)
170
+ vendored_frameworks += [added_framework_file_path]
171
+ spec.attributes_hash[platform]["vendored_frameworks"] = vendored_frameworks
172
+ end
173
+ def empty_source_files(spec)
174
+ spec.attributes_hash["source_files"] = []
175
+ ["ios", "watchos", "tvos", "osx"].each do |plat|
176
+ if spec.attributes_hash[plat] != nil
177
+ spec.attributes_hash[plat]["source_files"] = []
178
+ end
179
+ end
180
+ end
181
+
182
+
183
+ specs = self.analysis_result.specifications
184
+ prebuilt_specs = (specs.select do |spec|
185
+ self.prebuild_pod_names.include? spec.root.name
186
+ end)
187
+
188
+ prebuilt_specs.each do |spec|
189
+
190
+ # Use the prebuild framworks as vendered frameworks
191
+ # get_corresponding_targets
192
+ targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
193
+ targets.each do |target|
194
+ # the framework_file_path rule is decided when `install_for_prebuild`,
195
+ # as to compitable with older version and be less wordy.
196
+ framework_file_path = target.framework_name
197
+ framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
198
+ add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
199
+ end
200
+ # Clean the source files
201
+ # we just add the prebuilt framework to specific platform and set no source files
202
+ # for all platform, so it doesn't support the sence that 'a pod perbuild for one
203
+ # platform and not for another platform.'
204
+ empty_source_files(spec)
205
+
206
+ # to remove the resurce bundle target.
207
+ # When specify the "resource_bundles" in podspec, xcode will generate a bundle
208
+ # target after pod install. But the bundle have already built when the prebuit
209
+ # phase and saved in the framework folder. We will treat it as a normal resource
210
+ # file.
211
+ # https://github.com/leavez/cocoapods-binary/issues/29
212
+ if spec.attributes_hash["resource_bundles"]
213
+ bundle_names = spec.attributes_hash["resource_bundles"].keys
214
+ spec.attributes_hash["resource_bundles"] = nil
215
+ spec.attributes_hash["resources"] ||= []
216
+ spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
217
+ end
218
+
219
+ # to avoid the warning of missing license
220
+ spec.attributes_hash["license"] = {}
221
+
222
+ end
223
+
224
+ end
225
+
226
+
227
+ # Override the download step to skip download and prepare file in target folder
228
+ old_method = instance_method(:install_source_of_pod)
229
+ define_method(:install_source_of_pod) do |pod_name|
230
+
231
+ # copy from original
232
+ pod_installer = create_pod_installer(pod_name)
233
+ # \copy from original
234
+
235
+ if self.prebuild_pod_names.include? pod_name
236
+ pod_installer.install_for_prebuild!(self.sandbox)
237
+ else
238
+ pod_installer.install!
239
+ end
240
+
241
+ # copy from original
242
+ @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
243
+ # \copy from original
244
+ end
245
+
246
+
247
+ end
248
+ end
249
+
250
+ # A fix in embeded frameworks script.
251
+ #
252
+ # The framework file in pod target folder is a symblink. The EmbedFrameworksScript use `readlink`
253
+ # to read the read path. As the symlink is a relative symlink, readlink cannot handle it well. So
254
+ # we override the `readlink` to a fixed version.
255
+ #
256
+ module Pod
257
+ module Generator
258
+ class EmbedFrameworksScript
259
+
260
+ old_method = instance_method(:script)
261
+ define_method(:script) do
262
+
263
+ script = old_method.bind(self).()
264
+ patch = <<-SH.strip_heredoc
265
+ #!/bin/sh
266
+
267
+ # ---- this is added by cocoapods-binary ---
268
+ # Readlink cannot handle relative symlink well, so we override it to a new one
269
+ # If the path isn't an absolute path, we add a realtive prefix.
270
+ old_read_link=`which readlink`
271
+ readlink () {
272
+ path=`$old_read_link $1`;
273
+ if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
274
+ echo $path;
275
+ else
276
+ echo "`dirname $1`/$path";
277
+ fi
278
+ }
279
+ # ---
280
+ SH
281
+
282
+ # patch the rsync for copy dSYM symlink
283
+ script = script.gsub "rsync --delete", "rsync --copy-links --delete"
284
+
285
+ patch + script
286
+ end
287
+ end
288
+ end
289
+ end