環境
現象
dg deploy
を実行すると、適切にBundle Identifierを指定しているにも関わらず、Bundle Identifierの入力を求められたのち、
下記のエラーが発生する。
Status deploygate-cli ver 0.6.4 Error message undefined method `build_configuration_list' for nil:NilClass Backtrace /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/xcode/analyze.rb:145:in `target_build_configration' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/xcode/analyze.rb:91:in `target_xcode_setting_provisioning_profile_uuid' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/commands/deploy/build.rb:50:in `ios' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/commands/deploy/build.rb:22:in `run' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/commands/deploy.rb:16:in `run' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/command_builder.rb:70:in `block (2 levels) in run' /path/to/gemroot/gems/commander-4.4.5/lib/commander/command.rb:182:in `call' /path/to/gemroot/gems/commander-4.4.5/lib/commander/command.rb:153:in `run' /path/to/gemroot/gems/commander-4.4.5/lib/commander/runner.rb:446:in `run_active_command' /path/to/gemroot/gems/fastlane-2.57.2/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:64:in `run!' /path/to/gemroot/gems/commander-4.4.5/lib/commander/delegates.rb:15:in `run!' /path/to/gemroot/gems/deploygate-0.6.4/lib/deploygate/command_builder.rb:128:in `run' /path/to/gemroot/gems/deploygate-0.6.4/bin/dg:6:in `<top (required)>' /path/to/gemroot/bin/dg:23:in `load' /path/to/gemroot/bin/dg:23:in `<main>' /path/to/gemroot/bin/ruby_executable_hooks:15:in `eval' /path/to/gemroot/bin/ruby_executable_hooks:15:in `<main>'
解消方法
Xcodeのメニューバーから、[Product]> [Scheme]> [Manage Schemes ...] を開き、閉じる。
原因
lib/deploygate/xcode/analyze.rb
が必要とする、*.xcscheme
が存在しないため
調査記録
なんだか業務issue感さえ漂うので、何を調べたのか書き残す。余談。
Backtraceいわく、target_build_configration
の処理中に問題が発生したことがわかる。
def target_build_configration target_project_setting.build_configuration_list.build_configurations.reject{|conf| conf.name != @build_configuration}.first end
https://github.com/DeployGate/deploygate-cli/blob/v0.6.4/lib/deploygate/xcode/analyze.rb#L145
undefined method 'build_configuration_list' for nil:NilClass
ということから、target_project_setting
の結果がnil
であることが直接の問題であるとわかる。
def target_project_setting scheme_file = find_xcschemes xs = Xcodeproj::XCScheme.new(scheme_file) target_name = xs.profile_action.buildable_product_runnable.buildable_reference.target_name target_project.native_targets.reject{|target| target.name != target_name}.first end
https://github.com/DeployGate/deploygate-cli/blob/v0.6.4/lib/deploygate/xcode/analyze.rb#L153-L155
ではtarget_project_setting
の中身で何が起きているのか確認するため、scheme_file
, xs
, target_name
をprintしてみたところ、すべてnil
であることが確認できた。
この時点で、まずfind_xcschemes
が怪しいと直感を得た。(悪い癖)
native_targets.reject{|target| target.name != target_name}
を見て、「ああ、target_nameがnilになっちゃって正しいtargetも捨てちゃってるんだな」という認識を挟むのが正しい怪しみ方だろう。
def find_xcschemes shared_schemes = Dir[File.join(@xcodeproj, 'xcshareddata', 'xcschemes', '*.xcscheme')].reject do |scheme| @scheme != File.basename(scheme, '.xcscheme') end user_schemes = Dir[File.join(@xcodeproj, 'xcuserdata', '*.xcuserdatad', 'xcschemes', '*.xcscheme')].reject do |scheme| @scheme != File.basename(scheme, '.xcscheme') end shared_schemes.concat(user_schemes).first end
https://github.com/DeployGate/deploygate-cli/blob/v0.6.4/lib/deploygate/xcode/analyze.rb#L165-L170
で、find_xcschemes
の中にあるshared_schemes
, user_schemes
もprintしてみればこっちもnil
だと確認した。
というかブロックの中に入っていなかった。
File.join
で組んでいるパターンをターミナルからも確かめた結果、*.xcscheme
が生成されていないことがわかった。
おそらくこれが原因だろうと、schemeを作る手段を求めて上記解消方法を試したところ、*.xcscheme
が生成されたことを確認できた。
関連リンク
解消手順を報告させてもらったissue