gym 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2a18d2f0297efde728ac6e00fecd9ecd38f82bc
4
- data.tar.gz: 933ff160cfaee41f0388d33ae9735495ca615d05
3
+ metadata.gz: a8bddec4eefadb03f7101efb31470e229e97b256
4
+ data.tar.gz: d117764cec0e9985ba4814e415f28873b89771c9
5
5
  SHA512:
6
- metadata.gz: 433ca518ab8adb50eed1b5057cab7dba891b5a37272d2b1075a556457fd23f142bb2c698edd80bd9ea4618fbb69df622682446ec0c9aa7e737625ce4ce65fa95
7
- data.tar.gz: 2cd7bc32f4772f48552e520374f816bd20d6cdc82edef35655f878ae16b415113458fd7589e9c0ff26e2dd9db5e805921071cb00d9f2fc75e8253f5e1d38c7cb
6
+ metadata.gz: 9e8c5af75a48db478c218fea0470a1aa095300359f868b23dde81c21b513a058faa430a86496bef48e12466b38141afa0baac912be4dcd4dca3db089c85a4ed4
7
+ data.tar.gz: 4297f002c14cbd9efe12a0bcc93dcf5fbcef4087164d486d728686cfbbcf7a4161d86ddbd94a18fb3e0569835532fe1961bce932823d8d29285eb91c7735874f
data/README.md CHANGED
@@ -119,6 +119,11 @@ For a list of all available parameters use
119
119
 
120
120
  gym --help
121
121
 
122
+ If you run into any issues, use the `verbose` mode to get more information
123
+
124
+
125
+ gym --verbose
126
+
122
127
  # Gymfile
123
128
 
124
129
  Since you might want to manually trigger a new build but don't want to specify all the parameters every time, you can store your defaults in a so called `Gymfile`.
@@ -130,6 +135,8 @@ scheme "Example"
130
135
 
131
136
  sdk "9.0"
132
137
 
138
+ clean true
139
+
133
140
  output_directory "./build" # store the ipa in this folder
134
141
  output_name "MyApp" # the name of the ipa file
