Method: Pod::Generator::AppTargetHelper.create_app_host_main_file

Defined in:
lib/cocoapods/generator/app_target_helper.rb

.create_app_host_main_file(project, platform, name = 'App') ⇒ Pathname

Creates a default app host 'main.m' file.

Parameters:

  • project (Project)

    the Xcodeproj to generate the target into.

  • platform (Symbol)

    the platform of the target. Can be :ios or :osx.

  • name (String) (defaults to: 'App')

    The name of the folder to use and save the generated main file.

Returns:

  • (Pathname)

    the new source file that was generated.



249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/cocoapods/generator/app_target_helper.rb', line 249

def self.create_app_host_main_file(project, platform, name = 'App')
  source_file = project.path.dirname.+("#{name}/main.m")
  source_file.parent.mkpath
  source_file.open('w') do |f|
    case platform
    when :ios, :tvos
      f << IOS_APP_HOST_MAIN_CONTENTS
    when :osx
      f << MACOS_APP_HOST_MAIN_CONTENTS
    end
  end
  source_file
end