Wrong number of arguments (given 0, expected 1) (ArgumentError) at fastlane script

I did add method to my fastlane script:

# 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

And calls it in my fastlane action:

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

When I runs get_ver action, I get error wrong number of arguments (given 0, expected 1) and can't understand what's wrong

Method defined with one argument and calling has one argument too, what a reason?

Also I did try to add argument name:

get_last_app_version(app_identifier: 'com.some-app.ios')

remove brackets:

get_last_app_version 'com.some-app.ios'

But result is same

Full error output:

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 `'

1 answer

  • answered 2018-07-11 07:00 Marek Lipka

    Your error message says that you should pass argument to platform method call, which happens in this line:

    train_numbers = app.all_build_train_numbers(platform: platform)