fastlane setting version number according to iTunes Connect

    require 'spaceship'
    Spaceship::Tunes.login
    app = Spaceship::Tunes::Application.find("your app bundle Id")
    version = app.edit_version
    require 'spaceship'
    Spaceship::Tunes.login
    app = Spaceship::Tunes::Application.find("your app bundle Id")
    version = app.edit_version
    if version
      latest_app_version = version.raw_data["version"]["value"]
    else
      puts "No edit version available"
      version = app.live_version
      latest_app_version = version.raw_data["version"]["value"]
    puts "Latest live version: #{latest_app_version}"
    new_version = latest_app_version.to_f + 0.1
    puts "New version: #{format("%.1f", new_version)}"
    end

    increment_version_number(
      version_number: "#{format("%.1f", new_version)}"
    )

//get version from iTunes! and add 0.1 to that version.

reference: https://github.com/fastlane/fastlane/issues/11716

add device to run

  1. Login to your iphone provisioning portal through developer.apple.com
    1. open Certificates, Identifiers & Profiles

    2. click Devices
    3. click + button
  2. copy UDID of the device
    1. open iTunes
    2. Click on Serial number
    3. when UDID is show, right click and copy
  3. Add the UDID in devices
  4. Go back to XCode, open Preferences
    1. open Accounts
    2. click team ID
    3. click Download Manual Profiles
  5. Run!