Class: Fastlane::Actions::XamarinIosAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



95
96
97
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 95

def self.authors
  ["Thomas Charriere"]
end

.available_optionsObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 115

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :solution,
                                 env_name: "XAMARIN_SOLUTION",
                                 description: "Path to Solution to compile",
                                 optional: false,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :target,
                                 env_name: "XAMARIN_TARGET",
                                 description: "Specifies the Build Targets: Build",
                                 default_value: 'Build',
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :configuration,
                                 env_name: "XAMARIN_CONFIGURATION",
                                 description: "Specifies the build configuration to use, such as 'Debug' or 'Release'. The Configuration property is used to determine default values for other properties which determine target behavior. Additional configurations may be created within your IDE",
                                 default_value: 'Release',
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :platform,
                                 env_name: "XAMARIN_PLATFORM",
                                 description: "Specifies the platform configuration to use, such as 'iPhone' or 'iPhoneSimulator'. The Platform property is used to determine default values for other properties which determine target behavior. Additional configurations may be created within your IDE",
                                 default_value: 'iPhone',
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :define_constants,
                                 env_name: "XAMARIN_DEFINECONSTANTS",
                                 description: "Defines conditional compiler constants",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :msbuild,
                                 env_name: "XAMARIN_MSBUILD",
                                 description: "Path to `msbuild`. Default value is found by using `which msbuild`",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :build_ipa,
                                 env_name: "XAMARIN_BUILDIPA",
                                 description: "A boolean value which determines whether the ipa should be built",
                                 default_value: true,
                                 optional: true,
                                 type: Fastlane::Boolean),

    FastlaneCore::ConfigItem.new(key: :ipa_package_dir,
                                 env_name: "XAMARIN_IPAPACKAGEDIR",
                                 description: "Set custom IPA directory",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :codesign_entitlements,
                                 env_name: "XAMARIN_CODESIGNENTITLEMENTS",
                                 description: "",
                                 optional: true,
                                 type: Fastlane::Boolean), 

    FastlaneCore::ConfigItem.new(key: :include_itunes_artwork,
                                 env_name: "XAMARIN_INCLUDEITUNESARTWORK",
                                 description: "Includes ITunesArtwork images",
                                 optional: true,
                                 type: Fastlane::Boolean), 

    FastlaneCore::ConfigItem.new(key: :codesign_key,
                                 env_name: "XAMARIN_CODESIGNKEY",
                                 description: "A signing identity",
                                 optional: true,  
                                 type: String), 

    FastlaneCore::ConfigItem.new(key: :codesign_provision,
                                 env_name: "XAMARIN_CODESIGNPROVISION",
                                 description: "Id/Name of the provisioning profile",
                                 optional: true,
                                 type: String)
  ]

end

.descriptionObject



91
92
93
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 91

def self.description
  "Build Xamarin Android + iOS projects"
end

.detailsObject



103
104
105
106
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 103

def self.details
  # Optional:
  "Build Xamarin Android + iOS projects"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


196
197
198
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 196

def self.is_supported?(platform)
  [:ios].include?(platform)
end

.outputObject



108
109
110
111
112
113
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 108

def self.output
  [
    ['XAMARIN_IOS_IPA', 'Path to the ipa'],
    ['XAMARIN_IOS_SYM', 'Path to the dysm of the ipa']
  ]
end

.return_valueObject



99
100
101
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 99

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/fastlane/plugin/xamarin/actions/xamarin_ios_action.rb', line 9

def self.run(params)

  msbuild = params[:msbuild] || FastlaneCore::CommandExecutor.which('msbuild')

  if msbuild.nil?
      UI.error("Could not find msbuild")
      return
  end

  if FastlaneCore::Globals.verbose?
    FastlaneCore::PrintTable.print_values(
      config: params,
      title: "Summary of parameters passed"
    )
  end        
  command = Array.new

  command.push(msbuild)
  command.push(params[:solution])
  command.push("/t:#{params[:target]}")
  command.push("/p:Configuration=#{params[:configuration]}") unless params[:configuration].nil?
  command.push("/p:Platform=#{params[:platform]}") unless params[:platform].nil?
  command.push("/p:DefineConstants=#{params[:define_constants]}") unless params[:define_constants].nil?
  command.push("/p:BuildIpa=#{params[:build_ipa]}") unless params[:build_ipa].nil?
  command.push("/p:IpaPackageDir=#{params[:ipa_package_dir]}") unless params[:ipa_package_dir].nil?
  command.push("/p:CodesignEntitlements=#{params[:codesign_entitlements]}") unless params[:codesign_entitlements].nil?
  command.push("/p:IpaIncludeArtwork=#{params[:include_itunes_artwork]}") unless params[:include_itunes_artwork].nil?
  command.push("/p:CodesignKey=#{params[:codesign_key]}") unless params[:codesign_key].nil?
  command.push("/p:CodesignProvision=#{params[:codesign_provision]}") unless params[:codesign_provision].nil?

  if FastlaneCore::Globals.verbose?
    command.push("/v:d")
  else
    command.push("/v:m")
  end

  exit_status = 0
  result = FastlaneCore::CommandExecutor.execute(command: command,
                                  print_command: true,
                                  print_all: FastlaneCore::Globals.verbose?,
                                  error: proc do |error_output|
                                    exit_status = $?.exitstatus
                                    UI.error("Wups, invalid")
                                  end)

  if exit_status == 0
    UI.success("Successfully executed msbuild")

    if params[:ipa_package_dir].nil?

    end

    Dir.glob(File.join(File.dirname(params[:solution]), "/**/bin/#{params[:platform]}/#{params[:configuration]}/*.ipa")) {|file|

      Actions.lane_context[SharedValues::XAMARIN_IOS_IPA] = file
      Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] = file
    }

    Dir.glob(File.join(File.dirname(params[:solution]), "/**/bin/#{params[:platform]}/#{params[:configuration]}/*.dSYM")) {|file|

      zipfile = file + ".zip"

      File.delete(zipfile) if File.exist?(zipfile)

      Actions::ZipAction.run(path: file, output_path:  zipfile)
      Actions.lane_context[SharedValues::XAMARIN_IOS_SYM] = zipfile
      Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] = zipfile

    }

    FastlaneCore::PrintTable.print_values(
      config: Actions.lane_context,
      title: "Summary of Xamarin Build"
    )

  else
    UI.user_error!("Unable to build - see log for more info")
  end
  

end