cocoapods-binary 0.4.3 → 0.4.4

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
- SHA1:
3
- metadata.gz: 68b6e39958a64ccfaf68bcf58f5cf85610102f04
4
- data.tar.gz: 84301375e1c5b4ed7f8d68436bf34f6a74137084
2
+ SHA256:
3
+ metadata.gz: 7b59508b448e37d01ed739d543e081ef5e29ac379a8864a06ba90f4ffeec1092
4
+ data.tar.gz: ba6d98f85c6ed5e725186b3a8425d26b11637d0c8a868102ddd6525282954ca2
5
5
  SHA512:
6
- metadata.gz: 6f7d2a697838a6de2ee1a3f0086fea28abcf32d477ef44646f149fc4476da0c219f56cc0e144799b781ce002f7ebf641f92733f33ddb272fc6c7629f66138572
7
- data.tar.gz: b3b3e7c23ecb186c409d0d50f1a82188881c870a40a055aacf0542a54351a126b5dd0c774af4244c2572fe6309e9542d980107e655ac6da6b49bacbae6b513fa
6
+ metadata.gz: 99999f08eca4b68e4d1b5fbad63a943402adfe1c15aaae23ff4f60a9971972a876baa01fa51d4922ca8e7ef243baf6cc290af3029ef17dd70f6a3373cb412673
7
+ data.tar.gz: 9e75f9cf7e4eb114b93ed45c07c3f7ecf4d96800be9dd51fad65fdaeb04635d293575675e3b768b64df1c2492c43af6e97e802a5ee1364d93008f57f316ae177
@@ -13,13 +13,14 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = 'https://github.com/leavez/cocoapods-binary'
14
14
  spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/).reject{|f| f.start_with? "test/"}
16
+ spec.files = `git ls-files`.split($/).reject{|f| f.start_with?("test/") || f.start_with?('demo/')}
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_dependency "cocoapods", ">= 1.5.0", "< 2.0"
22
22
  spec.add_dependency "fourflusher", "~> 2.0"
23
+ spec.add_dependency "xcpretty", "~> 0.3.0"
23
24
 
24
25
  spec.add_development_dependency 'bundler', '~> 1.3'
25
26
  spec.add_development_dependency 'rake'
@@ -2,6 +2,7 @@ require_relative 'helper/podfile_options'
2
2
  require_relative 'helper/feature_switches'
3
3
  require_relative 'helper/prebuild_sandbox'
4
4
  require_relative 'helper/passer'
5
+ require_relative 'helper/target_checker'
5
6
 
6
7
 
7
8
  # NOTE:
@@ -32,6 +33,7 @@ module Pod
32
33
 
33
34
  # make a relatvie symbol link for all children
34
35
  def walk(path, &action)
36
+ return unless path.exist?
35
37
  path.children.each do |child|
36
38
  result = action.call(child, &action)
37
39
  if child.directory?
@@ -128,18 +130,12 @@ module Pod
128
130
  # call original
129
131
  old_method2.bind(self).()
130
132
 
133
+ # check the pods
134
+ # Although we have did it in prebuild stage, it's not sufficient.
135
+ # Same pod may appear in another target in form of source code.
136
+ Prebuild.check_one_pod_should_have_only_one_target(self.prebuild_pod_targets)
131
137
 
132
- # check the prebuilt targets
133
- targets = self.prebuild_pod_targets
134
- targets_have_different_platforms = targets.select {|t| t.pod_name != t.name }
135
-
136
- if targets_have_different_platforms.count > 0
137
- names = targets_have_different_platforms.map(&:pod_name)
138
- STDERR.puts "[!] Binary doesn't support pods who integrate in 2 or more platforms simultaneously: #{names}".red
139
- exit
140
- end
141
-
142
-
138
+ #
143
139
  specs = self.analysis_result.specifications
