Class: Gym::PackageCommandGeneratorXcode7
- Inherits:
-
Object
- Object
- Gym::PackageCommandGeneratorXcode7
- Defined in:
- gym/lib/gym/generators/package_command_generator_xcode7.rb
Overview
Responsible for building the fully working xcodebuild command
Constant Summary collapse
- DEFAULT_EXPORT_METHOD =
"app-store"
Class Method Summary collapse
-
.app_thinning_path ⇒ Object
The path to the app-thinning plist file.
-
.app_thinning_size_report_path ⇒ Object
The path to the App Thinning Size Report file.
-
.apps_path ⇒ Object
The path to the Apps folder.
- .appstore_info_path ⇒ Object
-
.asset_packs_path ⇒ Object
The path to the Apps folder.
- .binary_path ⇒ Object
-
.config_path ⇒ Object
The path the config file we use to sign our app.
-
.dsym_path ⇒ Object
The path the the dsym file for this app.
- .generate ⇒ Object
- .ipa_path ⇒ Object
-
.manifest_path ⇒ Object
The path to the manifest plist file.
- .options ⇒ Object
- .pipe ⇒ Object
-
.temporary_output_path ⇒ Object
We export the ipa into this directory, as we can’t specify the ipa file directly.
-
.wrap_xcodebuild ⇒ Object
Wrap xcodebuild to work-around ipatool dependency to system ruby.
Class Method Details
.app_thinning_path ⇒ Object
The path to the app-thinning plist file
131 132 133 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 131 def app_thinning_path Gym.cache[:app_thinning] ||= File.join(temporary_output_path, "app-thinning.plist") end |
.app_thinning_size_report_path ⇒ Object
The path to the App Thinning Size Report file
136 137 138 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 136 def app_thinning_size_report_path Gym.cache[:app_thinning_size_report] ||= File.join(temporary_output_path, "App Thinning Size Report.txt") end |
.apps_path ⇒ Object
The path to the Apps folder
141 142 143 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 141 def apps_path Gym.cache[:apps_path] ||= File.join(temporary_output_path, "Apps") end |
.appstore_info_path ⇒ Object
150 151 152 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 150 def appstore_info_path Gym.cache[:appstore_info_path] ||= File.join(temporary_output_path, "AppStoreInfo.plist") end |
.asset_packs_path ⇒ Object
The path to the Apps folder
146 147 148 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 146 def asset_packs_path Gym.cache[:asset_packs_path] ||= File.join(temporary_output_path, "OnDemandResources") end |
.binary_path ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 85 def binary_path path = Gym.cache[:binary_path] return path if path path = Dir[File.join(temporary_output_path, "*.pkg")].last app_path = Dir[File.join(temporary_output_path, "*.app")].last # We need to process generic PKG or APP if path # Try to find PKG file in the output directory, used when app thinning was not set Gym.cache[:binary_path] = File.join(temporary_output_path, "#{Gym.config[:output_name]}.pkg") FileUtils.mv(path, Gym.cache[:binary_path]) unless File.(path).casecmp(File.(Gym.cache[:binary_path]).downcase).zero? elsif Dir.exist?(apps_path) # Try to find "generic" PKG file inside "Apps" folder, used when app thinning was set files = Dir[File.join(apps_path, "*.pkg")] # Generic PKG file doesn't have suffix so its name is the shortest path = files.min_by(&:length) Gym.cache[:binary_path] = File.join(temporary_output_path, "#{Gym.config[:output_name]}.pkg") FileUtils.cp(path, Gym.cache[:binary_path]) unless File.(path).casecmp(File.(Gym.cache[:binary_path]).downcase).zero? elsif app_path # Try to find .app file in the output directory. This is used when macOS is set and .app is being generated. Gym.cache[:binary_path] = File.join(temporary_output_path, "#{Gym.config[:output_name]}.app") FileUtils.mv(app_path, Gym.cache[:binary_path]) unless File.(app_path).casecmp(File.(Gym.cache[:binary_path]).downcase).zero? else ErrorHandler.handle_empty_pkg unless path end Gym.cache[:binary_path] end |
.config_path ⇒ Object
The path the config file we use to sign our app
120 121 122 123 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 120 def config_path Gym.cache[:config_path] ||= "#{Tempfile.new('gym_config').path}.plist" return Gym.cache[:config_path] end |
.dsym_path ⇒ Object
The path the the dsym file for this app. Might be nil
115 116 117 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 115 def dsym_path Dir[BuildCommandGenerator.archive_path + "/**/*.app.dSYM"].last end |
.generate ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 22 def generate parts = ["/usr/bin/xcrun #{wrap_xcodebuild.shellescape} -exportArchive"] parts += parts += pipe File.write(config_path, config_content) # overwrite everytime. Could be optimized parts end |
.ipa_path ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 61 def ipa_path path = Gym.cache[:ipa_path] return path if path path = Dir[File.join(temporary_output_path, "*.ipa")].last # We need to process generic IPA if path # Try to find IPA file in the output directory, used when app thinning was not set Gym.cache[:ipa_path] = File.join(temporary_output_path, "#{Gym.config[:output_name]}.ipa") FileUtils.mv(path, Gym.cache[:ipa_path]) unless File.(path).casecmp?(File.(Gym.cache[:ipa_path]).downcase) elsif Dir.exist?(apps_path) # Try to find "generic" IPA file inside "Apps" folder, used when app thinning was set files = Dir[File.join(apps_path, "*.ipa")] # Generic IPA file doesn't have suffix so its name is the shortest path = files.min_by(&:length) Gym.cache[:ipa_path] = File.join(temporary_output_path, "#{Gym.config[:output_name]}.ipa") FileUtils.cp(path, Gym.cache[:ipa_path]) unless File.(path).casecmp?(File.(Gym.cache[:ipa_path]).downcase) else ErrorHandler.handle_empty_ipa unless path end Gym.cache[:ipa_path] end |
.manifest_path ⇒ Object
The path to the manifest plist file
126 127 128 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 126 def manifest_path Gym.cache[:manifest_path] ||= File.join(temporary_output_path, "manifest.plist") end |
.options ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 32 def config = Gym.config = [] << "-exportOptionsPlist '#{config_path}'" << "-archivePath #{BuildCommandGenerator.archive_path.shellescape}" << "-exportPath '#{temporary_output_path}'" << "-toolchain '#{config[:toolchain]}'" if config[:toolchain] << config[:export_xcargs] if config[:export_xcargs] << config[:xcargs] if config[:xcargs] end |
.pipe ⇒ Object
46 47 48 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 46 def pipe [""] end |
.temporary_output_path ⇒ Object
We export the ipa into this directory, as we can’t specify the ipa file directly
51 52 53 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 51 def temporary_output_path Gym.cache[:temporary_output_path] ||= Dir.mktmpdir('gym_output') end |
.wrap_xcodebuild ⇒ Object
Wrap xcodebuild to work-around ipatool dependency to system ruby
56 57 58 59 |
# File 'gym/lib/gym/generators/package_command_generator_xcode7.rb', line 56 def wrap_xcodebuild require 'fileutils' @wrapped_xcodebuild_path ||= File.join(Gym::ROOT, "lib/assets/wrap_xcodebuild/xcbuild-safe.sh") end |