gonative-cli 0.7.17 → 0.8.0
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/Gemfile.lock +1 -1
- data/lib/gonative/commands/ios/embed_extensions.rb +15 -0
- data/lib/gonative/commands/ios/extract_extensions.rb +17 -0
- data/lib/gonative/commands/ios/publish.rb +4 -3
- data/lib/gonative/commands.rb +2 -0
- data/lib/gonative/plugins/ios/build_framework.rb +16 -3
- data/lib/gonative/plugins/ios/embed_extensions.rb +73 -0
- data/lib/gonative/plugins/ios/extract_extensions.rb +86 -0
- data/lib/gonative/version.rb +1 -1
- data/templates/build/ios/PLUGIN_NAME-umbrella.h.tpl +16 -0
- data/templates/build/ios/PLUGIN_NAME.modulemap.tpl +6 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7995dad23118881e1f16097bc42257ab6592b53ec48eed27edd9ad1393a09273
|
4
|
+
data.tar.gz: 213cf6485bda29cfeeaa561cb316439a9b42fe9def6eb3c2d1f2a9cba441e03d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d51cad7d56e6d9f233933393c9ee0669e8245ccff392beace11141cfa53c03d2daa86a56c70ae30adf3e581ad0163be523b3da0f8a368331a872a2f6d9edd1
|
7
|
+
data.tar.gz: d605e247903c38c9a0123700ed55632e1df41cc8185b72755da018b989ea0cabca06d82dd4e79e7dfcb7972b97532bdc53de71d2912c4cad38f1c13d84530c5f
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GoNative
|
4
|
+
module Commands
|
5
|
+
module IOS
|
6
|
+
class EmbedExtensions < Base
|
7
|
+
desc 'Extracts extension targets from a project'
|
8
|
+
|
9
|
+
def call(**)
|
10
|
+
Plugins::IOS::EmbedExtensions.call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GoNative
|
4
|
+
module Commands
|
5
|
+
module IOS
|
6
|
+
class ExtractExtensions < Base
|
7
|
+
desc 'Extracts extension targets from a project'
|
8
|
+
|
9
|
+
argument :path, required: false, desc: 'Path to the xcodeproj'
|
10
|
+
|
11
|
+
def call(path:, **)
|
12
|
+
Plugins::IOS::ExtractExtensions.call(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,15 +4,16 @@ module GoNative
|
|
4
4
|
module Commands
|
5
5
|
module IOS
|
6
6
|
class Publish < Base
|
7
|
+
autoload :FileUtils, 'fileutils'
|
7
8
|
desc 'Verify, build and release a new version'
|
8
|
-
argument :name, required: true, desc: 'Name of the plugin'
|
9
9
|
option :skip_build, type: :boolean, default: false
|
10
10
|
option :debug, type: :boolean, default: false
|
11
11
|
option :archs, default: 'x86_64,arm64'
|
12
12
|
|
13
|
-
def call(
|
13
|
+
def call(skip_build:, debug:, archs:, **)
|
14
|
+
FileUtils.cd('/Users/hunaidhassan/Projects/gonative/AuthPlugin')
|
14
15
|
Plugins::IOS::Verify.call
|
15
|
-
Plugins::IOS::BuildFramework.call(
|
16
|
+
Plugins::IOS::BuildFramework.call(archs, debug) unless skip_build
|
16
17
|
Plugins::IOS::Release.call
|
17
18
|
end
|
18
19
|
end
|
data/lib/gonative/commands.rb
CHANGED
@@ -7,6 +7,8 @@ module GoNative
|
|
7
7
|
register 'version', Version, aliases: %w[--version -v]
|
8
8
|
register 'ios create', IOS::Create
|
9
9
|
register 'ios publish', IOS::Publish
|
10
|
+
register 'ios extract', IOS::ExtractExtensions
|
11
|
+
register 'ios embed', IOS::EmbedExtensions
|
10
12
|
register 'android create', Android::Create
|
11
13
|
end
|
12
14
|
end
|
@@ -16,8 +16,11 @@ module GoNative
|
|
16
16
|
|
17
17
|
attr_reader :plugin_name, :archs, :persist_build_dir
|
18
18
|
|
19
|
-
def initialize(
|
20
|
-
|
19
|
+
def initialize(archs, persist_build_dir)
|
20
|
+
podspec_file = Dir["./*.podspec"].first
|
21
|
+
raise Error, "No podspec exists." unless podspec_file
|
22
|
+
|
23
|
+
@plugin_name = File.basename(podspec_file, '.podspec')
|
21
24
|
@archs = archs.gsub(',', ' ')
|
22
25
|
@persist_build_dir = persist_build_dir
|
23
26
|
end
|
@@ -49,10 +52,18 @@ module GoNative
|
|
49
52
|
deployment_target)
|
50
53
|
main_group = proj.new_group(plugin_name, plugin_name)
|
51
54
|
classes_group = main_group.new_group('Classes', 'Classes')
|
52
|
-
references = Dir.glob("../#{plugin_name}/Classes
|
55
|
+
references = Dir.glob("../#{plugin_name}/Classes/**/*.{m,swift}").map{ |file| classes_group.new_file("../../#{file}") }
|
53
56
|
target.add_file_references(references)
|
57
|
+
references = Dir.glob("../#{plugin_name}/Classes/**/*.h").map{ |file| classes_group.new_file("../../#{file}") }
|
58
|
+
header_files = target.add_file_references(references)
|
59
|
+
header_files << target.headers_build_phase.add_file_reference(main_group.new_file("../#{plugin_name}-umbrella.h"))
|
60
|
+
header_files.each do |header|
|
61
|
+
header.settings = { 'ATTRIBUTES' => ['Public'] }
|
62
|
+
end
|
54
63
|
target.build_configurations.each do |config|
|
55
64
|
config.build_settings['GENERATE_INFOPLIST_FILE'] = 'YES'
|
65
|
+
config.build_settings['MODULEMAP_FILE'] = "#{plugin_name}.modulemap"
|
66
|
+
config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = "org.cocoapods.#{plugin_name}"
|
56
67
|
end
|
57
68
|
proj.save("#{plugin_name}.xcodeproj")
|
58
69
|
end
|
@@ -60,8 +71,10 @@ module GoNative
|
|
60
71
|
def move_template_files
|
61
72
|
plugin_dependencies = spec.dependencies.map{|d| ["pod '#{d.name}'", "'#{d.requirement}'"].compact.join(', ') } * "\n\t"
|
62
73
|
FileUtils.cp_r("#{BUILD_TEMPLATE_DIRECTORY_PATH}/.", '.')
|
74
|
+
headers = Dir.glob("../#{plugin_name}/Classes/**/*.h").map{ |f| "#import \"#{File.basename(f)}\"" } * "\n"
|
63
75
|
Utils::TemplateInflator.new(plugin_name: plugin_name,
|
64
76
|
plugin_dependencies: plugin_dependencies,
|
77
|
+
plugin_headers: headers,
|
65
78
|
archs: archs,
|
66
79
|
deployment_target: deployment_target
|
67
80
|
).call
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'xcodeproj'
|
5
|
+
|
6
|
+
module GoNative
|
7
|
+
module Plugins
|
8
|
+
module IOS
|
9
|
+
class EmbedExtensions
|
10
|
+
extend DSL::Serviceable
|
11
|
+
autoload :FileUtils, 'fileutils'
|
12
|
+
|
13
|
+
attr_reader :extensions
|
14
|
+
|
15
|
+
def call
|
16
|
+
prepare_extensions
|
17
|
+
embed_in_project
|
18
|
+
modify_podfile
|
19
|
+
end
|
20
|
+
|
21
|
+
def prepare_extensions
|
22
|
+
extension_paths = `find ./Pods -iname Extensions -not -empty -type d`.split("\n")
|
23
|
+
extension_paths
|
24
|
+
.map { |path| Pathname(path).children.select(&:directory?) }
|
25
|
+
.flatten
|
26
|
+
.each { |path| FileUtils.cp_r(path, '.') }
|
27
|
+
@extensions = extension_paths
|
28
|
+
.map { |path| Pathname(path).children.select{ |p| p.extname == '.json'} }
|
29
|
+
.flatten
|
30
|
+
.map { |p| JSON.parse(File.read(p)) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def embed_in_project
|
34
|
+
proj = Xcodeproj::Project.open('GoNativeIOS.xcodeproj')
|
35
|
+
extensions.each do |extension|
|
36
|
+
target = proj.new_target(:app_extension,
|
37
|
+
extension['name'],
|
38
|
+
:ios,
|
39
|
+
'11.0')
|
40
|
+
extension_group = proj.new_group(extension['name'], extension['name'])
|
41
|
+
|
42
|
+
extension['headers'].each{ |path| extension_group.new_file(path) }
|
43
|
+
target.add_file_references(extension['source_files'].map{ |path| extension_group.new_file(path) })
|
44
|
+
target.add_resources(extension['resources'].map{ |path| extension_group.new_file(path) })
|
45
|
+
target.add_system_frameworks(extension['system_frameworks'])
|
46
|
+
|
47
|
+
if extension['entitlements']
|
48
|
+
extension_group.new_file(extension['entitlements'])
|
49
|
+
target.build_configurations.each do |config|
|
50
|
+
config.build_settings['CODE_SIGN_ENTITLEMENTS'] = "#{extension['name']}/#{extension['entitlements']}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
proj.save
|
56
|
+
end
|
57
|
+
|
58
|
+
def modify_podfile
|
59
|
+
extensions.each do |extension|
|
60
|
+
open('Podfile', 'a') do |f|
|
61
|
+
f.puts "target '#{extension['name']}' do"
|
62
|
+
f.puts "\tuse_frameworks!"
|
63
|
+
extension['dependencies'].each do |dep|
|
64
|
+
f.puts "\tpod #{dep['name']}, #{dep['requirement']}"
|
65
|
+
end
|
66
|
+
f.puts "end"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cocoapods'
|
4
|
+
require 'xcodeproj'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module GoNative
|
8
|
+
module Plugins
|
9
|
+
module IOS
|
10
|
+
class ExtractExtensions
|
11
|
+
extend DSL::Serviceable
|
12
|
+
autoload :FileUtils, 'fileutils'
|
13
|
+
|
14
|
+
attr_reader :proj_path
|
15
|
+
|
16
|
+
def initialize(path)
|
17
|
+
@proj_path = path
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
original_path = FileUtils.pwd
|
22
|
+
FileUtils.cd(File.dirname(proj_path))
|
23
|
+
proj = Xcodeproj::Project.open(proj_path)
|
24
|
+
extension_targets = proj.targets.select { |target| target.product_type == Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension] }
|
25
|
+
|
26
|
+
extension_targets.each do |target|
|
27
|
+
extension_name = target.name
|
28
|
+
extension_path = "Extensions/#{target.name}"
|
29
|
+
|
30
|
+
target_definition = {}
|
31
|
+
target_definition[:name] = extension_name
|
32
|
+
|
33
|
+
FileUtils.cd(extension_name)
|
34
|
+
target_definition[:entitlements] = `find -E . -regex ".*\.(entitlements)"`.split("\n").first
|
35
|
+
target_definition[:headers] = `find -E . -regex ".*\.(h)"`.split("\n")
|
36
|
+
target_definition[:source_files] = `find -E . -regex ".*\.(m|swift)"`.split("\n")
|
37
|
+
target_definition[:resources] = target
|
38
|
+
.resources_build_phase
|
39
|
+
.files
|
40
|
+
.map(&:file_ref)
|
41
|
+
.map(&:name)
|
42
|
+
.map { |name| `find . -name #{name}`.strip }
|
43
|
+
|
44
|
+
target_definition[:system_frameworks] = target
|
45
|
+
.frameworks_build_phase
|
46
|
+
.files
|
47
|
+
.map(&:file_ref)
|
48
|
+
.map(&:path)
|
49
|
+
.select{|p| p.start_with? 'System'}
|
50
|
+
.map{ |p| File.basename(p)}
|
51
|
+
|
52
|
+
target_definition[:dependencies] = podfile.target_definitions[extension_name].dependencies.map do |dependency|
|
53
|
+
{
|
54
|
+
name: dependency.name,
|
55
|
+
requirement: dependency.requirement.requirements.map { |r| r.map(&:to_s).join(' ') }.join(', ')
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
target_definition.slice(:entitlements, :headers, :source_files, :resources).values.compact.flatten.each do |file_path|
|
60
|
+
system('ditto', file_path, "#{original_path}/#{extension_path}/#{file_path}")
|
61
|
+
end
|
62
|
+
|
63
|
+
File.open("#{original_path}/#{extension_path}.json","w") do |f|
|
64
|
+
f.write(JSON.pretty_generate(target_definition))
|
65
|
+
end
|
66
|
+
|
67
|
+
FileUtils.cd('..')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def podfile
|
72
|
+
@podfile ||= Pod::Podfile.from_file(Pathname.new(File.dirname(proj_path) + '/Podfile'))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# //:configuration = Debug
|
80
|
+
# CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements
|
81
|
+
#
|
82
|
+
# //:configuration = Release
|
83
|
+
# CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements
|
84
|
+
#
|
85
|
+
# //:completeSettings = some
|
86
|
+
# CODE_SIGN_ENTITLEMENTS
|
data/lib/gonative/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
#ifdef __OBJC__
|
2
|
+
#import <UIKit/UIKit.h>
|
3
|
+
#else
|
4
|
+
#ifndef FOUNDATION_EXPORT
|
5
|
+
#if defined(__cplusplus)
|
6
|
+
#define FOUNDATION_EXPORT extern "C"
|
7
|
+
#else
|
8
|
+
#define FOUNDATION_EXPORT extern
|
9
|
+
#endif
|
10
|
+
#endif
|
11
|
+
#endif
|
12
|
+
|
13
|
+
#{plugin_headers}
|
14
|
+
|
15
|
+
FOUNDATION_EXPORT double #{plugin_name}VersionNumber;
|
16
|
+
FOUNDATION_EXPORT const unsigned char #{plugin_name}VersionString[];
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gonative-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunaid Hassan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -190,6 +190,8 @@ files:
|
|
190
190
|
- lib/gonative/commands/android/create.rb
|
191
191
|
- lib/gonative/commands/base.rb
|
192
192
|
- lib/gonative/commands/ios/create.rb
|
193
|
+
- lib/gonative/commands/ios/embed_extensions.rb
|
194
|
+
- lib/gonative/commands/ios/extract_extensions.rb
|
193
195
|
- lib/gonative/commands/ios/publish.rb
|
194
196
|
- lib/gonative/commands/version.rb
|
195
197
|
- lib/gonative/dsl/error_catchable.rb
|
@@ -197,6 +199,8 @@ files:
|
|
197
199
|
- lib/gonative/plugins/android/create.rb
|
198
200
|
- lib/gonative/plugins/ios/build_framework.rb
|
199
201
|
- lib/gonative/plugins/ios/create.rb
|
202
|
+
- lib/gonative/plugins/ios/embed_extensions.rb
|
203
|
+
- lib/gonative/plugins/ios/extract_extensions.rb
|
200
204
|
- lib/gonative/plugins/ios/release.rb
|
201
205
|
- lib/gonative/plugins/ios/verify.rb
|
202
206
|
- lib/gonative/utils.rb
|
@@ -205,6 +209,8 @@ files:
|
|
205
209
|
- lib/gonative/utils/template_inflator.rb
|
206
210
|
- lib/gonative/utils/ui.rb
|
207
211
|
- lib/gonative/version.rb
|
212
|
+
- templates/build/ios/PLUGIN_NAME-umbrella.h.tpl
|
213
|
+
- templates/build/ios/PLUGIN_NAME.modulemap.tpl
|
208
214
|
- templates/build/ios/Podfile.tpl
|
209
215
|
- templates/build/ios/create-framework.sh.tpl
|
210
216
|
- templates/plugins/android/build.gradle
|