144
140
  prebuilt_specs = (specs.select do |spec|
145
141
  self.prebuild_pod_names.include? spec.root.name
@@ -24,6 +24,37 @@ module Pod
24
24
  DSL.dont_remove_source_code = true
25
25
  end
26
26
 
27
+ # Add custom xcodebuild option to the prebuilding action
28
+ #
29
+ # You may use this for your special demands. For example: the default archs in dSYMs
30
+ # of prebuilt frameworks is 'arm64 armv7 x86_64', and no 'i386' for 32bit simulator.
31
+ # It may generate a warning when building for a 32bit simulator. You may add following
32
+ # to your podfile
33
+ #
34
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks :simulator => "ARCHS=$(ARCHS_STANDARD)" `
35
+ #
36
+ # Another example to disable the generating of dSYM file:
37
+ #
38
+ # ` set_custom_xcodebuild_options_for_prebuilt_frameworks "DEBUG_INFORMATION_FORMAT=dwarf"`
39
+ #
40
+ #
41
+ # @param [String or Hash] options
42
+ #
43
+ # If is a String, it will apply for device and simulator. Use it just like in the commandline.
44
+ # If is a Hash, it should be like this: { :device => "XXXXX", :simulator => "XXXXX" }
45
+ #
46
+ def set_custom_xcodebuild_options_for_prebuilt_frameworks(options)
47
+ if options.kind_of? Hash
48
+ DSL.custom_build_options = [ options[:device] ] unless options[:device].nil?
49
+ DSL.custom_build_options_simulator = [ options[:simulator] ] unless options[:simulator].nil?
50
+ elsif options.kind_of? String
51
+ DSL.custom_build_options = [options]
52
+ DSL.custom_build_options_simulator = [options]
53
+ else
54
+ raise "Wrong type."
55
+ end
56
+ end
57
+
27
58
  private
28
59
  class_attr_accessor :prebuild_all
29
60
  prebuild_all = false
@@ -33,6 +64,11 @@ module Pod
33
64
 
34
65
  class_attr_accessor :dont_remove_source_code
35
66
  dont_remove_source_code = false
67
+
68
+ class_attr_accessor :custom_build_options
69
+ class_attr_accessor :custom_build_options_simulator
70
+ self.custom_build_options = []
71
+ self.custom_build_options_simulator = []
36
72
  end
37
73
  end
38
74
  end
@@ -1,5 +1,7 @@
1
1
  require_relative 'rome/build_framework'
2
2
  require_relative 'helper/passer'
3
+ require_relative 'helper/target_checker'
4
+
3
5
 
4
6
  # patch prebuild ability
5
7
  module Pod
@@ -67,6 +69,10 @@ module Pod
67
69
  # Build the needed framework files
68
70
  def prebuild_frameworks!
69
71
 
72
+ # check
73
+ # give a early warning, instead of after compiling all the pods
74
+ Prebuild.check_one_pod_should_have_only_one_target(self.pod_targets)
75
+
70
76
  # build options
71
77
  sandbox_path = sandbox.root
72
78
  existed_framework_folder = sandbox.generate_framework_path
@@ -98,7 +104,9 @@ module Pod
98
104
  sum
99
105
  end
100
106
  targets = root_names_to_update.map do |root_name|
101
- name_to_target_hash[root_name]
107
+ t = name_to_target_hash[root_name]
108
+ raise "There's no target named (#{root_name}) in Pod.xcodeproj.\n #{name_to_target_hash.keys}" if t.nil?
109
+ t
102
110
  end || []
103
111
 
104
112
  # add the dendencies
@@ -111,16 +119,18 @@ module Pod
111
119
  targets = targets.reject {|pod_target| sandbox.local?(pod_target.pod_name) }
112
120
 
113
121
 
114
-
115
122
  # build!
116
123
  Pod::UI.puts "Prebuild frameworks (total #{targets.count})"
117
124
  Pod::Prebuild.remove_build_dir(sandbox_path)
118
125
  targets.each do |target|
119
- next unless target.should_build?
126
+ if !target.should_build?
127
+ UI.puts "Prebuilding #{target.label}"
128
+ next
129
+ end
120
130
 
121
131
  output_path = sandbox.framework_folder_path_for_pod_name(target.name)
122
132
  output_path.mkpath unless output_path.exist?
123
- Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled)
133
+ Pod::Prebuild.build(sandbox_path, target, output_path, bitcode_enabled, Podfile::DSL.custom_build_options, Podfile::DSL.custom_build_options_simulator)
124
134
 
125
135
  # save the resource paths for later installing
126
136
  if target.static_framework? and !target.resource_paths.empty?
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBinary
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -0,0 +1,49 @@
1
+
2
+ module Pod
3
+ class Prebuild
4
+
5
+ # Check the targets, for the current limitation of the plugin
6
+ #
7
+ # @param [Array<PodTarget>] prebuilt_targets
8
+ def self.check_one_pod_should_have_only_one_target(prebuilt_targets)
9
+
10
+ targets_have_different_platforms = prebuilt_targets.select {|t| t.pod_name != t.name }
11
+
12
+ if targets_have_different_platforms.count > 0
13
+ names = targets_have_different_platforms.map(&:pod_name)
14
+ raw_names = targets_have_different_platforms.map(&:name)
15
+ message = "Oops, you came across a limitation of cocoapods-binary.
16
+
17
+ The plugin requires that one pod should have ONLY ONE target in the 'Pod.xcodeproj'. There are mainly 2 situations \
18
+ causing this problem:
19
+
20
+ 1. One pod integrates in 2 or more different platforms' targets. e.g.
21
+ ```
22
+ target 'iphoneApp' do
23
+ pod 'A', :binary => true
24
+ end
25
+ target 'watchApp' do
26
+ pod 'A'
27
+ end
28
+ ```
29
+
30
+ 2. Use different subspecs in multiple targets. e.g.
31
+ ```
32
+ target 'iphoneApp' do
33
+ pod 'A/core'
34
+ pod 'A/network'
35
+ end
36
+ target 'iphoneAppTest' do
37
+ pod 'A/core'
38
+ end
39
+ ```
40
+
41
+ Related pods: #{names}, target names: #{raw_names}
42
+ "
43
+ raise Informative, message
44
+ end
45
+ end
46
+
47
+
48
+ end
49
+ end
@@ -1,4 +1,5 @@
1
1
  require 'fourflusher'
2
+ require 'xcpretty'
2
3
 
3
4
  CONFIGURATION = "Release"
4
5
  PLATFORMS = { 'iphonesimulator' => 'iOS',
@@ -15,7 +16,10 @@ def build_for_iosish_platform(sandbox,
15
16
  target,
16
17
  device,
17
18
  simulator,
18
- bitcode_enabled)
19
+ bitcode_enabled,
20
+ custom_build_options = [], # Array<String>
21
+ custom_build_options_simulator = [] # Array<String>
22
+ )
19
23
 
20
24
  deployment_target = target.platform.deployment_target.to_s
21
25
 
@@ -26,47 +30,77 @@ def build_for_iosish_platform(sandbox,
26
30
  if bitcode_enabled
27
31
  other_options += ['BITCODE_GENERATION_MODE=bitcode']
28
32
  end
29
- xcodebuild(sandbox, target_label, device, deployment_target, other_options)
30
- xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'])
33
+
34
+ is_succeed, _ = xcodebuild(sandbox, target_label, device, deployment_target, other_options + custom_build_options)
35
+ exit 1 unless is_succeed
36
+ is_succeed, _ = xcodebuild(sandbox, target_label, simulator, deployment_target, other_options + ['ARCHS=x86_64', 'ONLY_ACTIVE_ARCH=NO'] + custom_build_options_simulator)
37
+ exit 1 unless is_succeed
31
38
 
32
39
  # paths
33
40
  root_name = target.pod_name
34
41
  module_name = target.product_module_name
35
- device_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{root_name}/#{module_name}.framework"
36
- simulator_framwork_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{root_name}/#{module_name}.framework"
42
+ device_framework_path = "#{build_dir}/#{CONFIGURATION}-#{device}/#{root_name}/#{module_name}.framework"
43
+ simulator_framework_path = "#{build_dir}/#{CONFIGURATION}-#{simulator}/#{root_name}/#{module_name}.framework"
37
44
 
38
- device_binary = device_framwork_path + "/#{module_name}"
39
- simulator_binary = simulator_framwork_path + "/#{module_name}"
45
+ device_binary = device_framework_path + "/#{module_name}"
46
+ simulator_binary = simulator_framework_path + "/#{module_name}"
40
47
  return unless File.file?(device_binary) && File.file?(simulator_binary)
41
48
 
42
49
  # the device_lib path is the final output file path
43
- # combine the bianries
50
+ # combine the binaries
44
51
  tmp_lipoed_binary_path = "#{build_dir}/#{root_name}"
45
52
  lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_binary} #{simulator_binary}`
46
53
  puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
47
54
  FileUtils.mv tmp_lipoed_binary_path, device_binary, :force => true
48
55
 
49
56
  # collect the swiftmodule file for various archs.
50
- device_swiftmodule_path = device_framwork_path + "/Modules/#{module_name}.swiftmodule"
51
- simulator_swiftmodule_path = simulator_framwork_path + "/Modules/#{module_name}.swiftmodule"
57
+ device_swiftmodule_path = device_framework_path + "/Modules/#{module_name}.swiftmodule"
58
+ simulator_swiftmodule_path = simulator_framework_path + "/Modules/#{module_name}.swiftmodule"
52
59
  if File.exist?(device_swiftmodule_path)
53
60
  FileUtils.cp_r simulator_swiftmodule_path + "/.", device_swiftmodule_path
54
61
  end
55
62
 
63
+ # combine the generated swift headers
64
+ # (In xcode 10.2, the generated swift headers vary for each archs)
65
+ # https://github.com/leavez/cocoapods-binary/issues/58
66
+ simulator_generated_swift_header_path = simulator_framework_path + "/Headers/#{module_name}-Swift.h"
67
+ device_generated_swift_header_path = device_framework_path + "/Headers/#{module_name}-Swift.h"
68
+ if File.exist? simulator_generated_swift_header_path
69
+ device_header = File.read(device_generated_swift_header_path)
70
+ simulator_header = File.read(simulator_generated_swift_header_path)
71
+ # https://github.com/Carthage/Carthage/issues/2718#issuecomment-473870461
72
+ combined_header_content = %Q{
73
+ #if TARGET_OS_SIMULATOR // merged by cocoapods-binary
74
+
75
+ #{simulator_header}
76
+
77
+ #else // merged by cocoapods-binary
78
+
79
+ #{device_header}
80
+
81
+ #endif // merged by cocoapods-binary
82
+ }
83
+ File.write(device_generated_swift_header_path, combined_header_content.strip)
84
+ end
85
+
56
86
  # handle the dSYM files
57
- device_dsym = "#{device_framwork_path}.dSYM"
87
+ device_dsym = "#{device_framework_path}.dSYM"
58
88
  if File.exist? device_dsym
59
89
  # lipo the simulator dsym
60
- tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
61
- lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_framwork_path}.dSYM/Contents/Resources/DWARF/#{module_name}`
62
- puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
63
- FileUtils.mv tmp_lipoed_binary_path, "#{device_framwork_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
90
+ simulator_dsym = "#{simulator_framework_path}.dSYM"
91
+ if File.exist? simulator_dsym
92
+ tmp_lipoed_binary_path = "#{output_path}/#{module_name}.draft"
93
+ lipo_log = `lipo -create -output #{tmp_lipoed_binary_path} #{device_dsym}/Contents/Resources/DWARF/#{module_name} #{simulator_dsym}/Contents/Resources/DWARF/#{module_name}`
94
+ puts lipo_log unless File.exist?(tmp_lipoed_binary_path)
95
+ FileUtils.mv tmp_lipoed_binary_path, "#{device_framework_path}.dSYM/Contents/Resources/DWARF/#{module_name}", :force => true
96
+ end
97
+ # move
64
98
  FileUtils.mv device_dsym, output_path, :force => true
