gym 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -8
- data/lib/assets/package_application_patches/PackageApplication_MD5 +1 -0
- data/lib/assets/package_application_patches/codesign_args_patch.diff +33 -0
- data/lib/assets/package_application_patches/no_strict_parameter_patch.diff +34 -0
- data/lib/gym.rb +2 -0
- data/lib/gym/build_command_generator.rb +1 -1
- data/lib/gym/commands_executor.rb +53 -0
- data/lib/gym/detect_values.rb +0 -6
- data/lib/gym/error_handler.rb +1 -1
- data/lib/gym/manager.rb +2 -1
- data/lib/gym/options.rb +9 -12
- data/lib/gym/package_command_generator.rb +14 -3
- data/lib/gym/project.rb +10 -8
- data/lib/gym/runner.rb +39 -55
- data/lib/gym/version.rb +1 -1
- data/lib/gym/xcode_fix.rb +42 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 397fb653f19ab23011a6adc4e4868b3cf3685a13
|
4
|
+
data.tar.gz: 4f43ac4c7427a7a1ec0189552a1579029c929d50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54112ec43584b099105130a45079e38328d8ee5c3dcf9e279d9228d3da2bce5dc0af2b176246b93172840303e8965667976f1a9272ded70fdd264525159d274
|
7
|
+
data.tar.gz: a69f4ca6ec8f5409fedaedc6b36e6bcc788132e5f8ae9bc809d40f923d2144c18526724ab4a48ca7e5c5b296d623f71e02f4f8bea6aa331f844dbee4fc2c632c
|
data/README.md
CHANGED
@@ -82,14 +82,14 @@ gym
|
|
82
82
|
--------------------------|------------------------------------------------------------
|
83
83
|
:rocket: | `gym` builds 30% faster than other build tools like [shenzhen](https://github.com/nomad/shenzhen)
|
84
84
|
:checkered_flag: | Beautiful inline build output
|
85
|
-
:book: |
|
85
|
+
:book: | Helps you resolve common build errors like code signing issues
|
86
86
|
:mountain_cableway: | Sensible defaults: Automatically detect the project, its schemes and more
|
87
87
|
:link: | Works perfectly with [fastlane](https://fastlane.tools) and other tools
|
88
88
|
:package: | Automatically generates an `ipa` and a compressed `dSYM` file
|
89
89
|
:bullettrain_side: | Don't remember any complicated build commands, just `gym`
|
90
90
|
:wrench: | Easy and dynamic configuration using parameters and environment variables
|
91
91
|
:floppy_disk: | Store common build settings in a `Gymfile`
|
92
|
-
:computer: | All archives are stored and accessible in the Xcode
|
92
|
+
:computer: | All archives are stored and accessible in the Xcode Organizer
|
93
93
|
|
94
94
|
![/assets/gymScreenshot.png](/assets/gymScreenshot.png)
|
95
95
|
|
@@ -156,14 +156,13 @@ archive | xcpretty
|
|
156
156
|
```
|
157
157
|
|
158
158
|
|
159
|
-
After building the archive it is being checked by `gym`. If it's valid, it gets packaged up and signed into an `ipa` file
|
159
|
+
After building the archive it is being checked by `gym`. If it's valid, it gets packaged up and signed into an `ipa` file.
|
160
160
|
|
161
161
|
```
|
162
|
-
|
163
|
-
'/Users/felixkrause/Library/Developer/Xcode/Archives/2015-08-11/ExampleProductName 2015-08-11 18.15.30.xcarchive' \
|
164
|
-
|
165
|
-
|
166
|
-
-exportProvisioningProfile 'Profile Name'
|
162
|
+
/usr/bin/xcrun -sdk iphoneos PackageApplication -v \
|
163
|
+
'/Users/felixkrause/Library/Developer/Xcode/Archives/2015-08-11/ExampleProductName 2015-08-11 18.15.30.xcarchive/Products/Applications/name.app' -o \
|
164
|
+
'/Users/felixkrause/Library/Developer/Xcode/Archives/2015-08-11/ExampleProductName.ipa' \
|
165
|
+
--sign "identity" --embed "provProfile"
|
167
166
|
```
|
168
167
|
|
169
168
|
Afterwards the `ipa` file is moved to the output folder. The `dSYM` file is compressed and moved to the output folder as well.
|
@@ -0,0 +1 @@
|
|
1
|
+
a434316d561ce5c4392a8447b58c18e7
|
@@ -0,0 +1,33 @@
|
|
1
|
+
From 13f2c76fd11b0d861ddf205d4d6ccc0c45a0d4b2 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Fabio Milano
|
3
|
+
Date: Thu, 13 Aug 2015 15:02:41 +0200
|
4
|
+
Subject: [PATCH] Fixed codesign_args
|
5
|
+
|
6
|
+
---
|
7
|
+
PackageApplication4Gym | 8 +++++++-
|
8
|
+
1 file changed, 7 insertions(+), 1 deletion(-)
|
9
|
+
|
10
|
+
diff --git a/PackageApplication4Gym b/PackageApplication4Gym
|
11
|
+
index fc4d7de..b97431f 100755
|
12
|
+
--- a/PackageApplication4Gym
|
13
|
+
+++ b/PackageApplication4Gym
|
14
|
+
@@ -152,9 +152,15 @@ if ( defined $opt{sign} ) {
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
- my @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules",
|
19
|
+
+ my @codesign_args;
|
20
|
+
+ if (-e '$destApp/ResourceRules.plist') { # If ResourceRules.plist exists, include it in codesign arguments, for backwards compatability
|
21
|
+
+ @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements,resource-rules",
|
22
|
+
"--sign", $opt{sign},
|
23
|
+
"--resource-rules=$destApp/ResourceRules.plist");
|
24
|
+
+ } else { # If ResourceRules.plist isn't found, don't include it in the codesign arguments
|
25
|
+
+ @codesign_args = ("/usr/bin/codesign", "--force", "--preserve-metadata=identifier,entitlements",
|
26
|
+
+ "--sign", $opt{sign});
|
27
|
+
+ }
|
28
|
+
|
29
|
+
if ( -e $entitlements_plist ) {
|
30
|
+
push(@codesign_args, '--entitlements');
|
31
|
+
--
|
32
|
+
2.2.1
|
33
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
From 38ea965869a436c4b60e7dbfd5a28d42232d82d6 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Fabio Milano
|
3
|
+
Date: Thu, 13 Aug 2015 16:03:26 +0200
|
4
|
+
Subject: [PATCH] Added no-strict parameter
|
5
|
+
|
6
|
+
---
|
7
|
+
PackageApplication4Gym | 4 ++--
|
8
|
+
1 file changed, 2 insertions(+), 2 deletions(-)
|
9
|
+
|
10
|
+
diff --git a/PackageApplication4Gym b/PackageApplication4Gym
|
11
|
+
index 3085608..54a4b9e 100755
|
12
|
+
--- a/PackageApplication4Gym
|
13
|
+
+++ b/PackageApplication4Gym
|
14
|
+
@@ -92,7 +92,7 @@ foreach $plugin (@plugins) {
|
15
|
+
chomp $pluginName;
|
16
|
+
my $destPlugin = "$destAppDir/$pluginName";
|
17
|
+
|
18
|
+
- my $result = runCmd("/usr/bin/codesign", "--verify", "-vvvv", , $plugin );
|
19
|
+
+ my $result = runCmd("/usr/bin/codesign", "--verify", "--no-strict", "-vvvv", , $plugin );
|
20
|
+
if ( $result !~ /valid on disk/ ) {
|
21
|
+
fatal("Codesign check fails : $result\n");
|
22
|
+
}
|
23
|
+
@@ -111,7 +111,7 @@ if ( $opt{symbols} ) {
|
24
|
+
|
25
|
+
if ( $opt{verbose} ) {
|
26
|
+
print "### Checking original app\n";
|
27
|
+
- my $result = runCmd("/usr/bin/codesign", "--verify", "-vvvv", , $origApp );
|
28
|
+
+ my $result = runCmd("/usr/bin/codesign", "--verify", "--no-strict", "-vvvv", , $origApp );
|
29
|
+
if ( $result !~ /valid on disk/ ) {
|
30
|
+
print "Codesign check fails : $result\n";
|
31
|
+
}
|
32
|
+
--
|
33
|
+
2.2.1
|
34
|
+
|
data/lib/gym.rb
CHANGED
@@ -4,10 +4,12 @@ require 'gym/manager'
|
|
4
4
|
require 'gym/project'
|
5
5
|
require 'gym/build_command_generator'
|
6
6
|
require 'gym/package_command_generator'
|
7
|
+
require 'gym/commands_executor'
|
7
8
|
require 'gym/runner'
|
8
9
|
require 'gym/error_handler'
|
9
10
|
require 'gym/options'
|
10
11
|
require 'gym/detect_values'
|
12
|
+
require 'gym/xcode_fix'
|
11
13
|
|
12
14
|
require 'fastlane_core'
|
13
15
|
require 'terminal-table'
|
@@ -40,7 +40,7 @@ module Gym
|
|
40
40
|
options << "-sdk '#{config[:sdk]}'" if config[:sdk]
|
41
41
|
options << "-destination '#{config[:destination]}'" if config[:destination]
|
42
42
|
options << "-archivePath '#{archive_path}'"
|
43
|
-
options <<
|
43
|
+
options << config[:xcargs] if config[:xcargs]
|
44
44
|
|
45
45
|
options
|
46
46
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Gym
|
2
|
+
# Executes commands and takes care of error handling and more
|
3
|
+
module CommandsExecutor
|
4
|
+
# @param command [String] The command to be executed
|
5
|
+
# @param print_all [Boolean] Do we want to print out the command output while building?
|
6
|
+
# If set to false, nothing will be printed
|
7
|
+
# @param error [Block] A block that's called if an error occurs
|
8
|
+
# @return [String] All the output as string
|
9
|
+
def self.execute(command: nil, print_all: false, error: nil)
|
10
|
+
print_all = true if $verbose
|
11
|
+
|
12
|
+
output = []
|
13
|
+
command = command.join(" ")
|
14
|
+
Helper.log.info command.yellow.strip unless Gym.config[:silent]
|
15
|
+
|
16
|
+
puts "\n-----".cyan if print_all
|
17
|
+
|
18
|
+
last_length = 0
|
19
|
+
begin
|
20
|
+
PTY.spawn(command) do |stdin, stdout, pid|
|
21
|
+
stdin.each do |l|
|
22
|
+
line = l.strip # strip so that \n gets removed
|
23
|
+
output << line
|
24
|
+
|
25
|
+
next unless print_all
|
26
|
+
|
27
|
+
current_length = line.length
|
28
|
+
spaces = [last_length - current_length, 0].max
|
29
|
+
print((line + " " * spaces + "\r").cyan)
|
30
|
+
last_length = current_length
|
31
|
+
end
|
32
|
+
Process.wait(pid)
|
33
|
+
puts "-----\n".cyan if print_all
|
34
|
+
end
|
35
|
+
rescue => ex
|
36
|
+
# This could happen when the environment is wrong:
|
37
|
+
# > invalid byte sequence in US-ASCII (ArgumentError)
|
38
|
+
output << ex.to_s
|
39
|
+
o = output.join("\n")
|
40
|
+
puts o
|
41
|
+
error.call(o)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Exit status for build command, should be 0 if build succeeded
|
45
|
+
# Disabled Rubocop, since $CHILD_STATUS just is not the same
|
46
|
+
if $?.exitstatus != 0 # rubocop:disable Style/SpecialGlobalVars
|
47
|
+
o = output.join("\n")
|
48
|
+
puts o # the user has the right to see the raw output
|
49
|
+
error.call(o)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/gym/detect_values.rb
CHANGED
@@ -50,12 +50,6 @@ module Gym
|
|
50
50
|
|
51
51
|
if Gym.config[:provisioning_profile_path]
|
52
52
|
FastlaneCore::ProvisioningProfile.install(Gym.config[:provisioning_profile_path])
|
53
|
-
data = FastlaneCore::ProvisioningProfile.parse(Gym.config[:provisioning_profile_path])
|
54
|
-
|
55
|
-
if data['Name']
|
56
|
-
Helper.log.info "Using provisioning profile with name '#{data['Name']}'...".green if $verbose
|
57
|
-
Gym.config[:provisioning_profile_name] = data['Name']
|
58
|
-
end
|
59
53
|
end
|
60
54
|
end
|
61
55
|
|
data/lib/gym/error_handler.rb
CHANGED
@@ -63,7 +63,7 @@ module Gym
|
|
63
63
|
print "Make sure the name of the provisioning profile is correct"
|
64
64
|
print "and it matches a locally installed profile"
|
65
65
|
print "You can pass the name of the provisioning profile using the"
|
66
|
-
print "`--
|
66
|
+
print "`--provisioning_profile_path` option"
|
67
67
|
when /mismatch between specified provisioning profile and signing identity/
|
68
68
|
print "Mismatch between provisioning profile and code signing identity"
|
69
69
|
print "This means, the specified provisioning profile was not created using"
|
data/lib/gym/manager.rb
CHANGED
@@ -16,10 +16,11 @@ module Gym
|
|
16
16
|
rows << ["Project", config[:project]] if config[:project]
|
17
17
|
rows << ["Workspace", config[:workspace]] if config[:workspace]
|
18
18
|
rows << ["Scheme", config[:scheme]] if config[:scheme]
|
19
|
+
rows << ["Configuration", config[:configuration]] if config[:configuration]
|
19
20
|
|
20
21
|
puts ""
|
21
22
|
puts Terminal::Table.new(
|
22
|
-
title: "Building Application".green,
|
23
|
+
title: "Building Application 🚀".green,
|
23
24
|
rows: rows
|
24
25
|
)
|
25
26
|
puts ""
|
data/lib/gym/options.rb
CHANGED
@@ -18,9 +18,10 @@ module Gym
|
|
18
18
|
optional: true,
|
19
19
|
description: "Path the workspace file",
|
20
20
|
verify_block: proc do |value|
|
21
|
-
|
22
|
-
raise "Workspace file
|
23
|
-
raise "Workspace file
|
21
|
+
v = File.expand_path(value.to_s)
|
22
|
+
raise "Workspace file not found at path '#{v}'".red unless File.exist?(v)
|
23
|
+
raise "Workspace file invalid".red unless File.directory?(v)
|
24
|
+
raise "Workspace file is not a workspace, must end with .xcworkspace".red unless v.include?(".xcworkspace")
|
24
25
|
end),
|
25
26
|
FastlaneCore::ConfigItem.new(key: :project,
|
26
27
|
short_option: "-p",
|
@@ -28,9 +29,10 @@ module Gym
|
|
28
29
|
env_name: "GYM_PROJECT",
|
29
30
|
description: "Path the project file",
|
30
31
|
verify_block: proc do |value|
|
31
|
-
|
32
|
-
raise "Project file
|
33
|
-
raise "Project file
|
32
|
+
v = File.expand_path(value.to_s)
|
33
|
+
raise "Project file not found at path '#{v}'".red unless File.exist?(v)
|
34
|
+
raise "Project file invalid".red unless File.directory?(v)
|
35
|
+
raise "Project file is not a project file, must end with .xcodeproj".red unless v.include?(".xcodeproj")
|
34
36
|
end),
|
35
37
|
FastlaneCore::ConfigItem.new(key: :provisioning_profile_path,
|
36
38
|
short_option: "-e",
|
@@ -83,11 +85,6 @@ module Gym
|
|
83
85
|
description: "Hide all information that's not necessary while building",
|
84
86
|
default_value: false,
|
85
87
|
is_string: false),
|
86
|
-
FastlaneCore::ConfigItem.new(key: :provisioning_profile_name,
|
87
|
-
short_option: "-l",
|
88
|
-
env_name: "GYM_PROVISIONING_PROFILE_NAME",
|
89
|
-
description: "The name of the provisioning profile to use. It has to match the name exactly",
|
90
|
-
optional: true),
|
91
88
|
FastlaneCore::ConfigItem.new(key: :codesigning_identity,
|
92
89
|
short_option: "-i",
|
93
90
|
env_name: "GYM_CODE_SIGNING_IDENTITY",
|
@@ -101,7 +98,7 @@ module Gym
|
|
101
98
|
FastlaneCore::ConfigItem.new(key: :xcargs,
|
102
99
|
short_option: "-x",
|
103
100
|
env_name: "GYM_XCARGS",
|
104
|
-
description: "Pass additional arguments to xcodebuild when building the app. Be sure to quote
|
101
|
+
description: "Pass additional arguments to xcodebuild when building the app. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS=\"-ObjC -lstdc++\"",
|
105
102
|
optional: true)
|
106
103
|
|
107
104
|
]
|
@@ -1,11 +1,17 @@
|
|
1
1
|
module Gym
|
2
2
|
# Responsible for building the fully working xcodebuild command
|
3
|
+
#
|
4
|
+
# Because of a known bug in PackageApplication Perl script used by Xcode the packaging process is performed with
|
5
|
+
# a patched version of the script.
|
3
6
|
class PackageCommandGenerator
|
4
7
|
class << self
|
5
8
|
def generate
|
6
|
-
|
9
|
+
@patched_package_application = XcodeFix.patch_package_application
|
10
|
+
|
11
|
+
parts = ["/usr/bin/xcrun #{@patched_package_application} -v"]
|
7
12
|
parts += options
|
8
13
|
parts += pipe
|
14
|
+
parts += postfix
|
9
15
|
|
10
16
|
parts
|
11
17
|
end
|
@@ -17,8 +23,8 @@ module Gym
|
|
17
23
|
options << "-o '#{ipa_path}'"
|
18
24
|
options << "exportFormat ipa"
|
19
25
|
|
20
|
-
if Gym.config[:
|
21
|
-
options << "--embed '#{Gym.config[:
|
26
|
+
if Gym.config[:provisioning_profile_path]
|
27
|
+
options << "--embed '#{Gym.config[:provisioning_profile_path]}'"
|
22
28
|
end
|
23
29
|
|
24
30
|
if Gym.config[:codesigning_identity]
|
@@ -32,6 +38,11 @@ module Gym
|
|
32
38
|
[""]
|
33
39
|
end
|
34
40
|
|
41
|
+
def postfix
|
42
|
+
# Remove the patched PackageApplication file after the export is finished
|
43
|
+
["&& rm '#{@patched_package_application}'"]
|
44
|
+
end
|
45
|
+
|
35
46
|
def appfile_path
|
36
47
|
Dir.glob("#{BuildCommandGenerator.archive_path}/Products/Applications/*.app").first
|
37
48
|
end
|
data/lib/gym/project.rb
CHANGED
@@ -78,16 +78,18 @@ module Gym
|
|
78
78
|
|
79
79
|
return @raw if @raw
|
80
80
|
|
81
|
-
#
|
82
|
-
#
|
83
|
-
|
84
|
-
|
81
|
+
# Unfortunately since we pass the workspace we also get all the
|
82
|
+
# schemes generated by CocoaPods
|
83
|
+
|
84
|
+
options = BuildCommandGenerator.project_path_array.delete_if { |a| a.to_s.include? "scheme" }
|
85
|
+
command = "xcrun xcodebuild -list #{options.join(' ')}"
|
85
86
|
Helper.log.info command.yellow unless Gym.config[:silent]
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
@raw = `#{command}`.to_s
|
89
|
+
|
90
|
+
raise "Error parsing xcode file using `#{command}`".red if @raw.length == 0
|
91
|
+
|
92
|
+
return @raw
|
91
93
|
end
|
92
94
|
end
|
93
95
|
end
|
data/lib/gym/runner.rb
CHANGED
@@ -9,6 +9,7 @@ module Gym
|
|
9
9
|
build_app
|
10
10
|
verify_archive
|
11
11
|
package_app
|
12
|
+
swift_library_fix
|
12
13
|
move_results
|
13
14
|
end
|
14
15
|
|
@@ -55,7 +56,7 @@ module Gym
|
|
55
56
|
def build_app
|
56
57
|
command = BuildCommandGenerator.generate
|
57
58
|
print_command(command, "Generated Build Command") if $verbose
|
58
|
-
|
59
|
+
Gym::CommandsExecutor.execute(command: command, print_all: true, error: proc do |output|
|
59
60
|
ErrorHandler.handle_build_error(output)
|
60
61
|
end)
|
61
62
|
|
@@ -74,11 +75,47 @@ module Gym
|
|
74
75
|
command = PackageCommandGenerator.generate
|
75
76
|
print_command(command, "Generated Package Command") if $verbose
|
76
77
|
|
77
|
-
|
78
|
+
Gym::CommandsExecutor.execute(command: command, print_all: false, error: proc do |output|
|
78
79
|
ErrorHandler.handle_package_error(output)
|
79
80
|
end)
|
80
81
|
end
|
81
82
|
|
83
|
+
# Determine whether it is a Swift project and, eventually, include all required libraries to copy from Xcode's toolchain directory.
|
84
|
+
# Since there's no "xcodebuild" target to do just that, it is done post-build when exporting an archived build.
|
85
|
+
def swift_library_fix
|
86
|
+
require 'fileutils'
|
87
|
+
|
88
|
+
ipa_swift_frameworks = Dir["#{PackageCommandGenerator.appfile_path}/Frameworks/libswift*"]
|
89
|
+
|
90
|
+
unless ipa_swift_frameworks.empty?
|
91
|
+
Dir.mktmpdir do |tmpdir|
|
92
|
+
# Copy all necessary Swift libraries to a temporary "SwiftSupport" directory so that we can
|
93
|
+
# easily add it to the .ipa later.
|
94
|
+
swift_support = File.join(tmpdir, "SwiftSupport")
|
95
|
+
|
96
|
+
Dir.mkdir(swift_support)
|
97
|
+
|
98
|
+
developer_dir = `xcode-select --print-path`.strip
|
99
|
+
ipa_swift_frameworks.each do |path|
|
100
|
+
framework = File.basename(path)
|
101
|
+
|
102
|
+
FileUtils.copy_file("#{developer_dir}/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos/#{framework}", File.join(swift_support, framework))
|
103
|
+
end
|
104
|
+
|
105
|
+
# Add "SwiftSupport" to the .ipa archive
|
106
|
+
Dir.chdir(tmpdir) do
|
107
|
+
command_parts = ["zip --recurse-paths #{PackageCommandGenerator.ipa_path} SwiftSupport"]
|
108
|
+
command_parts << "> /dev/null" unless $verbose
|
109
|
+
print_command(command_parts, "Fix Swift embedded code if needed") if $verbose
|
110
|
+
|
111
|
+
Gym::CommandsExecutor.execute(command: command_parts, print_all: false, error: proc do |output|
|
112
|
+
ErrorHandler.handle_package_error(output)
|
113
|
+
end)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
82
119
|
# Moves over the binary and dsym file to the output directory
|
83
120
|
# @return (String) The path to the resulting ipa file
|
84
121
|
def move_results
|
@@ -109,58 +146,5 @@ module Gym
|
|
109
146
|
Helper.log.info ipa_path
|
110
147
|
ipa_path
|
111
148
|
end
|
112
|
-
|
113
|
-
#####################################################
|
114
|
-
# @!group Actually executing the commands
|
115
|
-
#####################################################
|
116
|
-
|
117
|
-
# @param command [String] The command to be executed
|
118
|
-
# @param print_all [Boolean] Do we want to print out the command output while building?
|
119
|
-
# If set to false, nothing will be printed
|
120
|
-
# @param error [Block] A block that's called if an error occurs
|
121
|
-
# @return [String] All the output as string
|
122
|
-
def execute_command(command: nil, print_all: false, error: nil)
|
123
|
-
print_all = true if $verbose
|
124
|
-
|
125
|
-
output = []
|
126
|
-
command = command.join(" ")
|
127
|
-
Helper.log.info command.yellow.strip unless Gym.config[:silent]
|
128
|
-
|
129
|
-
puts "\n-----".cyan if print_all
|
130
|
-
|
131
|
-
last_length = 0
|
132
|
-
begin
|
133
|
-
PTY.spawn(command) do |stdin, stdout, pid|
|
134
|
-
stdin.each do |l|
|
135
|
-
line = l.strip # strip so that \n gets removed
|
136
|
-
output << line
|
137
|
-
|
138
|
-
next unless print_all
|
139
|
-
|
140
|
-
current_length = line.length
|
141
|
-
spaces = [last_length - current_length, 0].max
|
142
|
-
print((line + " " * spaces + "\r").cyan)
|
143
|
-
last_length = current_length
|
144
|
-
end
|
145
|
-
Process.wait(pid)
|
146
|
-
puts "-----\n".cyan if print_all
|
147
|
-
end
|
148
|
-
rescue => ex
|
149
|
-
# This could happen when the environment is wrong:
|
150
|
-
# > invalid byte sequence in US-ASCII (ArgumentError)
|
151
|
-
output << ex.to_s
|
152
|
-
o = output.join("\n")
|
153
|
-
puts o
|
154
|
-
error.call(o)
|
155
|
-
end
|
156
|
-
|
157
|
-
# Exit status for build command, should be 0 if build succeeded
|
158
|
-
# Disabled Rubocop, since $CHILD_STATUS just is not the same
|
159
|
-
if $?.exitstatus != 0 # rubocop:disable Style/SpecialGlobalVars
|
160
|
-
o = output.join("\n")
|
161
|
-
puts o # the user has the right to see the raw output
|
162
|
-
error.call(o)
|
163
|
-
end
|
164
|
-
end
|
165
149
|
end
|
166
150
|
end
|
data/lib/gym/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Gym
|
2
|
+
class XcodeFix
|
3
|
+
class << self
|
4
|
+
# Fix PackageApplication Perl script by Xcode to create the IPA from the archive
|
5
|
+
def patch_package_application
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
# Initialization
|
9
|
+
developer_dir = `xcode-select --print-path`.strip
|
10
|
+
patched_package_application_path = File.join("/tmp", "PackageApplication4Gym")
|
11
|
+
# Remove any previous patched PackageApplication
|
12
|
+
FileUtils.rm patched_package_application_path if File.exist?(patched_package_application_path)
|
13
|
+
|
14
|
+
Dir.mktmpdir do |tmpdir|
|
15
|
+
# Check current PackageApplication MD5
|
16
|
+
require 'digest'
|
17
|
+
|
18
|
+
path = File.join(Helper.gem_path("gym"), "lib/assets/package_application_patches/PackageApplication_MD5")
|
19
|
+
expected_md5 = File.read(path)
|
20
|
+
|
21
|
+
raise "Found an invalid `PackageApplication` script. This is not supported." unless expected_md5 == Digest::MD5.file("#{developer_dir}/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication").hexdigest
|
22
|
+
|
23
|
+
# Duplicate PackageApplication script to PackageApplication4Gym
|
24
|
+
FileUtils.copy_file("#{developer_dir}/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication", patched_package_application_path)
|
25
|
+
|
26
|
+
# Apply patches to PackageApplication4Gym from patches folder
|
27
|
+
Dir[File.join(Helper.gem_path("gym"), "lib/assets/package_application_patches/*.diff")].each do |patch|
|
28
|
+
Helper.log.info "Applying Package Application patch: #{File.basename(patch)}" unless Gym.config[:silent]
|
29
|
+
command = ["patch #{patched_package_application_path} < #{patch}"]
|
30
|
+
print_command(command, "Applying Package Application patch: #{File.basename(patch)}") if $verbose
|
31
|
+
|
32
|
+
Gym::CommandsExecutor.execute(command: command, print_all: false, error: proc do |output|
|
33
|
+
ErrorHandler.handle_build_error(output)
|
34
|
+
end)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
return patched_package_application_path # Return path to the patched PackageApplication
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -190,8 +190,12 @@ files:
|
|
190
190
|
- README.md
|
191
191
|
- bin/gym
|
192
192
|
- lib/assets/GymfileTemplate
|
193
|
+
- lib/assets/package_application_patches/PackageApplication_MD5
|
194
|
+
- lib/assets/package_application_patches/codesign_args_patch.diff
|
195
|
+
- lib/assets/package_application_patches/no_strict_parameter_patch.diff
|
193
196
|
- lib/gym.rb
|
194
197
|
- lib/gym/build_command_generator.rb
|
198
|
+
- lib/gym/commands_executor.rb
|
195
199
|
- lib/gym/commands_generator.rb
|
196
200
|
- lib/gym/detect_values.rb
|
197
201
|
- lib/gym/error_handler.rb
|
@@ -201,6 +205,7 @@ files:
|
|
201
205
|
- lib/gym/project.rb
|
202
206
|
- lib/gym/runner.rb
|
203
207
|
- lib/gym/version.rb
|
208
|
+
- lib/gym/xcode_fix.rb
|
204
209
|
homepage: https://fastlane.tools
|
205
210
|
licenses:
|
206
211
|
- MIT
|