fir-cli 1.5.1 → 1.6.0

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
2
  SHA1:
3
- metadata.gz: 983c34c1ff6964b4cff980a06a83900468aa5d56
4
- data.tar.gz: 16e5217fd7d08a5aed2dd4451a0e46d19cd9ab63
3
+ metadata.gz: 273a3d4a1727d563e204dbdad7fc16e6c9763c08
4
+ data.tar.gz: dcd37c2d1bba37d0bbb5f770b9aaaede8cb37eef
5
5
  SHA512:
6
- metadata.gz: da2875e4eea8e5f5b9263462ef7ed27afbe81831fa2614b10a3ef244074e68d79ba65938a28f710a568275e5bc5354d377894d1bf9f74cc287df3861982309f6
7
- data.tar.gz: f174fb83ee008253cdb62689c30ca5c0e566de20af1375b13aa41b40cc41dc993ccb45ac99e848120cc4c8cfd15e991b13c7709dc74087ed64d0ee879d80a12f
6
+ metadata.gz: a9ac2d63c1d9fe1ec682a17a94964dd6a7460b90b2b70a5a8d10047bb1abf307ce6fd18bf952593bdd6e55cc45d0a5296114dd78292b2328ff1f7d9aaeb616b3
7
+ data.tar.gz: 021bdb6ed3dfd98aed9941eef21569cfb466e1c8a63a37a115052d366cade76432f0fca3ccd4a2e79935d9507c47f0b62ceebf147ce066ca59df1fd2f047bd8b
data/.gitignore CHANGED
@@ -20,3 +20,5 @@ Gemfile.lock
20
20
  /test/cases/*.png
21
21
  /build_apk_example_*
22
22
  /build_ipa_example_*
23
+
24
+ .idea/
data/.travis.yml CHANGED
@@ -1,28 +1,31 @@
1
1
  rvm:
2
- - 1.9.2
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1
6
- - 2.2
7
- - 2.3
8
- - ruby-head
9
- - rbx-2
10
- - jruby
11
- - jruby-head
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3
8
+ - ruby-head
9
+ - rbx-2
10
+ - jruby
11
+ - jruby-head
12
12
  matrix:
13
13
  allow_failures:
14
- - rvm: ruby-head
15
- - rvm: jruby
16
- - rvm: jruby-head
17
- - rvm: rbx-2
14
+ - rvm: ruby-head
15
+ - rvm: jruby
16
+ - rvm: jruby-head
17
+ - rvm: rbx-2
18
18
  env:
19
+ matrix:
19
20
  - USE_OFFICIAL_GEM_SOURCE=true
21
+ global:
22
+ secure: XiWKHPcQNB/mGv8Q5VuBqETS1bmYZ3t5xJkR/JFHrhWi30O+QWulMM5YjzkVawPjpUS/rtefDEASc4bN+a1iRVi6kf8fxjeKNFAzNc/hEKiPgANELf1JJgGAcz4oygzrH94Vqj90fuf6DoUh9r+IO+Z0PF39GL9GCnUjJeg+zao=
20
23
  notifications:
21
24
  recipients:
22
- - hxy@fir.im
25
+ - hxy@fir.im
23
26
  branches:
24
27
  only:
25
- - master
28
+ - master
26
29
  addons:
27
30
  code_climate:
28
31
  repo_token: 7158bd5d0218441524b8663790dd28edba8a870387ed000a1b56968e3315af2a
data/doc/build_ipa.md CHANGED
@@ -15,6 +15,8 @@ Options:
15
15
  -C, [--configuration=CONFIGURATION] # Use the build configuration NAME for building each target
16
16
  -d, [--destination=DESTINATION] # Set the destinationspecifier
17
17
  -t, [--target=TARGET] # Build the target specified by targetname
18
+ -E, [--export_method=METHOD] # for exportOptionsPlist method, ad-hoc as default
19
+ -O, [--optionPlistPath] # User defined exportOptionsPlist path
18
20
  -f, [--profile=PROFILE] # Set the export provisioning profile
19
21
  -o, [--output=OUTPUT] # IPA output path, the default is: BUILD_DIR/fir_build_ipa
20
22
  -p, [--publish], [--no-publish] # true/false if publish to fir.im
@@ -55,3 +57,10 @@ Options:
55
57
  ```sh
56
58
  $ fir build_ipa path/to/workspace -w -S <scheme name>
57
59
  ```
60
+
61
+
62
+ ChangeLog 1.6.0
63
+
64
+ - 支持 XCode 8.3 打包
65
+ * 新增参数 -E,指定 exportOptionsPlist plist 文件中的方法, 默认为 ad-hoc
66
+ * 用户可自定义 -exportOptionsPlist 中的 plist 路径
data/fir-cli.gemspec CHANGED
@@ -44,4 +44,5 @@ Gem::Specification.new do |spec|
44
44
  spec.add_dependency 'rest-client', '~> 2.0'
45
45
  spec.add_dependency 'ruby_android', '~> 0.7'
46
46
  spec.add_dependency 'rqrcode', '~> 0.7'
47
+ spec.add_dependency 'xcodeproj', '~> 1.4'
47
48
  end
data/lib/fir/cli.rb CHANGED
@@ -29,13 +29,15 @@ module FIR
29
29
  method_option :workspace, type: :boolean, aliases: '-w', desc: 'true/false if build workspace'
30
30
  method_option :scheme, type: :string, aliases: '-S', desc: 'Set the scheme NAME if build workspace'
31
31
  method_option :configuration, type: :string, aliases: '-C', desc: 'Use the build configuration NAME for building each target'
32
- method_option :destination, type: :string, aliases: '-d', desc: 'Set the destinationspecifier'
33
- method_option :target, type: :string, aliases: '-t', desc: 'Build the target specified by targetname'
32
+ method_option :destination, type: :string, aliases: '-d', desc: 'Set the destination specifier'
33
+ method_option :target, type: :string, aliases: '-t', desc: 'Build the target specified by target name'
34
+ method_option :export_method, type: :string, aliases: '-E', desc: 'for exportOptionsPlist method, ad-hoc as default'
35
+ method_option :optionPlistPath, type: :string, aliases: '-O', desc: 'User defined exportOptionsPlist path'
34
36
  method_option :profile, type: :string, aliases: '-f', desc: 'Set the export provisioning profile'
35
37
  method_option :output, type: :string, aliases: '-o', desc: 'IPA output path, the default is: BUILD_DIR/fir_build_ipa'
36
38
  method_option :publish, type: :boolean, aliases: '-p', desc: 'true/false if publish to fir.im'
37
39
  method_option :short, type: :string, aliases: '-s', desc: 'Set custom short link if publish to fir.im'
38
- method_option :name, type: :string, aliases: '-n', desc: 'Set custom ipa name when builded'
40
+ method_option :name, type: :string, aliases: '-n', desc: 'Set custom ipa name when built'
39
41
  method_option :changelog, type: :string, aliases: '-c', desc: 'Set changelog if publish to fir.im'
40
42
  method_option :qrcode, type: :boolean, aliases: '-Q', desc: 'Generate qrcode'
41
43
  method_option :mapping, type: :boolean, aliases: '-M', desc: 'true/false if upload app mapping file to BugHD.com'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+ require 'xcodeproj'
2
3
 
3
4
  module FIR
4
5
  module BuildIpa
@@ -7,7 +8,7 @@ module FIR
7
8
  initialize_build_common_options(args, options)
8
9
 
9
10
  @build_tmp_dir = Dir.mktmpdir
10
- @build_cmd = initialize_ipa_build_cmd(args, options)
11
+ @build_cmd = initialize_ipa_build_cmd(args, options)
11
12
 
12
13
  logger_info_and_run_build_command
13
14
 
@@ -22,17 +23,32 @@ module FIR
22
23
 
23
24
  def initialize_ipa_build_cmd(args, options)
24
25
  @configuration = options[:configuration]
25
- @target_name = options[:target]
26
- @scheme_name = options[:scheme]
27
- @profile_name = options[:profile]
28
- @destination = options[:destination]
29
-
30
- build_cmd = 'xcodebuild build -sdk iphoneos'
26
+ @target_name = options[:target]
27
+ @scheme_name = options[:scheme]
28
+ @profile_name = options[:profile]
29
+ @destination = options[:destination]
30
+ @export_method = options[:export_method] || 'ad-hoc'
31
+ @optionPlistPath = options[:optionPlistPath]
32
+
33
+ build_cmd = 'xcodebuild archive -sdk iphoneos'
31
34
  build_cmd += initialize_xcode_build_path(options)
35
+
36
+ build_settings = find_build_setting
37
+ @team_id = build_settings['DEVELOPMENT_TEAM']
38
+ provisioning_profile_id = build_settings['PROVISIONING_PROFILE']
39
+
40
+ check_ios_scheme(@scheme_name)
41
+ build_cmd += " -scheme '#{@scheme_name}'" unless @scheme_name.blank?
32
42
  build_cmd += " -configuration '#{@configuration}'" unless @configuration.blank?
33
- build_cmd += " -target '#{@target_name}'" unless @target_name.blank?
34
- build_cmd += " -destination '#{@destination}'" unless @destination.blank?
35
- build_cmd += " -exportProvisioningProfile '#{@profile_name}'" unless @profile_name.blank?
43
+
44
+ # build_cmd += " -target '#{@target_name}'" unless @target_name.blank?
45
+
46
+ # xcarchive name for build -exportArchive
47
+ @xcarchive_name = @scheme_name.nil? ? @target_name : @scheme_name + '.xcarchive'
48
+ @xcarchive_path = "#{@build_dir}/fir_build/#{@xcarchive_name}"
49
+
50
+ build_cmd += " -archivePath #{@xcarchive_path}"
51
+ build_cmd += " PROVISIONING_PROFILE='#{provisioning_profile_id}'"
36
52
  build_cmd += " #{ipa_custom_settings(args)} 2>&1"
37
53
  build_cmd
38
54
  end
@@ -40,7 +56,7 @@ module FIR
40
56
  def ipa_custom_settings(args)
41
57
  custom_settings = split_assignment_array_to_hash(args)
42
58
 
43
- setting_str = convert_hash_to_assignment_string(custom_settings)
59
+ setting_str = convert_hash_to_assignment_string(custom_settings)
44
60
  setting_str += " TARGET_BUILD_DIR='#{@build_tmp_dir}'" unless custom_settings['TARGET_BUILD_DIR']
45
61
  setting_str += " CONFIGURATION_BUILD_DIR='#{@build_tmp_dir}'" unless custom_settings['CONFIGURATION_BUILD_DIR']
46
62
  setting_str += " DWARF_DSYM_FOLDER_PATH='#{@output_path}'" unless custom_settings['DWARF_DSYM_FOLDER_PATH']
@@ -49,16 +65,15 @@ module FIR
49
65
 
50
66
  def output_ipa_and_dsym
51
67
  apps = Dir["#{@build_tmp_dir}/*.app"].sort_by(&:size)
52
- check_no_output_app(apps)
68
+ # check_no_output_app(apps)
53
69
 
54
70
  @temp_ipa = "#{@build_tmp_dir}/#{Time.now.to_i}.ipa"
55
71
  archive_ipa(apps)
56
72
 
57
- check_archived_ipa_is_exist
73
+ # check_archived_ipa_is_exist
58
74
  rename_ipa_and_dsym
59
75
 
60
76
  FileUtils.rm_rf(@build_tmp_dir) unless $DEBUG
61
-
62
77
  logger.info 'Build Success'
63
78
  end
64
79
 
@@ -66,7 +81,13 @@ module FIR
66
81
  logger.info 'Archiving......'
67
82
  logger_info_dividing_line
68
83
 
69
- @xcrun_cmd = "xcrun -sdk iphoneos PackageApplication -v #{apps.join(' ')} -o #{@temp_ipa}"
84
+ option_plist_path = @optionPlistPath || gen_option_plist
85
+
86
+ @xcrun_cmd = "#{FIR::Config::XCODE_WRAPPER_PATH} -exportArchive"
87
+ @xcrun_cmd += " -archivePath #{@xcarchive_path}"
88
+ @xcrun_cmd += " -exportOptionsPlist #{option_plist_path}"
89
+ @xcrun_cmd += " -exportPath #{@build_dir}/fir_build"
90
+
70
91
  puts @xcrun_cmd if $DEBUG
71
92
  logger.info `#{@xcrun_cmd}`
72
93
  end
@@ -78,18 +99,80 @@ module FIR
78
99
  end
79
100
  end
80
101
 
81
- def rename_ipa_and_dsym
82
- ipa_info = FIR.ipa_info(@temp_ipa)
83
- dsym_name = "#{@output_path}/#{ipa_info[:name]}.app.dSYM"
102
+ def gen_option_plist
103
+ plist = "
104
+ <plist version=\"1.0\">
105
+ <dict>
106
+ <key>teamID</key>
107
+ <string>#{@team_id}</string>
108
+ <key>method</key>
109
+ <string>#{@export_method}</string>
110
+ <key>uploadSymbols</key>
111
+ <true/>
112
+ <key>compileBitcode</key>
113
+ <false/>
114
+ <key>uploadBitcode</key>
115
+ <false/>
116
+ </dict>
117
+ </plist>"
118
+
119
+ logger.info 'Generated plist file for exportOptionsPlist argument'
120
+ logger.info "{"
121
+ logger.info " teamID:#{@team_id}" unless @team_id.nil?
122
+ logger.info " method:#{@export_method}"
123
+ logger.info " uploadSymbols:true"
124
+ logger.info " uploadBitcode:false"
125
+ logger.info "}"
126
+
127
+ begin
128
+ plist_path = "#{@build_dir}/fir_build/exportOptions.plist"
129
+ file = File.open(plist_path, "w")
130
+ file.write(plist)
131
+ plist_path
132
+ rescue IOError => e
133
+ raise e
134
+ ensure
135
+ file.close unless file.nil?
136
+ end
137
+ end
138
+
139
+ # Find build setting from xcode project by target and configuration
140
+ def find_build_setting
141
+ project = Xcodeproj::Project.open(@xc_project)
84
142
 
143
+ # find target
144
+ used_target = project.targets[0]
145
+ if @target_name
146
+ project.targets.each do |target|
147
+ if target.name == @target_name
148
+ used_target = target
149
+ end
150
+ end
151
+ end
152
+
153
+ # find configuration settings
154
+ used_target.build_configurations.each do |config|
155
+ if config.name == @configuration
156
+ return config.build_settings
157
+ end
158
+ end
159
+
160
+ logger.info "configuration '#{@configuration}' not found"
161
+ end
162
+
163
+ def rename_ipa_and_dsym
85
164
  if @name.blank?
86
165
  @ipa_name = "#{ipa_info[:name]}-#{ipa_info[:version]}-build-#{ipa_info[:build]}"
87
166
  else
88
167
  @ipa_name = @name
89
168
  end
90
169
 
170
+ @temp_ipa = "#{@build_dir}/fir_build/#{@scheme_name}.ipa"
91
171
  @builded_app_path = "#{@output_path}/#{@ipa_name}.ipa"
92
172
 
173
+ ipa_info = FIR.ipa_info(@temp_ipa)
174
+ dsym_name = " #{@output_path}/#{ipa_info[:name]}.app.dSYM"
175
+
93
176
  FileUtils.mv(@temp_ipa, @builded_app_path, force: true)
94
177
  if File.exist?(dsym_name)
95
178
  FileUtils.mv(dsym_name, "#{@output_path}/#{@ipa_name}.app.dSYM", force: true)
@@ -99,25 +182,22 @@ module FIR
99
182
  def upload_build_dsym_mapping_file
100
183
  logger_info_blank_line
101
184
 
102
- @app_info = ipa_info(@builded_app_path)
185
+ @app_info = ipa_info(@builded_app_path)
103
186
  @mapping_file = Dir["#{@output_path}/#{@ipa_name}.app.dSYM/Contents/Resources/DWARF/*"].first
104
187
 
105
- mapping @mapping_file, proj: @proj,
106
- build: @app_info[:build],
107
- version: @app_info[:version],
108
- token: @token
188
+ mapping @mapping_file, proj: @proj,
189
+ build: @app_info[:build],
190
+ version: @app_info[:version],
191
+ token: @token
109
192
  end
110
193
 
111
194
  def initialize_xcode_build_path(options)
112
195
  if options.workspace?
113
- workspace = check_and_find_ios_xcworkspace(@build_dir)
114
- check_ios_scheme(@scheme_name)
115
-
116
- return " -workspace '#{workspace}' -scheme '#{@scheme_name}'"
196
+ @xc_workspace = check_and_find_ios_xcworkspace(@build_dir)
197
+ " -workspace '#{@xc_workspace}'"
117
198
  else
118
- project = check_and_find_ios_xcodeproj(@build_dir)
119
-
120
- return " -project '#{project}'"
199
+ @xc_project = check_and_find_ios_xcodeproj(@build_dir)
200
+ " -project '#{@xc_project}'"
121
201
  end
122
202
  end
123
203
 
@@ -5,6 +5,7 @@ module FIR
5
5
  CONFIG_PATH = "#{ENV['HOME']}/.fir-cli"
6
6
  APP_INFO_PATH = "#{ENV['HOME']}/.fir-cli-app"
7
7
  API_YML_PATH = File.expand_path('../../', __FILE__) + '/api.yml'
8
+ XCODE_WRAPPER_PATH = File.expand_path('../../', __FILE__) + '/xcode_wrapper.sh'
8
9
  APP_FILE_TYPE = %w(.ipa .apk).freeze
9
10
 
10
11
  def fir_api
data/lib/fir/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module FIR
4
- VERSION = '1.5.1'
4
+ VERSION = '1.6.0'
5
5
  end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
3
+ #!/bin/bash --login
4
+
5
+ which rvm > /dev/null
6
+
7
+ if [[ $? -eq 0 ]]; then
8
+ echo "RVM detected, forcing to use system ruby since xcodebuild cause error"
9
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
10
+ rvm use system
11
+ fi
12
+
13
+ if which rbenv > /dev/null; then
14
+ echo "rbenv detected, removing env variables since xcodebuild cause error"
15
+ rbenv shell system
16
+ fi
17
+
18
+ shell_session_update() { :; }
19
+
20
+ unset RUBYLIB
21
+ unset RUBYOPT
22
+ unset BUNDLE_BIN_PATH
23
+ unset _ORIGINAL_GEM_PATH
24
+ unset BUNDLE_GEMFILE
25
+ unset GEM_HOME
26
+ unset GEM_PATH
27
+
28
+ set -x
29
+ xcodebuild "$@"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fir-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NaixSpirit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: xcodeproj
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.4'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.4'
139
153
  description: fir.im command tool, support iOS and Android
140
154
  email:
141
155
  - neverlandxy.naix@gmail.com
@@ -197,6 +211,7 @@ files:
197
211
  - lib/fir/util/parser/pngcrush.rb
198
212
  - lib/fir/util/publish.rb
199
213
  - lib/fir/version.rb
214
+ - lib/fir/xcode_wrapper.sh
200
215
  - lib/fir_cli.rb
201
216
  - test/build_ipa_test.rb
202
217
  - test/cases/test_apk.apk
@@ -234,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
249
  version: '0'
235
250
  requirements: []
236
251
  rubyforge_project:
237
- rubygems_version: 2.6.10
252
+ rubygems_version: 2.6.8
238
253
  signing_key:
239
254
  specification_version: 4
240
255
  summary: fir.im command tool