65
99
  end
66
100
 
67
101
  # output
68
102
  output_path.mkpath unless output_path.exist?
69
- FileUtils.mv device_framwork_path, output_path, :force => true
103
+ FileUtils.mv device_framework_path, output_path, :force => true
70
104
 
71
105
  end
72
106
 
@@ -75,7 +109,23 @@ def xcodebuild(sandbox, target, sdk='macosx', deployment_target=nil, other_optio
75
109
  platform = PLATFORMS[sdk]
76
110
  args += Fourflusher::SimControl.new.destination(:oldest, platform, deployment_target) unless platform.nil?
77
111
  args += other_options
78
- Pod::Executable.execute_command 'xcodebuild', args, true
112
+ log = `xcodebuild #{args.join(" ")} 2>&1`
113
+ exit_code = $?.exitstatus # Process::Status
114
+ is_succeed = (exit_code == 0)
115
+
116
+ if !is_succeed
117
+ begin
118
+ # 64 represent command invalid. http://www.manpagez.com/man/3/sysexits/
119
+ raise "shouldn't be handle by xcpretty" if exit_code == 64
120
+ printer = XCPretty::Printer.new({:formatter => XCPretty::Simple, :colorize => 'auto'})
121
+ log.each_line do |line|
122
+ printer.pretty_print(line)
123
+ end
124
+ rescue
125
+ puts log
126
+ end
127
+ end
128
+ [is_succeed, log]
79
129
  end
80
130
 
81
131
 
@@ -94,7 +144,7 @@ module Pod
94
144
  # [Pathname] output_path
95
145
  # output path for generated frameworks
96
146
  #
97
- def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false)
147
+ def self.build(sandbox_root_path, target, output_path, bitcode_enabled = false, custom_build_options=[], custom_build_options_simulator=[])
98
148
 
