我确实将方法添加到了fastlane脚本中:
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.28.2"
default_platform :ios
platform :ios do
# some code was copied from fastlane/app_store_build_number
def get_last_app_version(app_identifier)
Spaceship::Tunes.login('some-user@icloud.com')
Spaceship::Tunes.select_team
app = Spaceship::Tunes::Application.find(app_identifier)
train_numbers = app.all_build_train_numbers(platform: platform)
self.order_versions(train_numbers).last
end
def self.order_versions(versions)
versions.map(&:to_s).sort_by { |v| Gem::Version.new(v) }
end
# ....
end
并在我的快速通道动作中调用它:
lane :get_ver do
get_certificates(
username: 'some-user@icloud.com',
team_name: 'Our team name'
)
app_version = get_last_app_version('com.some-app.ios')
# further actions
end
当我执行get_ver
操作时,出现错误wrong number of arguments (given 0, expected 1)
,并且不明白哪里出了问题
用一个参数定义并调用的方法也有一个参数,这是什么原因?
我也尝试添加参数名称:
get_last_app_version(app_identifier: 'com.some-app.ios')
去掉括号:
get_last_app_version 'com.some-app.ios'
但是结果是一样的
完整错误输出:
Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/fast_file.rb:112:in `platform': [!] wrong number of arguments (given 0, expected 1) (ArgumentError) from Fastfile:22:in `get_last_app_version' from Fastfile:58:in `block (2 levels) in parsing_binding' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/lane.rb:33:in `call' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/runner.rb:45:in `chdir' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/runner.rb:45:in `execute' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/lane_manager.rb:56:in `cruise_lane' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run' from /Library/Ruby/Gems/2.3.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call' from /Library/Ruby/Gems/2.3.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run' from /Library/Ruby/Gems/2.3.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:74:in `run!' from /Library/Ruby/Gems/2.3.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/commands_generator.rb:333:in `run' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/fastlane/lib/fastlane/cli_tools_distributor.rb:108:in `take_off' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.99.0/bin/fastlane:20:in `' from /usr/local/bin/fastlane:22:in `load' from /usr/local/bin/fastlane:22:in `'
答案 0 :(得分:2)
您的错误消息说,您应该将参数传递给platform
方法调用,此行将发生在此行:
train_numbers = app.all_build_train_numbers(platform: platform)