135
142
  ```
@@ -190,8 +197,7 @@ Afterwards the `ipa` file is moved to the output folder. The `dSYM` file is comp
190
197
  Download and install the [Provisioning Plugin](https://github.com/chockenberry/Provisioning).
191
198
 
192
199
  # Need help?
193
- - If there is a technical problem with `gym`, submit an issue.
194
- - I'm available for contract work - drop me an email: gym@krausefx.com
200
+ Please submit an issue on GitHub and provide information about your setup
195
201
 
196
202
  # License
197
203
  This project is licensed under the terms of the MIT license. See the LICENSE file.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.push File.expand_path("../../lib", __FILE__)
3
+
4
+ require "gym"
5
+ require "gym/commands_generator"
6
+ Gym::CommandsGenerator.start
data/lib/gym.rb CHANGED
@@ -8,7 +8,11 @@ require 'gym/runner'
8
8
  require 'gym/error_handler'
9
9
  require 'gym/options'
10
10
  require 'gym/detect_values'
11
- require 'gym/xcode_fix'
11
+
12
+ # Import all the fixes
13
+ require 'gym/xcodebuild_fixes/swift_fix'
14
+ require 'gym/xcodebuild_fixes/watchkit_fix'
15
+ require 'gym/xcodebuild_fixes/package_application_fix'
12
16
 
13
17
  require 'fastlane_core'
14
18
  require 'terminal-table'
@@ -27,6 +31,10 @@ module Gym
27
31
  def gymfile_name
28
32
  "Gymfile"
29
33
  end
34
+
35
+ def xcode_path
36
+ @path ||= `xcode-select --print-path`.strip
37
+ end
30
38
  end
31
39
 
32
40
  Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
@@ -18,11 +18,18 @@ module Gym
18
18
  print "Make sure you use the correct provisioning profile for this app"
19
19
  print "Take a look at the ouptput above for more information"
20
20
  print "You can follow this guide: https://github.com/KrauseFx/fastlane/blob/master/docs/CodeSigning.md"
21
- when /provisioning profiles matching the bundle identifier (.*)”/
21
+ when /provisioning profiles matching the bundle identifier .(.*)./ # the . around the (.*) are for the strange "
22
22
  print "You don't have the provisioning profile for '#{$1}' installed on the local machine"
23
23
  print "Make sure you have the profile on this computer and it's properly installed"
24
24
  print "You can use sigh (https://github.com/KrauseFx/sigh) to download and install the provisioning profile"
25
25
  print "Follow this guide: https://github.com/KrauseFx/fastlane/blob/master/docs/CodeSigning.md"
26
+ when /matching the bundle identifier .(.*). were found/ # the . around the (.*) are for the strange "
27
+ print "You don't have a provisioning profile for the bundle identifier '#{$1}' installed on the local machine"
28
+ print "Make sure you have the profile on this computer and it's properly installed"
29
+ print "You can use sigh (https://github.com/KrauseFx/sigh) to download and install the provisioning profile"
30
+ print "Follow this guide: https://github.com/KrauseFx/fastlane/blob/master/docs/CodeSigning.md"
31
+
32
+ # Insert more code signing specific errors here
26
33
  when /code signing is required/
27
34
  print "Your project settings define invalid code signing settings"
28
35
  print "To generate an ipa file you need to enable code signing for your project"
@@ -17,6 +17,7 @@ module Gym
17
17
  rows << ["Workspace", config[:workspace]] if config[:workspace]
18
18
  rows << ["Scheme", config[:scheme]] if config[:scheme]
19
19
  rows << ["Configuration", config[:configuration]] if config[:configuration]
20
+ rows << ["Xcode path", Gym.xcode_path]
20
21
 
21
22
  puts ""
22
23
  puts Terminal::Table.new(
@@ -49,10 +49,7 @@ module Gym
49
49
  short_option: "-o",
50
50
  env_name: "GYM_OUTPUT_DIRECTORY",
51
51
  description: "The directory in which the ipa file should be stored in",
52
- default_value: ".",
53
- verify_block: proc do |value|
54
- raise "Directory not found at path '#{File.expand_path(value)}'".red unless File.directory?(value)
55
- end),
52
+ default_value: "."),
56
53
  FastlaneCore::ConfigItem.new(key: :output_name,
57
54
  short_option: "-n",
58
55
  env_name: "GYM_OUTPUT_NAME",
@@ -6,12 +6,9 @@ module Gym
6
6
  class PackageCommandGenerator
7
7
  class << self
8
8
  def generate
9
- @patched_package_application = XcodeFix.patch_package_application
10
-
11
- parts = ["/usr/bin/xcrun #{@patched_package_application} -v"]
9
+ parts = ["/usr/bin/xcrun #{XcodebuildFixes.patch_package_application} -v"]
12
10
  parts += options
13
11
  parts += pipe
14
- parts += postfix
15
12
 
16
13
  parts
17
14
  end
@@ -38,13 +35,8 @@ module Gym
38
35
  [""]
39
36
  end
40
37
 
41
- def postfix
42
- # Remove the patched PackageApplication file after the export is finished
43
- ["&& rm '#{@patched_package_application}'"]
44
- end
45
-
46
38
  def appfile_path
47
- Dir.glob("#{BuildCommandGenerator.archive_path}/Products/Applications/*.app").first
39
+ Dir[BuildCommandGenerator.archive_path + "/**/*.app"].last
48
40
  end
49
41
 
50
42
  # We export it to the temporary folder and move it over to the actual output once it's finished and valid
@@ -54,7 +46,7 @@ module Gym
54
46
 
55
47
  # The path the the dsym file for this app. Might be nil
56
48
  def dsym_path
57
- Dir[BuildCommandGenerator.archive_path + "/**/*.dSYM"].last
49
+ Dir[BuildCommandGenerator.archive_path + "/**/*.app.dSYM"].last
58
50
  end
59
51
  end
60
52
  end
@@ -9,7 +9,9 @@ module Gym
9
9
  build_app
10
10
  verify_archive
11
11
  package_app
12
- swift_library_fix
12
+ Gym::XcodebuildFixes.swift_library_fix
13
+ Gym::XcodebuildFixes.watchkit_fix
14
+ Gym::XcodebuildFixes.clear_patched_package_application
13
15
  move_results
14
16
  end
15
17
 
@@ -23,12 +25,12 @@ module Gym
23
25
  current = c.to_s.dup
24
26
  next unless current.length > 0
25
27
 
26
- if current.include? "-" and current.to_s.split(" '").count == 2
28
+ match_default_parameter = current.match(/(-.*) '(.*)'/)
29
+ if match_default_parameter
27
30
  # That's a default parameter, like `-project 'Name'`
28
- # We use " '" to not split by spaces within the value (e.g. path)
29
- current.split(" '")
31
+ match_default_parameter[1, 2]
30
32
  else
31
- current.gsub!("| ", "") # as the | will somehow break the terminal table
33
+ current.gsub!("| ", "\| ") # as the | will somehow break the terminal table
32
34
  [current, ""]
33
35
  end
34
36
  end
@@ -86,50 +88,11 @@ module Gym
86
88
  end)
87
89
  end
88
90
 
89
- # Determine whether it is a Swift project and, eventually, include all required libraries to copy from Xcode's toolchain directory.
90
- # Since there's no "xcodebuild" target to do just that, it is done post-build when exporting an archived build.
91
- def swift_library_fix
92
- require 'fileutils'
93
-
94
- ipa_swift_frameworks = Dir["#{PackageCommandGenerator.appfile_path}/Frameworks/libswift*"]
95
-
96
- unless ipa_swift_frameworks.empty?
97
- Dir.mktmpdir do |tmpdir|
98
- # Copy all necessary Swift libraries to a temporary "SwiftSupport" directory so that we can
99
- # easily add it to the .ipa later.
100
- swift_support = File.join(tmpdir, "SwiftSupport")
101
-
102
- Dir.mkdir(swift_support)
103
-
104
- developer_dir = `xcode-select --print-path`.strip
105
- ipa_swift_frameworks.each do |path|
106
- framework = File.basename(path)
107
-
108
- FileUtils.copy_file("#{developer_dir}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/#{framework}", File.join(swift_support, framework))
109
- end
110
-
111
- # Add "SwiftSupport" to the .ipa archive
112
- Dir.chdir(tmpdir) do
113
- command_parts = ["zip --recurse-paths #{PackageCommandGenerator.ipa_path} SwiftSupport"]
114
- command_parts << "> /dev/null" unless $verbose
115
- print_command(command_parts, "Fix Swift embedded code if needed") if $verbose
116
-
117
- FastlaneCore::CommandExecutor.execute(command: command_parts,
118
- print_all: false,
119
- print_command: !Gym.config[:silent],
120
- error: proc do |output|
121
- ErrorHandler.handle_package_error(output)
122
- end)
123
- end
124
- end
125
- end
126
- end
127
-
128
91
  # Moves over the binary and dsym file to the output directory
129
92
  # @return (String) The path to the resulting ipa file
130
93
  def move_results
131
94
  require 'fileutils'
132
-
95
+ FileUtils.mkdir_p(Gym.config[:output_directory])
133
96
  FileUtils.mv(PackageCommandGenerator.ipa_path, Gym.config[:output_directory], force: true)
134
97
 
135
98
  if PackageCommandGenerator.dsym_path
@@ -1,4 +1,4 @@
1
1
  module Gym
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  DESCRIPTION = "Building your iOS apps has never been easier"
4
4
  end
@@ -0,0 +1,9 @@
1
+ ## Fixes
2
+
3
+ This directory contains all the (hopefully temporary) work-arounds to make the `ipa` export work.
4
+
5
+ `xcodebuild` doesn't get the same set of features as Xcode does (e.g. WatchKit app export, Swift export and more)
6
+
7
+ This directory should be empty as soon as all those `xcodebuild` issues are fixed.
8
+
9
+ In the mean-time we have all the workarounds in one central place
@@ -1,15 +1,14 @@
1
1
  module Gym
2
- class XcodeFix
2
+ class XcodebuildFixes
3
3
  class << self
4
4
  # Fix PackageApplication Perl script by Xcode to create the IPA from the archive
5
5
  def patch_package_application
6
6
  require 'fileutils'
7
7
 
8
8
  # Initialization
9
- developer_dir = `xcode-select --print-path`.strip
10
- patched_package_application_path = File.join("/tmp", "PackageApplication4Gym")
9
+ @patched_package_application_path = File.join("/tmp", "PackageApplication4Gym")
11
10
  # Remove any previous patched PackageApplication
12
- FileUtils.rm patched_package_application_path if File.exist?(patched_package_application_path)
11
+ FileUtils.rm @patched_package_application_path if File.exist?(@patched_package_application_path)
13
12
 
14
13
  Dir.mktmpdir do |tmpdir|
15
14
  # Check current PackageApplication MD5
@@ -19,29 +18,37 @@ module Gym
19
18
  expected_md5 = File.read(path)
20
19
 
21
20
  # If that location changes, search it using xcrun --sdk iphoneos -f PackageApplication
22
- package_application_path = "#{developer_dir}/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication"
21
+ package_application_path = "#{Gym.xcode_path}/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication"
23
22
 
24
23
  raise "Unable to patch the `PackageApplication` script bundled in XCode. This is not supported." unless expected_md5 == Digest::MD5.file(package_application_path).hexdigest
25
24
 
26
25
  # Duplicate PackageApplication script to PackageApplication4Gym
27
- FileUtils.copy_file(package_application_path, patched_package_application_path)
26
+ FileUtils.copy_file(package_application_path, @patched_package_application_path)
28
27
 
29
28
  # Apply patches to PackageApplication4Gym from patches folder
30
29
  Dir[File.join(Helper.gem_path("gym"), "lib/assets/package_application_patches/*.diff")].each do |patch|
31
- Helper.log.info "Applying Package Application patch: #{File.basename(patch)}" unless Gym.config[:silent]
32
- command = ["patch #{patched_package_application_path} < #{patch}"]
30
+ Helper.log.info "Applying Package Application patch: #{File.basename(patch)}" if $verbose
31
+ command = ["patch #{@patched_package_application_path} < #{patch}"]
33
32
  Runner.new.print_command(command, "Applying Package Application patch: #{File.basename(patch)}") if $verbose
34
33
 
35
34
  FastlaneCore::CommandExecutor.execute(command: command,
36
35
  print_all: false,
37
- print_command: !Gym.config[:silent],
36
+ print_command: $verbose,
38
37
  error: proc do |output|
39
38
  ErrorHandler.handle_package_error(output)
40
39
  end)
41
40
  end
42
41
  end
43
42
 
44
- return patched_package_application_path # Return path to the patched PackageApplication
43
+ return @patched_package_application_path # Return path to the patched PackageApplication
44
+ end
45
+
46
+ # Remove the patched script after it was used
47
+ def clear_patched_package_application
48
+ if @patched_package_application_path and File.exist?(@patched_package_application_path)
49
+ Helper.log.debug "Removing patched PackageApplication file at path '#{@patched_package_application_path}'" if $verbose
50
+ File.delete(@patched_package_application_path)
51
+ end
45
52
  end
46
53
  end
47
54
  end
@@ -0,0 +1,45 @@
1
+ module Gym
2
+ class XcodebuildFixes
3
+ class << self
4
+ # Determine whether it is a Swift project and, eventually, include all required libraries to copy from Xcode's toolchain directory.
5
+ # Since there's no "xcodebuild" target to do just that, it is done post-build when exporting an archived build.
6
+ def swift_library_fix
7
+ require 'fileutils'
8
+
9
+ ipa_swift_frameworks = Dir["#{PackageCommandGenerator.appfile_path}/Frameworks/libswift*"]
10
+ Helper.log.info "Checking for Swift framework" if $verbose
11
+
12
+ return if ipa_swift_frameworks.empty?
13
+ Helper.log.info "Packaging up the Swift Framework as the current app is a Swift app" if $verbose
14
+
15
+ Dir.mktmpdir do |tmpdir|
16
+ # Copy all necessary Swift libraries to a temporary "SwiftSupport" directory so that we can
17
+ # easily add it to the .ipa later.
18
+ swift_support = File.join(tmpdir, "SwiftSupport")
19
+
20
+ Dir.mkdir(swift_support)
21
+
22
+ ipa_swift_frameworks.each do |path|
23
+ framework = File.basename(path)
24
+
25
+ FileUtils.copy_file("#{Gym.xcode_path}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/#{framework}", File.join(swift_support, framework))
26
+ end
27
+
28
+ # Add "SwiftSupport" to the .ipa archive
29
+ Dir.chdir(tmpdir) do
30
+ command_parts = ["zip --recurse-paths #{PackageCommandGenerator.ipa_path} SwiftSupport"]
31
+ command_parts << "> /dev/null" unless $verbose
32
+ print_command(command_parts, "Fix Swift embedded code if needed") if $verbose
33
+
34
+ FastlaneCore::CommandExecutor.execute(command: command_parts,
35
+ print_all: false,
36
+ print_command: !Gym.config[:silent],
37
+ error: proc do |output|
38
+ ErrorHandler.handle_package_error(output)
39
+ end)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ module Gym
2
+ class XcodebuildFixes
3
+ class << self
4
+ # Determine whether this app has WatchKit support and manually package up the WatchKit framework
5
+ def watchkit_fix
6
+ return unless watchkit?
7
+
8
+ Helper.log.info "Adding WatchKit support" if $verbose
9
+
10
+ Dir.mktmpdir do |tmpdir|
11
+ # Make watchkit support directory
12
+ watchkit_support = File.join(tmpdir, "WatchKitSupport")
13
+ Dir.mkdir(watchkit_support)
14
+
15
+ # Copy WK from Xcode into WatchKitSupport
16
+ FileUtils.copy_file("#{Gym.xcode_path}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/Library/Application Support/WatchKit/WK", File.join(watchkit_support, "WK"))
17
+
18
+ # Add "WatchKitSupport" to the .ipa archive
19
+ Dir.chdir(tmpdir) do
20
+ abort unless system %(zip --recurse-paths "#{PackageCommandGenerator.ipa_path}" "WatchKitSupport" > /dev/null)
21
+ end
22
+
23
+ Helper.log.info "Successfully added WatchKit support" if $verbose
24
+ end
25
+ end
26
+
27
+ # Does this application have a WatchKit target
28
+ def watchkit?
29
+ Dir["#{PackageCommandGenerator.appfile_path}/**/*.plist"].any? do |plist_path|
30
+ `/usr/libexec/PlistBuddy -c 'Print WKWatchKitApp' '#{plist_path}' 2>&1`.strip == 'true'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gym
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-16 00:00:00.000000000 Z
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fastlane_core
@@ -183,12 +183,14 @@ email:
183
183
  - gym@krausefx.com
184
184
  executables:
185
185
  - gym
186
+ - "\U0001F4AA"
186
187
  extensions: []
187
188
  extra_rdoc_files: []
188
189
  files:
189
190
  - LICENSE
190
191
  - README.md
191
192
  - bin/gym
193
+ - "bin/\U0001F4AA"
192
194
  - lib/assets/GymfileTemplate
193
195
  - lib/assets/package_application_patches/0001_codesign_args_patch.diff
194
196
  - lib/assets/package_application_patches/0002_no_strict_parameter_patch.diff
@@ -204,7 +206,10 @@ files:
204
206
  - lib/gym/project.rb
205
207
  - lib/gym/runner.rb
206
208
  - lib/gym/version.rb
207
- - lib/gym/xcode_fix.rb
209
+ - lib/gym/xcodebuild_fixes/README.md
210
+ - lib/gym/xcodebuild_fixes/package_application_fix.rb
211
+ - lib/gym/xcodebuild_fixes/swift_fix.rb
212
+ - lib/gym/xcodebuild_fixes/watchkit_fix.rb
208
213
  homepage: https://fastlane.tools
209
214
  licenses:
210
215
  - MIT
@@ -225,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
230
  version: '0'
226
231
  requirements: []
227
232
  rubyforge_project:
228
- rubygems_version: 2.4.8
233
+ rubygems_version: 2.4.6
229
234
  signing_key:
230
235
  specification_version: 4
231
236
  summary: Building your iOS apps has never been easier