fastlane-plugin-versioning 0.3.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +142 -8
- data/lib/fastlane/plugin/versioning/actions/ci_build_number.rb +11 -3
- data/lib/fastlane/plugin/versioning/actions/get_app_store_version_number.rb +6 -6
- data/lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb +19 -7
- data/lib/fastlane/plugin/versioning/actions/get_build_number_from_xcodeproj.rb +127 -0
- data/lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb +45 -49
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb +1 -1
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb +20 -8
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_xcodeproj.rb +111 -0
- data/lib/fastlane/plugin/versioning/actions/increment_build_number_in_plist.rb +36 -10
- data/lib/fastlane/plugin/versioning/actions/increment_build_number_in_xcodeproj.rb +126 -0
- data/lib/fastlane/plugin/versioning/actions/increment_version_number_in_plist.rb +39 -14
- data/lib/fastlane/plugin/versioning/actions/increment_version_number_in_xcodeproj.rb +178 -0
- data/lib/fastlane/plugin/versioning/version.rb +1 -1
- metadata +11 -5
@@ -7,17 +7,16 @@ module Fastlane
|
|
7
7
|
def self.run(params)
|
8
8
|
unless params[:xcodeproj]
|
9
9
|
if Helper.test?
|
10
|
-
params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/bundle.xcodeproj"
|
10
|
+
params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/xcodeproj/bundle.xcodeproj"
|
11
11
|
else
|
12
12
|
params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
path = find_path_using_target(params)
|
16
|
+
if params[:target]
|
17
|
+
path = find_path_using_target(params)
|
19
18
|
else
|
20
|
-
|
19
|
+
path = find_path_using_scheme(params)
|
21
20
|
end
|
22
21
|
path
|
23
22
|
end
|
@@ -25,44 +24,44 @@ module Fastlane
|
|
25
24
|
def self.find_path_using_target(params)
|
26
25
|
project = Xcodeproj::Project.open(params[:xcodeproj])
|
27
26
|
if params[:target]
|
28
|
-
target = project.targets.detect { |t| t.name == params[:target]}
|
27
|
+
target = project.targets.detect { |t| t.name == params[:target] }
|
29
28
|
else
|
30
29
|
# firstly we are trying to find modern application target
|
31
30
|
target = project.targets.detect do |t|
|
32
31
|
t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
|
33
|
-
|
32
|
+
t.product_type == 'com.apple.product-type.application'
|
34
33
|
end
|
35
34
|
target = project.targets[0] if target.nil?
|
36
35
|
end
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
37
|
+
# This ensures we get correctly resolved variables against present configuration files.
|
38
|
+
plist = target.resolved_build_setting('INFOPLIST_FILE', true)
|
39
|
+
UI.user_error! 'Cannot resolve Info.plist build setting. Check it\'s defined or try defining it explicitly on the target without variables.' if plist.nil? || plist.empty?
|
40
|
+
|
41
|
+
if !(build_configuration_name = params[:build_configuration_name]).nil?
|
42
|
+
plist = plist[build_configuration_name]
|
43
|
+
UI.user_error! "Cannot resolve Info.plist build setting for #{build_configuration_name}." if plist.nil?
|
41
44
|
else
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
UI.user_error! 'Cannot resolve Info.plist build setting. Maybe you should specify :build_configuration_name?'
|
46
|
-
end
|
45
|
+
plist = plist.values.compact.uniq
|
46
|
+
UI.user_error! 'Cannot accurately resolve Info.plist build setting, try specifying :build_configuration_name.' if plist.count > 1
|
47
|
+
plist = plist.first
|
47
48
|
end
|
48
49
|
|
49
|
-
path = plist.gsub('
|
50
|
-
unless (Pathname.new path).absolute?
|
51
|
-
path = File.join(project.path.parent.to_path, path)
|
52
|
-
end
|
50
|
+
path = plist.gsub('SRCROOT', project.path.parent.to_path)
|
51
|
+
path = File.join(project.path.parent.to_path, path) unless (Pathname.new path).absolute?
|
53
52
|
path
|
54
53
|
end
|
55
54
|
|
56
55
|
def self.find_path_using_scheme(params)
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
config = { project: params[:xcodeproj], scheme: params[:scheme], configuration: params[:build_configuration_name] }
|
57
|
+
project = FastlaneCore::Project.new(config)
|
58
|
+
project.select_scheme
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
path = project.build_settings(key: 'INFOPLIST_FILE')
|
61
|
+
unless (Pathname.new path).absolute?
|
62
|
+
path = File.join(Pathname.new(project.path).parent.to_path, path)
|
63
|
+
end
|
64
|
+
path
|
66
65
|
end
|
67
66
|
|
68
67
|
#####################################################
|
@@ -74,35 +73,32 @@ module Fastlane
|
|
74
73
|
end
|
75
74
|
|
76
75
|
def self.details
|
77
|
-
|
78
|
-
"This action will return path to Info.plist for specific target in your project."
|
79
|
-
].join(' ')
|
76
|
+
'This action will return path to Info.plist for specific target in your project.'
|
80
77
|
end
|
81
78
|
|
82
79
|
def self.available_options
|
83
80
|
[
|
84
81
|
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
env_name: "FL_INFO_PLIST_PROJECT",
|
83
|
+
description: "Optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
|
84
|
+
optional: true,
|
85
|
+
verify_block: proc do |value|
|
86
|
+
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
|
87
|
+
UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
|
88
|
+
end),
|
92
89
|
FastlaneCore::ConfigItem.new(key: :target,
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
env_name: "FL_INFO_PLIST_TARGET",
|
91
|
+
optional: true,
|
92
|
+
conflicting_options: [:scheme],
|
93
|
+
description: "Specify a specific target if you have multiple per project, optional"),
|
97
94
|
FastlaneCore::ConfigItem.new(key: :scheme,
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
95
|
+
env_name: "FL_INFO_PLIST_SCHEME",
|
96
|
+
optional: true,
|
97
|
+
conflicting_options: [:target],
|
98
|
+
description: "Specify a specific scheme if you have multiple per project, optional"),
|
102
99
|
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
103
|
-
|
104
|
-
|
105
|
-
|
100
|
+
optional: true,
|
101
|
+
description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
|
106
102
|
]
|
107
103
|
end
|
108
104
|
|
@@ -111,7 +107,7 @@ module Fastlane
|
|
111
107
|
end
|
112
108
|
|
113
109
|
def self.is_supported?(platform)
|
114
|
-
[
|
110
|
+
%i[ios mac].include? platform
|
115
111
|
end
|
116
112
|
end
|
117
113
|
end
|
@@ -1,16 +1,24 @@
|
|
1
|
-
module Fastlane
|
1
|
+
module Fastlane
|
2
2
|
module Actions
|
3
3
|
class GetVersionNumberFromPlistAction < Action
|
4
4
|
def self.run(params)
|
5
5
|
if Helper.test?
|
6
|
-
plist = "/tmp/fastlane/tests/fastlane/Info.plist"
|
6
|
+
plist = "/tmp/fastlane/tests/fastlane/plist/Info.plist"
|
7
7
|
else
|
8
8
|
plist = GetInfoPlistPathAction.run(params)
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
if params[:plist_build_setting_support]
|
12
|
+
UI.important "version will originate from xcodeproj"
|
13
|
+
version_number = GetVersionNumberFromXcodeprojAction.run(params)
|
14
|
+
else
|
15
|
+
UI.important "version will originate from plist."
|
16
|
+
version_number = GetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString')
|
17
|
+
end
|
18
|
+
|
12
19
|
# Store the number in the shared hash
|
13
20
|
Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
|
21
|
+
version_number
|
14
22
|
end
|
15
23
|
|
16
24
|
#####################################################
|
@@ -23,7 +31,8 @@ module Fastlane
|
|
23
31
|
|
24
32
|
def self.details
|
25
33
|
[
|
26
|
-
"This action will return the current version number set on your project's Info.plist."
|
34
|
+
"This action will return the current version number set on your project's Info.plist.",
|
35
|
+
"note that you can pass plist_build_setting_support: true, in which case it will return from your xcodeproj."
|
27
36
|
].join(' ')
|
28
37
|
end
|
29
38
|
|
@@ -49,8 +58,11 @@ module Fastlane
|
|
49
58
|
description: "Specify a specific scheme if you have multiple per project, optional"),
|
50
59
|
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
51
60
|
optional: true,
|
52
|
-
description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
|
53
|
-
|
61
|
+
description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration"),
|
62
|
+
FastlaneCore::ConfigItem.new(key: :plist_build_setting_support,
|
63
|
+
description: "support automatic resolution of build setting from xcodeproj if not a literal value in the plist",
|
64
|
+
is_string: false,
|
65
|
+
default_value: false)
|
54
66
|
]
|
55
67
|
end
|
56
68
|
|
@@ -61,11 +73,11 @@ module Fastlane
|
|
61
73
|
end
|
62
74
|
|
63
75
|
def self.authors
|
64
|
-
["SiarheiFedartsou"]
|
76
|
+
["SiarheiFedartsou", "jdouglas-nz"]
|
65
77
|
end
|
66
78
|
|
67
79
|
def self.is_supported?(platform)
|
68
|
-
[
|
80
|
+
%i[ios mac].include? platform
|
69
81
|
end
|
70
82
|
end
|
71
83
|
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class GetVersionNumberFromXcodeprojAction < Action
|
4
|
+
require 'xcodeproj'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
def self.run(params)
|
8
|
+
unless params[:xcodeproj]
|
9
|
+
if Helper.test?
|
10
|
+
params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/xcodeproj/versioning_fixture_project.xcodeproj"
|
11
|
+
else
|
12
|
+
params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
if params[:target]
|
17
|
+
version_number = get_version_number_using_target(params)
|
18
|
+
else
|
19
|
+
version_number = get_version_number_using_scheme(params)
|
20
|
+
end
|
21
|
+
|
22
|
+
Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
|
23
|
+
version_number
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.get_version_number_using_target(params)
|
27
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
28
|
+
if params[:target]
|
29
|
+
target = project.targets.detect { |t| t.name == params[:target] }
|
30
|
+
else
|
31
|
+
# firstly we are trying to find modern application target
|
32
|
+
target = project.targets.detect do |t|
|
33
|
+
t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
|
34
|
+
t.product_type == 'com.apple.product-type.application'
|
35
|
+
end
|
36
|
+
target = project.targets[0] if target.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
version_number = target.resolved_build_setting('MARKETING_VERSION', true)
|
40
|
+
UI.user_error! 'Cannot resolve version number build setting.' if version_number.nil? || version_number.empty?
|
41
|
+
|
42
|
+
if !(build_configuration_name = params[:build_configuration_name]).nil?
|
43
|
+
version_number = version_number[build_configuration_name]
|
44
|
+
UI.user_error! "Cannot resolve $(MARKETING_VERSION) build setting for #{build_configuration_name}." if version_number.nil?
|
45
|
+
else
|
46
|
+
version_number = version_number.values.compact.uniq
|
47
|
+
UI.user_error! 'Cannot accurately resolve $(MARKETING_VERSION) build setting, try specifying :build_configuration_name.' if version_number.count > 1
|
48
|
+
version_number = version_number.first
|
49
|
+
end
|
50
|
+
|
51
|
+
version_number
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.get_version_number_using_scheme(params)
|
55
|
+
config = { project: params[:xcodeproj], scheme: params[:scheme], configuration: params[:build_configuration_name] }
|
56
|
+
project = FastlaneCore::Project.new(config)
|
57
|
+
project.select_scheme
|
58
|
+
|
59
|
+
build_number = project.build_settings(key: 'MARKETING_VERSION')
|
60
|
+
UI.user_error! "Cannot resolve $(MARKETING_VERSION) in for the scheme #{config.scheme} with the name #{params.configuration}" if build_number.nil? || build_number.empty?
|
61
|
+
build_number
|
62
|
+
end
|
63
|
+
|
64
|
+
#####################################################
|
65
|
+
# @!group Documentation
|
66
|
+
#####################################################
|
67
|
+
|
68
|
+
def self.description
|
69
|
+
"Get the version number of your project"
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.details
|
73
|
+
'Gets the $(MARKETING_VERSION) build setting using the specified parameters, or the first if not enough parameters are passed.'
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.available_options
|
77
|
+
[
|
78
|
+
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
79
|
+
env_name: "FL_VERSION_NUMBER_PROJECT",
|
80
|
+
description: "Optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
|
81
|
+
optional: true,
|
82
|
+
verify_block: proc do |value|
|
83
|
+
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
|
84
|
+
UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
|
85
|
+
end),
|
86
|
+
FastlaneCore::ConfigItem.new(key: :target,
|
87
|
+
env_name: "FL_VERSION_NUMBER_TARGET",
|
88
|
+
optional: true,
|
89
|
+
conflicting_options: [:scheme],
|
90
|
+
description: "Specify a specific target if you have multiple per project, optional"),
|
91
|
+
FastlaneCore::ConfigItem.new(key: :scheme,
|
92
|
+
env_name: "FL_VERSION_NUMBER_SCHEME",
|
93
|
+
optional: true,
|
94
|
+
conflicting_options: [:target],
|
95
|
+
description: "Specify a specific scheme if you have multiple per project, optional"),
|
96
|
+
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
97
|
+
optional: true,
|
98
|
+
description: "Specify a specific build configuration if you have different build settings for each configuration")
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.authors
|
103
|
+
["jdouglas-nz"]
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.is_supported?(platform)
|
107
|
+
%i[ios mac].include? platform
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -7,19 +7,40 @@ module Fastlane
|
|
7
7
|
else
|
8
8
|
current_build_number = GetBuildNumberFromPlistAction.run(params)
|
9
9
|
build_array = current_build_number.split(".").map(&:to_i)
|
10
|
-
build_array[-1] = build_array[-1]+1
|
10
|
+
build_array[-1] = build_array[-1] + 1
|
11
11
|
next_build_number = build_array.join(".")
|
12
12
|
end
|
13
13
|
|
14
14
|
if Helper.test?
|
15
|
-
plist = "/tmp/fastlane/tests/fastlane/Info.plist"
|
15
|
+
plist = "/tmp/fastlane/tests/fastlane/plist/Info.plist"
|
16
16
|
else
|
17
17
|
plist = GetInfoPlistPathAction.run(params)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
build_number = GetInfoPlistValueAction.run(path: plist, key: 'CFBundleVersion')
|
21
|
+
if build_number =~ /\$\(([\w\-]+)\)/
|
22
|
+
UI.important "detected that build number is a build setting."
|
23
|
+
if params[:plist_build_setting_support]
|
24
|
+
UI.important "will continue and update the xcodeproj $(CURRENT_PROJECT_VERSION) instead."
|
25
|
+
IncrementBuildNumberInXcodeprojAction.run(params)
|
26
|
+
else
|
27
|
+
UI.important "will continue and update the info plist key. this will replace the existing value."
|
28
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleVersion', value: next_build_number)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
if params[:plist_build_setting_support]
|
32
|
+
UI.important "will continue and update the xcodeproj $(CURRENT_PROJECT_VERSION) instead."
|
33
|
+
IncrementBuildNumberInXcodeprojAction.run(params)
|
34
|
+
UI.important "will also update info plist key to be a build setting"
|
35
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleVersion', value: "$(CURRENT_PROJECT_VERSION)")
|
36
|
+
else
|
37
|
+
UI.important "will continue and update the info plist key. this will replace the existing value."
|
38
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleVersion', value: next_build_number)
|
39
|
+
end
|
40
|
+
end
|
21
41
|
|
22
42
|
Actions.lane_context[SharedValues::BUILD_NUMBER] = next_build_number
|
43
|
+
next_build_number
|
23
44
|
end
|
24
45
|
|
25
46
|
def self.description
|
@@ -28,7 +49,8 @@ module Fastlane
|
|
28
49
|
|
29
50
|
def self.details
|
30
51
|
[
|
31
|
-
"This action will increment the build number directly in Info.plist
|
52
|
+
"This action will increment the build number directly in Info.plist",
|
53
|
+
"unless plist_build_setting_support: true is passed in as parameters"
|
32
54
|
].join("\n")
|
33
55
|
end
|
34
56
|
|
@@ -36,7 +58,7 @@ module Fastlane
|
|
36
58
|
[
|
37
59
|
FastlaneCore::ConfigItem.new(key: :build_number,
|
38
60
|
env_name: "FL_BUILD_NUMBER_BUILD_NUMBER",
|
39
|
-
description: "Change to a specific
|
61
|
+
description: "Change to a specific build number",
|
40
62
|
optional: true),
|
41
63
|
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
42
64
|
env_name: "FL_VERSION_NUMBER_PROJECT",
|
@@ -58,22 +80,26 @@ module Fastlane
|
|
58
80
|
description: "Specify a specific scheme if you have multiple per project, optional"),
|
59
81
|
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
60
82
|
optional: true,
|
61
|
-
description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
|
83
|
+
description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration"),
|
84
|
+
FastlaneCore::ConfigItem.new(key: :plist_build_setting_support,
|
85
|
+
description: "support automatic resolution of build setting from xcodeproj if not a literal value in the plist",
|
86
|
+
is_string: false,
|
87
|
+
default_value: false)
|
62
88
|
]
|
63
89
|
end
|
64
90
|
|
65
91
|
def self.output
|
66
92
|
[
|
67
|
-
['BUILD_NUMBER', 'The new
|
93
|
+
['BUILD_NUMBER', 'The new build number']
|
68
94
|
]
|
69
95
|
end
|
70
96
|
|
71
|
-
def self.
|
72
|
-
"SiarheiFedartsou"
|
97
|
+
def self.authors
|
98
|
+
["SiarheiFedartsou", "jdouglas-nz"]
|
73
99
|
end
|
74
100
|
|
75
101
|
def self.is_supported?(platform)
|
76
|
-
[
|
102
|
+
%i[ios mac].include? platform
|
77
103
|
end
|
78
104
|
end
|
79
105
|
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class IncrementBuildNumberInXcodeprojAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
unless params[:xcodeproj]
|
6
|
+
if Helper.test?
|
7
|
+
params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/xcodeproj/versioning_fixture_project.xcodeproj"
|
8
|
+
else
|
9
|
+
params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
if params[:build_number]
|
14
|
+
next_build_number = params[:build_number]
|
15
|
+
else
|
16
|
+
current_build_number = GetBuildNumberFromXcodeprojAction.run(params)
|
17
|
+
build_array = current_build_number.split(".").map(&:to_i)
|
18
|
+
build_array[-1] = build_array[-1] + 1
|
19
|
+
next_build_number = build_array.join(".")
|
20
|
+
end
|
21
|
+
|
22
|
+
if params[:target]
|
23
|
+
set_build_number_using_target(params, next_build_number)
|
24
|
+
elsif params[:build_configuration_name] && params[:scheme]
|
25
|
+
set_build_number_using_scheme(params, next_build_number)
|
26
|
+
else
|
27
|
+
set_all_xcodeproj_build_numbers(params, next_build_number)
|
28
|
+
end
|
29
|
+
Actions.lane_context[SharedValues::BUILD_NUMBER] = next_build_number
|
30
|
+
next_build_number
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.set_all_xcodeproj_build_numbers(params, next_build_number)
|
34
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
35
|
+
configs = project.objects.select { |obj| select_build_configuration_predicate(nil, obj) }
|
36
|
+
configs.each do |config|
|
37
|
+
config.build_settings["CURRENT_PROJECT_VERSION"] = next_build_number
|
38
|
+
end
|
39
|
+
project.save
|
40
|
+
end
|
41
|
+
|
42
|
+
private_class_method
|
43
|
+
def self.select_build_configuration_predicate(name, configuration)
|
44
|
+
is_build_valid_configuration = configuration.isa == "XCBuildConfiguration" && !configuration.build_settings["PRODUCT_BUNDLE_IDENTIFIER"].nil?
|
45
|
+
is_build_valid_configuration &&= configuration.name == name unless name.nil?
|
46
|
+
return is_build_valid_configuration
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.set_build_number_using_target(params, next_build_number)
|
50
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
51
|
+
if params[:target]
|
52
|
+
target = project.targets.detect { |t| t.name == params[:target] }
|
53
|
+
else
|
54
|
+
# firstly we are trying to find modern application target
|
55
|
+
target = project.targets.detect do |t|
|
56
|
+
t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
|
57
|
+
t.product_type == 'com.apple.product-type.application'
|
58
|
+
end
|
59
|
+
target = project.targets[0] if target.nil?
|
60
|
+
end
|
61
|
+
|
62
|
+
target.build_configurations.each do |config|
|
63
|
+
UI.message "updating #{config.name} to build #{next_build_number}"
|
64
|
+
config.build_settings["CURRENT_PROJECT_VERSION"] = next_build_number
|
65
|
+
end unless target.nil?
|
66
|
+
|
67
|
+
project.save
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.set_build_number_using_scheme(params, next_build_number)
|
71
|
+
config = { project: params[:xcodeproj], scheme: params[:scheme], configuration: params[:build_configuration_name] }
|
72
|
+
project = FastlaneCore::Project.new(config)
|
73
|
+
project.select_scheme
|
74
|
+
|
75
|
+
project.build_settings["CURRENT_PROJECT_VERSION"] = next_build_number
|
76
|
+
project.save
|
77
|
+
end
|
78
|
+
|
79
|
+
#####################################################
|
80
|
+
# @!group Documentation
|
81
|
+
#####################################################
|
82
|
+
|
83
|
+
def self.description
|
84
|
+
"Increment build number in xcodeproj"
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.available_options
|
88
|
+
[
|
89
|
+
FastlaneCore::ConfigItem.new(key: :build_number,
|
90
|
+
env_name: "FL_BUILD_NUMBER_BUILD_NUMBER",
|
91
|
+
description: "Change to a specific build number",
|
92
|
+
optional: true),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
94
|
+
env_name: "FL_VERSION_NUMBER_PROJECT",
|
95
|
+
description: "Optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
|
96
|
+
optional: true,
|
97
|
+
verify_block: proc do |value|
|
98
|
+
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
|
99
|
+
UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
|
100
|
+
end),
|
101
|
+
FastlaneCore::ConfigItem.new(key: :target,
|
102
|
+
env_name: "FL_VERSION_NUMBER_TARGET",
|
103
|
+
optional: true,
|
104
|
+
conflicting_options: [:scheme],
|
105
|
+
description: "Specify a specific target if you have multiple per project, optional"),
|
106
|
+
FastlaneCore::ConfigItem.new(key: :scheme,
|
107
|
+
env_name: "FL_VERSION_NUMBER_SCHEME",
|
108
|
+
optional: true,
|
109
|
+
conflicting_options: [:target],
|
110
|
+
description: "Specify a specific scheme if you have multiple per project, optional"),
|
111
|
+
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
112
|
+
optional: true,
|
113
|
+
description: "Specify a specific build configuration if you have different build settings for each configuration")
|
114
|
+
]
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.authors
|
118
|
+
["jdouglas-nz"]
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.is_supported?(platform)
|
122
|
+
%i[ios mac android].include? platform
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|