cocoapods-project-gen 0.1.0 → 0.2.3
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 +4 -4
- data/README.md +62 -23
- data/bin/xcframework +11 -0
- data/lib/cocoapods-project-gen/command/command.rb +25 -0
- data/lib/cocoapods-project-gen/command/gen.rb +120 -0
- data/lib/cocoapods-project-gen/gem_version.rb +1 -1
- data/lib/cocoapods-project-gen/gen/build/headers_store.rb +104 -0
- data/lib/cocoapods-project-gen/gen/build/xcode_build.rb +47 -0
- data/lib/cocoapods-project-gen/gen/constants.rb +71 -0
- data/lib/cocoapods-project-gen/gen/pod/pod_copy_cleaner.rb +50 -0
- data/lib/cocoapods-project-gen/gen/pod/project_gen_helper.rb +341 -0
- data/lib/cocoapods-project-gen/gen/pod/swift_module_helper.rb +134 -0
- data/lib/cocoapods-project-gen/gen/product/product_helper.rb +93 -0
- data/lib/cocoapods-project-gen/gen/product.rb +165 -0
- data/lib/cocoapods-project-gen/gen/project_builder.rb +144 -0
- data/lib/cocoapods-project-gen/gen/project_gen.rb +179 -128
- data/lib/cocoapods-project-gen/gen/results.rb +143 -0
- data/lib/cocoapods-project-gen/gen/utils.rb +35 -0
- data/lib/cocoapods-project-gen/gen/xcframework_gen.rb +44 -0
- data/lib/cocoapods-project-gen.rb +14 -7
- metadata +21 -6
- data/lib/cocoapods-project-gen/gen/swift_module_helper.rb +0 -52
@@ -0,0 +1,143 @@
|
|
1
|
+
module ProjectGen
|
2
|
+
class Results
|
3
|
+
# !@group results
|
4
|
+
|
5
|
+
attr_reader :results
|
6
|
+
|
7
|
+
def initialize(ignore_public_only_results: false)
|
8
|
+
@ignore_public_only_results = ignore_public_only_results
|
9
|
+
@results = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.puts(message = '')
|
13
|
+
$stdout.puts message
|
14
|
+
end
|
15
|
+
|
16
|
+
def error(*args)
|
17
|
+
add_result(:error, *args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def warning(*args)
|
21
|
+
add_result(:warning, *args)
|
22
|
+
end
|
23
|
+
|
24
|
+
def note(*args)
|
25
|
+
add_result(:note, *args)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Prints the result of the validation to the user.
|
29
|
+
#
|
30
|
+
# @return [void]
|
31
|
+
#
|
32
|
+
def print_results
|
33
|
+
Results.puts results_message
|
34
|
+
end
|
35
|
+
|
36
|
+
def results_message
|
37
|
+
message = ''
|
38
|
+
results.each do |result|
|
39
|
+
if result.platforms == [:ios]
|
40
|
+
platform_message = '[iOS] '
|
41
|
+
elsif result.platforms == [:osx]
|
42
|
+
platform_message = '[OSX] '
|
43
|
+
elsif result.platforms == [:watchos]
|
44
|
+
platform_message = '[watchOS] '
|
45
|
+
elsif result.platforms == [:tvos]
|
46
|
+
platform_message = '[tvOS] '
|
47
|
+
end
|
48
|
+
case result.type
|
49
|
+
when :error then type = 'ERROR'
|
50
|
+
when :warning then type = 'WARN'
|
51
|
+
when :note then type = 'NOTE'
|
52
|
+
else raise result.type.to_s end
|
53
|
+
message << " - #{type.ljust(5)} | #{platform_message}#{result.attribute_name}: #{result.message}\n"
|
54
|
+
end
|
55
|
+
message << "\n"
|
56
|
+
end
|
57
|
+
|
58
|
+
def failure_reason
|
59
|
+
results_by_type = results.group_by(&:type)
|
60
|
+
results_by_type.default = []
|
61
|
+
return nil if validated?
|
62
|
+
|
63
|
+
reasons = []
|
64
|
+
if (size = results_by_type[:error].size) && size > 0
|
65
|
+
reasons << "#{size} #{'error'.pluralize(size)}"
|
66
|
+
end
|
67
|
+
if !allow_warnings && (size = results_by_type[:warning].size) && size > 0
|
68
|
+
reason = "#{size} #{'warning'.pluralize(size)}"
|
69
|
+
pronoun = size == 1 ? 'it' : 'them'
|
70
|
+
reason << " (but you can use `--allow-warnings` to ignore #{pronoun})" if reasons.empty?
|
71
|
+
reasons << reason
|
72
|
+
end
|
73
|
+
if results.all?(&:public_only)
|
74
|
+
reasons << 'all results apply only to public specs, but you can use ' \
|
75
|
+
'`--private` to ignore them if linting the specification for a private pod'
|
76
|
+
end
|
77
|
+
|
78
|
+
reasons.to_sentence
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [Symbol] The type, which should been used to display the result.
|
82
|
+
# One of: `:error`, `:warning`, `:note`.
|
83
|
+
#
|
84
|
+
def result_type
|
85
|
+
applicable_results = results
|
86
|
+
applicable_results = applicable_results.reject(&:public_only?) if @ignore_public_only_results
|
87
|
+
types = applicable_results.map(&:type).uniq
|
88
|
+
if types.include?(:error) then :error
|
89
|
+
elsif types.include?(:warning) then :warning
|
90
|
+
else
|
91
|
+
:note
|
92
|
+
end
|
93
|
+
end
|
94
|
+
# !@group Result Helpers
|
95
|
+
|
96
|
+
def add_result(type, attribute_name, message, public_only = false)
|
97
|
+
result = results.find do |r|
|
98
|
+
r.type == type && r.attribute_name && r.message == message && r.public_only? == public_only
|
99
|
+
end
|
100
|
+
unless result
|
101
|
+
result = Pod::Specification::Linter::Results::Result.new(type, attribute_name, message, public_only)
|
102
|
+
results << result
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def translate_xcodebuild_output_to_messages(output)
|
107
|
+
parsed_output = parse_xcodebuild_output(output)
|
108
|
+
parsed_output.each do |message|
|
109
|
+
next if message.include?("'InputFile' should have")
|
110
|
+
|
111
|
+
if message =~ /\S*error:/
|
112
|
+
error('xcodebuild', message)
|
113
|
+
elsif message =~ /\S*warning:/
|
114
|
+
warning('xcodebuild', message)
|
115
|
+
else
|
116
|
+
note('xcodebuild', message)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# Parse the xcode build output to identify the lines which are relevant
|
122
|
+
# to the linter.
|
123
|
+
#
|
124
|
+
# @param [String] output the output generated by the xcodebuild tool.
|
125
|
+
#
|
126
|
+
# @note The indentation and the temporary path is stripped form the
|
127
|
+
# lines.
|
128
|
+
#
|
129
|
+
# @return [Array<String>] the lines that are relevant to the linter.
|
130
|
+
#
|
131
|
+
def parse_xcodebuild_output(output)
|
132
|
+
lines = output.split("\n")
|
133
|
+
selected_lines = lines.select do |l|
|
134
|
+
l.include?('error: ') && (l !~ /errors? generated\./) && (l !~ /error: \(null\)/) ||
|
135
|
+
l.include?('warning: ') && (l !~ /warnings? generated\./) && (l !~ /frameworks only run on iOS 8/) ||
|
136
|
+
l.include?('note: ') && (l !~ /expanded from macro/)
|
137
|
+
end
|
138
|
+
selected_lines.map do |l|
|
139
|
+
l.force_encoding('UTF-8').gsub(/xcodebuild:\s*/, '')
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module ProjectGen
|
4
|
+
module Utils
|
5
|
+
# @return [Bool]
|
6
|
+
#
|
7
|
+
def self.absolute?(path)
|
8
|
+
Pathname(path).absolute? || path.to_s.start_with?('~')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.remove_target_scope_suffix(label, scope_suffix)
|
12
|
+
if scope_suffix.nil? || scope_suffix[0] == '.'
|
13
|
+
label.delete_suffix(scope_suffix || '')
|
14
|
+
else
|
15
|
+
label.delete_suffix("-#{scope_suffix}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.zip(product_path, zip_path)
|
20
|
+
product_name = Pathname.new(product_path).basename
|
21
|
+
zip_product_name = Pathname.new(zip_path).basename
|
22
|
+
FileUtils.rm_rf(zip_path)
|
23
|
+
FileUtils.mkdir_p(zip_path.dirname)
|
24
|
+
Dir.chdir(product_path) do
|
25
|
+
out_put = `pushd #{product_name};zip -qry #{zip_path} *;popd`
|
26
|
+
if out_put.downcase.include?('error')
|
27
|
+
$stdout.puts(out_put.red)
|
28
|
+
else
|
29
|
+
$stdout.puts("#{zip_product_name}:".green)
|
30
|
+
$stdout.puts(" path: #{zip_path}".green)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'cocoapods-project-gen/gen/project_gen'
|
2
|
+
require 'cocoapods-project-gen/gen/project_builder'
|
3
|
+
|
4
|
+
module ProjectGen
|
5
|
+
class XcframeworkGen
|
6
|
+
|
7
|
+
def self.new_from_project_gen(project_gen)
|
8
|
+
new(project_gen)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Initialize a new instance
|
12
|
+
#
|
13
|
+
# @param [ProjectGenerator] project_gen
|
14
|
+
# Creates the target for the Pods libraries in the Pods project and the
|
15
|
+
# relative support files.
|
16
|
+
#
|
17
|
+
def initialize(project_gen)
|
18
|
+
@project_gen = project_gen
|
19
|
+
end
|
20
|
+
|
21
|
+
# Initialize a new instance
|
22
|
+
#
|
23
|
+
# @param [<Pathname, String>] work_dir
|
24
|
+
# the temporary directory used by the Generator.
|
25
|
+
#
|
26
|
+
# @param [Symbol] The name of the build configuration.
|
27
|
+
#
|
28
|
+
# @param [Bool] Build xcframework.
|
29
|
+
#
|
30
|
+
def generate_xcframework(work_dir, configuration = nil, build: true, build_library_for_distribution: false)
|
31
|
+
app_root = Pathname.new(work_dir).expand_path
|
32
|
+
o_value = nil
|
33
|
+
@project_gen.generate!(app_root) do |platforms, pod_targets, no_clean, fail_fast|
|
34
|
+
if build
|
35
|
+
bm = BuildManager.new(app_root, no_clean: no_clean, fail_fast: fail_fast)
|
36
|
+
o_value = bm.create_xcframework_products!(platforms, pod_targets, configuration, build_library_for_distribution: build_library_for_distribution)
|
37
|
+
else
|
38
|
+
o_value = pod_targets
|
39
|
+
end
|
40
|
+
end
|
41
|
+
o_value
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,7 +1,14 @@
|
|
1
|
-
module ProjectGen
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
module ProjectGen
|
2
|
+
require 'cocoapods'
|
3
|
+
require 'pathname'
|
4
|
+
require 'claide'
|
5
|
+
require 'cocoapods-project-gen/gem_version'
|
6
|
+
# autoload registers a file path to be loaded the first time
|
7
|
+
# that a specified module or class is accessed in the namespace of the calling module or class.
|
8
|
+
autoload :Command, 'cocoapods-project-gen/command/command'
|
9
|
+
autoload :ProjectGenerator, 'cocoapods-project-gen/gen/project_gen'
|
10
|
+
autoload :XcframeworkGen, 'cocoapods-project-gen/gen/xcframework_gen'
|
11
|
+
autoload :Constants, 'cocoapods-project-gen/gen/constants'
|
12
|
+
autoload :Utils, 'cocoapods-project-gen/gen/utils'
|
13
|
+
autoload :Results, 'cocoapods-project-gen/gen/results'
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-project-gen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cat1237
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.11.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.11.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -41,16 +41,31 @@ dependencies:
|
|
41
41
|
description: cocoapods project gen
|
42
42
|
email:
|
43
43
|
- wangson1237@outlook.com
|
44
|
-
executables:
|
44
|
+
executables:
|
45
|
+
- xcframework
|
45
46
|
extensions: []
|
46
47
|
extra_rdoc_files: []
|
47
48
|
files:
|
48
49
|
- LICENSE
|
49
50
|
- README.md
|
51
|
+
- bin/xcframework
|
50
52
|
- lib/cocoapods-project-gen.rb
|
53
|
+
- lib/cocoapods-project-gen/command/command.rb
|
54
|
+
- lib/cocoapods-project-gen/command/gen.rb
|
51
55
|
- lib/cocoapods-project-gen/gem_version.rb
|
56
|
+
- lib/cocoapods-project-gen/gen/build/headers_store.rb
|
57
|
+
- lib/cocoapods-project-gen/gen/build/xcode_build.rb
|
58
|
+
- lib/cocoapods-project-gen/gen/constants.rb
|
59
|
+
- lib/cocoapods-project-gen/gen/pod/pod_copy_cleaner.rb
|
60
|
+
- lib/cocoapods-project-gen/gen/pod/project_gen_helper.rb
|
61
|
+
- lib/cocoapods-project-gen/gen/pod/swift_module_helper.rb
|
62
|
+
- lib/cocoapods-project-gen/gen/product.rb
|
63
|
+
- lib/cocoapods-project-gen/gen/product/product_helper.rb
|
64
|
+
- lib/cocoapods-project-gen/gen/project_builder.rb
|
52
65
|
- lib/cocoapods-project-gen/gen/project_gen.rb
|
53
|
-
- lib/cocoapods-project-gen/gen/
|
66
|
+
- lib/cocoapods-project-gen/gen/results.rb
|
67
|
+
- lib/cocoapods-project-gen/gen/utils.rb
|
68
|
+
- lib/cocoapods-project-gen/gen/xcframework_gen.rb
|
54
69
|
homepage: https://github.com/Cat1237/cocoapods-project-gen.git
|
55
70
|
licenses:
|
56
71
|
- MIT
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'cocoapods'
|
2
|
-
|
3
|
-
module ProjectGen
|
4
|
-
module SwiftModule
|
5
|
-
COPY_LIBRARY_SWIFT_HEADERS = 'Copy-Library-Swift-Headers'
|
6
|
-
private_constant :COPY_LIBRARY_SWIFT_HEADERS
|
7
|
-
|
8
|
-
# Adds a shell script phase, intended only for library targets that contain swift,
|
9
|
-
# to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates)
|
10
|
-
# to the built products directory. Additionally, the script phase copies the module map, appending a `.Swift`
|
11
|
-
# submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header
|
12
|
-
# is _also_ copied, so that it is sitting next to the module map. This is necessary for a successful archive build.
|
13
|
-
#
|
14
|
-
# @param [PBXNativeTarget] native_target
|
15
|
-
# the native target to add the Swift static library script phase into.
|
16
|
-
#
|
17
|
-
# @return [Void]
|
18
|
-
#
|
19
|
-
def add_swift_library_compatibility_header(targets)
|
20
|
-
targets.each do |target|
|
21
|
-
relative_module_map_path = target.module_map_path.relative_path_from(target.sandbox.root)
|
22
|
-
relative_umbrella_header_path = target.umbrella_header_path.relative_path_from(target.sandbox.root)
|
23
|
-
shell_script = <<-SH.strip_heredoc
|
24
|
-
COMPATIBILITY_HEADER_ROOT_PATH="${SRCROOT}/${PRODUCT_MODULE_NAME}/#{COPY_LIBRARY_SWIFT_HEADERS}"
|
25
|
-
COPY_MODULE_MAP_PATH="${COMPATIBILITY_HEADER_ROOT_PATH}/${PRODUCT_MODULE_NAME}.modulemap"
|
26
|
-
ditto "${PODS_ROOT}/#{relative_module_map_path}" "${COPY_MODULE_MAP_PATH}"
|
27
|
-
UMBRELLA_HEADER_PATH="${PODS_ROOT}/#{relative_umbrella_header_path}"
|
28
|
-
if test -f "$UMBRELLA_HEADER_PATH"; then
|
29
|
-
ditto "$UMBRELLA_HEADER_PATH" "${COMPATIBILITY_HEADER_ROOT_PATH}"
|
30
|
-
fi
|
31
|
-
SH
|
32
|
-
|
33
|
-
target.root_spec.script_phases ||= []
|
34
|
-
target.root_spec.script_phases += [{ name: 'Copy Copy generated module header', script: shell_script }]
|
35
|
-
next unless target.uses_swift?
|
36
|
-
|
37
|
-
shell_script = <<-SH.strip_heredoc
|
38
|
-
COMPATIBILITY_HEADER_ROOT_PATH="${SRCROOT}/${PRODUCT_MODULE_NAME}/#{COPY_LIBRARY_SWIFT_HEADERS}"
|
39
|
-
COPY_COMPATIBILITY_HEADER_PATH="${COMPATIBILITY_HEADER_ROOT_PATH}/${PRODUCT_MODULE_NAME}-Swift.h"#{' '}
|
40
|
-
COPY_MODULE_MAP_PATH="${COMPATIBILITY_HEADER_ROOT_PATH}/${PRODUCT_MODULE_NAME}.modulemap"
|
41
|
-
ditto "${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h" "${COPY_COMPATIBILITY_HEADER_PATH}"#{' '}
|
42
|
-
ditto "${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.swiftmodule" "${COMPATIBILITY_HEADER_ROOT_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule"#{' '}
|
43
|
-
printf "\\n\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\n header \\"${PRODUCT_MODULE_NAME}-Swift.h\\"\\n requires objc\\n}\\n" >> "${COPY_MODULE_MAP_PATH}"
|
44
|
-
SH
|
45
|
-
target.root_spec.script_phases += [{
|
46
|
-
name: 'Copy Copy generated compatibility header',
|
47
|
-
script: shell_script
|
48
|
-
}]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|