class Produce::DeveloperCenter

Constants

ALLOWED_SERVICES
SERVICE_CLOUDKIT
SERVICE_COMPLETE
SERVICE_GAME_CENTER_IOS
SERVICE_GAME_CENTER_MAC
SERVICE_LEGACY
SERVICE_OFF
SERVICE_ON
SERVICE_UNLESS_OPEN
SERVICE_UNTIL_FIRST_LAUNCH

Public Instance Methods

app_identifier() click to toggle source
# File produce/lib/produce/developer_center.rb, line 157
def app_identifier
  Produce.config[:app_identifier].to_s
end
create_new_app() click to toggle source
# File produce/lib/produce/developer_center.rb, line 87
def create_new_app
  ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s
  if app_exists?
    UI.success("[DevCenter] App '#{Produce.config[:app_identifier]}' already exists, nothing to do on the Dev Center")
    ENV["CREATED_NEW_APP_ID"] = nil
    # Nothing to do here
  else
    app_name = Produce.config[:app_name]
    UI.message("Creating new app '#{app_name}' on the Apple Dev Center")

    app = Spaceship.app.create!(bundle_id: app_identifier,
                                     name: app_name,
                                     enable_services: enable_services,
                                     mac: platform == "osx")

    if app.name != Produce.config[:app_name]
      UI.important("Your app name includes non-ASCII characters, which are not supported by the Apple Developer Portal.")
      UI.important("To fix this a unique (internal) name '#{app.name}' has been created for you. Your app's real name '#{Produce.config[:app_name]}'")
      UI.important("will still show up correctly on App Store Connect and the App Store.")
    end

    UI.message("Created app #{app.app_id}")

    UI.crash!("Something went wrong when creating the new app - it's not listed in the apps list") unless app_exists?

    ENV["CREATED_NEW_APP_ID"] = Time.now.to_i.to_s

    UI.success("Finished creating new app '#{app_name}' on the Dev Center")
  end

  return true
end
enable_services() click to toggle source
# File produce/lib/produce/developer_center.rb, line 120
def enable_services
  app_service = Spaceship.app_service
  enabled_clean_options = {}

  # "enabled_features" was deprecated in favor of "enable_services"
  config_enabled_services = Produce.config[:enable_services] || Produce.config[:enabled_features]

  config_enabled_services.each do |k, v|
    if k.to_sym == :data_protection
      case v
      when SERVICE_COMPLETE
        enabled_clean_options[app_service.data_protection.complete.service_id] = app_service.data_protection.complete
      when SERVICE_UNLESS_OPEN
        enabled_clean_options[app_service.data_protection.unlessopen.service_id] = app_service.data_protection.unlessopen
      when SERVICE_UNTIL_FIRST_LAUNCH
        enabled_clean_options[app_service.data_protection.untilfirstauth.service_id] = app_service.data_protection.untilfirstauth
      end
    elsif k.to_sym == :icloud
      case v
      when SERVICE_LEGACY
        enabled_clean_options[app_service.cloud.on.service_id] = app_service.cloud.on
        enabled_clean_options[app_service.cloud_kit.xcode5_compatible.service_id] = app_service.cloud_kit.xcode5_compatible
      when SERVICE_CLOUDKIT
        enabled_clean_options[app_service.cloud.on.service_id] = app_service.cloud.on
        enabled_clean_options[app_service.cloud_kit.cloud_kit.service_id] = app_service.cloud_kit.cloud_kit
      end
    else
      if v == SERVICE_ON
        enabled_clean_options[app_service.send(k.to_s).on.service_id] = app_service.send(k.to_s).on
      else
        enabled_clean_options[app_service.send(k.to_s).off.service_id] = app_service.send(k.to_s).off
      end
    end
  end
  enabled_clean_options
end
run() click to toggle source
# File produce/lib/produce/developer_center.rb, line 82
def run
  login
  create_new_app
end

Private Instance Methods

app_exists?() click to toggle source
# File produce/lib/produce/developer_center.rb, line 172
def app_exists?
  Spaceship.app.find(app_identifier, mac: platform == "osx") != nil
end
login() click to toggle source
# File produce/lib/produce/developer_center.rb, line 176
def login
  Spaceship.login(Produce.config[:username], nil)
  Spaceship.select_team
end
platform() click to toggle source
# File produce/lib/produce/developer_center.rb, line 163
def platform
  # This was added to support creation of multiple platforms
  # Produce::ItunesConnect can take an array of platforms to create for App Store Connect
  # but the Developer Center is now platform agnostic so we choose any platform here
  #
  # Platform won't be needed at all in the future when this is change over to use Spaceship::ConnectAPI
  (Produce.config[:platforms] || []).first || Produce.config[:platform]
end