cocoapods-binaryhqp 0.4.8

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
+ SHA256:
3
+ metadata.gz: bdd23ae869768d260d8575fd1ef550c3d68efde0256099537f443d44c7a6b6c0
4
+ data.tar.gz: d9288a1d9d6b3148adadccaf1608b51cb34280093a33e3bc29bc6f23d52c7cda
5
+ SHA512:
6
+ metadata.gz: da7673f9961783babc73636d91c44885e4821fb0fd98ede8ec8c877d59a447f2cd4f56e62f7a6cafc64c6e19b509d9a3e5a1193ec8d36bdb4b5343e8c86533bb
7
+ data.tar.gz: 6f2a336589e0893c47ce358efe1e88dc567094a531ed07a81fd9e987001e2740dbc65b522f41f69db1722ee180aa393cddea806da628c004512b0ad7ae8b113d
@@ -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
+
data/.gitignore ADDED
@@ -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
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
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
+ - sh test.sh
12
+ - cd ..
13
+
14
+ # auto deploy on tagging
15
+ # automatically set by `travis setup rubygems`
16
+ deploy:
17
+ provider: rubygems
18
+ api_key:
19
+ secure: HglQwElI8cEeKc5oXzoVbBBprgb8k7RUr0YOH1N1fhpNW7HJpJtSLzUBPC5T+Sv5RPSicaxY/oXeYE6x4E7Oadf7Gy2tmM9iwwJQh6YgZ/foh9G9obHZtTerhB4wY2cjguBXDmLqiMRiJzNTZRvoUnESBKakPbK/ODY0mHT+LDdMwZk2QsMjD3fRc5M7JRR29jr56jzVuUdy0lR4TRoc2+yIRqp2vFNtcbKdzKuYgzcdE9xzPh0FQzgiImA5uGDruyAgoNeOlGxDPZdnm7fw/epLmq8fUIZanReI30QnJeIErFwMCVeN1zVqQiWRgv8qGi8Z0ZKOzvcu7oKuaeXo5xSkTfkAc9I0LbcRd3UHCluAr9JHuERNwkn1qx5W0DdngTKrPM65ZABQxk4KUHt+5yd6Dv7lR9GrGD3teNZDga/X8u0tQIkoPIl76ZjXRh0bmCDQM/zWaTKkh7eX/YXQKgrjrEecZMeZfsLds789MK2QO17QlbHTVno+HBr0Rah6nHI0/vl1xqHthHCb/Y9SBXmLQ7+ySNXmj7YxPjpD6m8kEEUDTQQdgjS7vMInqJiSekGBImu2VQA/qZP1+WEBha5nX2ADfvsAWfUdsdQfuTbv07RnIG+3quzSl5U1UPVR9f7EsqpTtxflLJCqVdaz2ndQBO6NXAnRhA90cfAFd9s=
20
+ gem: cocoapods-binaryhqp
21
+ on:
22
+ tags: true
23
+ repo: leavez/cocoapods-binaryhqp
@@ -0,0 +1,15 @@
1
+ {
2
+ "configurations": [
3
+ {
4
+ "name": "Debug CocoaPods Binary",
5
+ "showDebuggerOutput": true,
6
+ "type": "Ruby",
7
+ "request": "launch",
8
+ "useBundler": true,
9
+ "cwd": "${workspaceRoot}/demo", // pod 命令执行的路径
10
+ "program": "/usr/local/bin/pod",
11
+ "args": ["update", "--verbose","--sources=http://gitlab.9tong.com/ios-group/HQPFoundation/hqpspecs.git"], // `pod` 命令的参数
12
+ // "args": ["install"]
13
+ }
14
+ ]
15
+ }
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-binaryhqp.gemspec
4
+ gemspec
5
+
6
+
7
+
8
+ gem 'cocoapods'
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ gem 'ruby-debug-ide'
14
+ gem 'debase', '~> 0.2.5.beta2'
15
+
data/Gemfile.lock ADDED
@@ -0,0 +1,131 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-binaryhqp (0.4.7)
5
+ cocoapods
6
+ fourflusher
7
+ plist
8
+ xcpretty
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ CFPropertyList (3.0.5)
14
+ rexml
15
+ activesupport (6.1.4.1)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
+ addressable (2.8.0)
22
+ public_suffix (>= 2.0.2, < 5.0)
23
+ algoliasearch (1.27.5)
24
+ httpclient (~> 2.8, >= 2.8.3)
25
+ json (>= 1.5.1)
26
+ atomos (0.1.3)
27
+ bacon (1.2.0)
28
+ claide (1.0.3)
29
+ cocoapods (1.11.2)
30
+ addressable (~> 2.8)
31
+ claide (>= 1.0.2, < 2.0)
32
+ cocoapods-core (= 1.11.2)
33
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
34
+ cocoapods-downloader (>= 1.4.0, < 2.0)
35
+ cocoapods-plugins (>= 1.0.0, < 2.0)
36
+ cocoapods-search (>= 1.0.0, < 2.0)
37
+ cocoapods-trunk (>= 1.4.0, < 2.0)
38
+ cocoapods-try (>= 1.1.0, < 2.0)
39
+ colored2 (~> 3.1)
40
+ escape (~> 0.0.4)
41
+ fourflusher (>= 2.3.0, < 3.0)
42
+ gh_inspector (~> 1.0)
43
+ molinillo (~> 0.8.0)
44
+ nap (~> 1.0)
45
+ ruby-macho (>= 1.0, < 3.0)
46
+ xcodeproj (>= 1.21.0, < 2.0)
47
+ cocoapods-core (1.11.2)
48
+ activesupport (>= 5.0, < 7)
49
+ addressable (~> 2.8)
50
+ algoliasearch (~> 1.0)
51
+ concurrent-ruby (~> 1.1)
52
+ fuzzy_match (~> 2.0.4)
53
+ nap (~> 1.0)
54
+ netrc (~> 0.11)
55
+ public_suffix (~> 4.0)
56
+ typhoeus (~> 1.0)
57
+ cocoapods-deintegrate (1.0.5)
58
+ cocoapods-downloader (1.5.1)
59
+ cocoapods-plugins (1.0.0)
60
+ nap
61
+ cocoapods-search (1.0.1)
62
+ cocoapods-trunk (1.6.0)
63
+ nap (>= 0.8, < 2.0)
64
+ netrc (~> 0.11)
65
+ cocoapods-try (1.2.0)
66
+ colored2 (3.1.2)
67
+ concurrent-ruby (1.1.9)
68
+ debase (0.2.5.beta2)
69
+ debase-ruby_core_source (>= 0.10.12)
70
+ debase-ruby_core_source (0.10.13)
71
+ escape (0.0.4)
72
+ ethon (0.15.0)
73
+ ffi (>= 1.15.0)
74
+ ffi (1.15.4)
75
+ fourflusher (2.3.1)
76
+ fuzzy_match (2.0.4)
77
+ gh_inspector (1.1.3)
78
+ httpclient (2.8.3)
79
+ i18n (1.8.11)
80
+ concurrent-ruby (~> 1.0)
81
+ json (2.6.1)
82
+ minitest (5.14.4)
83
+ mocha (1.13.0)
84
+ mocha-on-bacon (0.2.3)
85
+ mocha (>= 0.13.0)
86
+ molinillo (0.8.0)
87
+ nanaimo (0.3.0)
88
+ nap (1.1.0)
89
+ netrc (0.11.0)
90
+ plist (3.6.0)
91
+ prettybacon (0.0.2)
92
+ bacon (~> 1.2)
93
+ public_suffix (4.0.6)
94
+ rake (13.0.6)
95
+ rexml (3.2.5)
96
+ rouge (2.0.7)
97
+ ruby-debug-ide (0.7.3)
98
+ rake (>= 0.8.1)
99
+ ruby-macho (2.5.1)
100
+ typhoeus (1.4.0)
101
+ ethon (>= 0.9.0)
102
+ tzinfo (2.0.4)
103
+ concurrent-ruby (~> 1.0)
104
+ xcodeproj (1.21.0)
105
+ CFPropertyList (>= 2.3.3, < 4.0)
106
+ atomos (~> 0.1.3)
107
+ claide (>= 1.0.2, < 2.0)
108
+ colored2 (~> 3.1)
109
+ nanaimo (~> 0.3.0)
110
+ rexml (~> 3.2.4)
111
+ xcpretty (0.3.0)
112
+ rouge (~> 2.0.7)
113
+ zeitwerk (2.5.1)
114
+
115
+ PLATFORMS
116
+ ruby
117
+
118
+ DEPENDENCIES
119
+ bacon
120
+ bundler
121
+ cocoapods
122
+ cocoapods-binaryhqp!
123
+ debase (~> 0.2.5.beta2)
124
+ mocha
125
+ mocha-on-bacon
126
+ prettybacon
127
+ rake
128
+ ruby-debug-ide
129
+
130
+ BUNDLED WITH
131
+ 2.1.4
data/LICENSE.txt ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,80 @@
1
+ <p align="center"><img src="/test/logo.png" width="622"></p>
2
+
3
+ [![Build Status](https://travis-ci.org/leavez/cocoapods-binary.svg?branch=master)](https://travis-ci.org/leavez/cocoapods-binary)
4
+
5
+ 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.
6
+
7
+ 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.)
8
+
9
+
10
+ ## Why
11
+
12
+ 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.
13
+
14
+ This plugin implements this simple wish. Replace the source code in pod target with prebuilt frameworks.
15
+
16
+ Why don't use Carthage? While Carthage also integrates libs in form of frameworks, there several reasons to use CocoaPods with this plugin:
17
+
18
+ - Pod is a good simple form to organize files, manage dependencies. (private or local pods)
19
+ - Fast switch between source code and binary, or partial source code, partial binaries.
20
+ - Some libs don't support Carthage.
21
+
22
+ ## How it works
23
+
24
+ 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.
25
+
26
+ #### Under the hood
27
+
28
+ ( You could leave this paragraph for further reading, and try it now. )
29
+
30
+ 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.
31
+
32
+ Then in the flowing normal install process, we hook the integration functions to modify pod specification to using our frameworks.
33
+
34
+ ## Installation
35
+
36
+ ## 编译方法
37
+ sudo gem build cocoapods-binaryhqp.gemspec && sudo gem install cocoapods-binaryhqp-0.4.7.gem
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
+
67
+ #### Known Issues
68
+
69
+ - doesn't support watchos now
70
+ - ~~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)
71
+
72
+ ## License
73
+
74
+ MIT
75
+
76
+ Appreciate a 🌟 if you like it.
77
+
78
+ # cocoapods-binaryhqp
79
+
80
+
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
+
Binary file
Binary file
@@ -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-binaryhqp/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-binaryhqp'
8
+ spec.version = CocoapodsBinaryHqp::VERSION
9
+ spec.authors = ['leavez']
10
+ spec.email = ['gaojiji@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/leavez/cocoapods-binary'
14
+ spec.homepage = 'https://www.baidu.com'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($/).reject{|f| f.start_with?("test/") || f.start_with?('demo/') || f.start_with?('ddqp-swift/')}
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency "cocoapods"
23
+ spec.add_runtime_dependency "fourflusher"
24
+ spec.add_runtime_dependency "xcpretty"
25
+ spec.add_runtime_dependency "CFPropertyList"
26
+
27
+ spec.add_development_dependency 'bundler'
28
+ spec.add_development_dependency 'rake'
29
+ end
@@ -0,0 +1,292 @@
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
+
185
+ prebuilt_specs = (specs.select do |spec|
186
+
187
+ self.prebuild_pod_names.include? spec.root.name
188
+ end)
189
+
190
+ prebuilt_specs.each do |spec|
191
+
192
+ # Use the prebuild framworks as vendered frameworks
193
+ # get_corresponding_targets
194
+ targets = Pod.fast_get_targets_for_pod_name(spec.root.name, self.pod_targets, cache)
195
+
196
+ targets.each do |target|
197
+ # the framework_file_path rule is decided when `install_for_prebuild`,
198
+ # as to compitable with older version and be less wordy.
199
+ framework_file_path = target.framework_name
200
+ framework_file_path = target.name + "/" + framework_file_path if targets.count > 1
201
+ add_vendered_framework(spec, target.platform.name.to_s, framework_file_path)
202
+ end
203
+ # Clean the source files
204
+ # we just add the prebuilt framework to specific platform and set no source files
205
+ # for all platform, so it doesn't support the sence that 'a pod perbuild for one
206
+ # platform and not for another platform.'
207
+ empty_source_files(spec)
208
+
209
+ # to remove the resurce bundle target.
210
+ # When specify the "resource_bundles" in podspec, xcode will generate a bundle
211
+ # target after pod install. But the bundle have already built when the prebuit
212
+ # phase and saved in the framework folder. We will treat it as a normal resource
213
+ # file.
214
+ # https://github.com/leavez/cocoapods-binary/issues/29
215
+ if spec.attributes_hash["resource_bundles"]
216
+ bundle_names = spec.attributes_hash["resource_bundles"].keys
217
+ spec.attributes_hash["resource_bundles"] = nil
218
+ spec.attributes_hash["resources"] ||= []
219
+ spec.attributes_hash["resources"] += bundle_names.map{|n| n+".bundle"}
220
+ end
221
+
222
+ # to avoid the warning of missing license
223
+ spec.attributes_hash["license"] = {}
224
+
225
+ end
226
+
227
+ end
228
+
229
+
230
+ # Override the download step to skip download and prepare file in target folder
231
+ old_method = instance_method(:install_source_of_pod)
232
+ define_method(:install_source_of_pod) do |pod_name|
233
+
234
+ # copy from original
235
+ pod_installer = create_pod_installer(pod_name)
236
+ # \copy from original
237
+
238
+ if self.prebuild_pod_names.include? pod_name
239
+ pod_installer.install_for_prebuild!(self.sandbox)
240
+ else
241
+ pod_installer.install!
242
+ end
243
+
244
+ # copy from original
245
+ @installed_specs.concat(pod_installer.specs_by_platform.values.flatten.uniq)
246
+ # \copy from original
247
+ end
248
+
249
+
250
+ end
251
+ end
252
+
253
+ # A fix in embeded frameworks script.
254
+ #
255
+ # The framework file in pod target folder is a symblink. The EmbedFrameworksScript use `readlink`
256
+ # to read the read path. As the symlink is a relative symlink, readlink cannot handle it well. So
257
+ # we override the `readlink` to a fixed version.
258
+ #
259
+ module Pod
260
+ module Generator
261
+ class EmbedFrameworksScript
262
+
263
+ old_method = instance_method(:script)
264
+ define_method(:script) do
265
+
266
+ script = old_method.bind(self).()
267
+ patch = <<-SH.strip_heredoc
268
+ #!/bin/sh
269
+
270
+ # ---- this is added by cocoapods-binary ---
271
+ # Readlink cannot handle relative symlink well, so we override it to a new one
272
+ # If the path isn't an absolute path, we add a realtive prefix.
273
+ old_read_link=`which readlink`
274
+ readlink () {
275
+ path=`$old_read_link "$1"`;
276
+ if [ $(echo "$path" | cut -c 1-1) = '/' ]; then
277
+ echo $path;
278
+ else
279
+ echo "`dirname $1`/$path";
280
+ fi
281
+ }
282
+ # ---
283
+ SH
284
+
285
+ # patch the rsync for copy dSYM symlink
286
+ script = script.gsub "rsync --delete", "rsync --copy-links --delete"
287
+
288
+ patch + script
289
+ end
290
+ end
291
+ end
292
+ end