99
149
  return unless not target == nil
100
150
 
@@ -104,8 +154,8 @@ module Pod
104
154
 
105
155
  # -- build the framework
106
156
  case target.platform.name
107
- when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled)
108
- when :osx then xcodebuild(sandbox, target.label)
157
+ when :ios then build_for_iosish_platform(sandbox, build_dir, output_path, target, 'iphoneos', 'iphonesimulator', bitcode_enabled, custom_build_options, custom_build_options_simulator)
158
+ when :osx then xcodebuild(sandbox, target.label, 'macosx', nil, custom_build_options)
109
159
  # when :tvos then build_for_iosish_platform(sandbox, build_dir, target, 'appletvos', 'appletvsimulator')
110
160
  # when :watchos then build_for_iosish_platform(sandbox, build_dir, target, 'watchos', 'watchsimulator')
111
161
  else raise "Unsupported platform for '#{target.name}': '#{target.platform.name}'" end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-binary
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - leavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods
@@ -44,6 +44,20 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: xcpretty
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.3.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.3.0
47
61
  - !ruby/object:Gem::Dependency
48
62
  name: bundler
49
63
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +110,7 @@ files:
96
110
  - lib/cocoapods-binary/helper/passer.rb
97
111
  - lib/cocoapods-binary/helper/podfile_options.rb
98
112
  - lib/cocoapods-binary/helper/prebuild_sandbox.rb
113
+ - lib/cocoapods-binary/helper/target_checker.rb
99
114
  - lib/cocoapods-binary/rome/build_framework.rb
100
115
  - lib/cocoapods-binary/tool/tool.rb
101
116
  - lib/cocoapods_plugin.rb
@@ -120,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
135
  version: '0'
121
136
  requirements: []
122
137
  rubyforge_project:
123
- rubygems_version: 2.5.2.3
138
+ rubygems_version: 2.7.6
124
139
  signing_key:
125
140
  specification_version: 4
126
141
  summary: A CocoaPods plugin to integrate pods in form of prebuilt frameworks, not