gonative-cli 0.7.17 → 0.9.0

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
  SHA256:
3
- metadata.gz: 266c15337f1ef121f2c088feb35a31f7045992e4925baec26ed20b11785534f5
4
- data.tar.gz: 7f51fbebfab848d4b6d460637c3489aef0a8fc2113608d7bb8dd5ae8930e3154
3
+ metadata.gz: 392a2b4ff0ecb66ee524f2b0843f2aa334c22c0bd2723bb28a569e9318bdb111
4
+ data.tar.gz: efce28573e1fd80d0a408ad0c62fd48d687c791efa05ea90dd096fc2fc748d0a
5
5
  SHA512:
6
- metadata.gz: c803898debbc3f77c285444856a5f708296b6e911fc4e98a2bf17c1a3966b6f7f1fa844cac7f98c198cc721add3cf3e54887be11024160d2213c9143ce055146
7
- data.tar.gz: 21f1d1a60f93e09d5837b0a6a5e9da4259f6c51dc98ff14c62f1615e0c3acb2c20db251858750873ab8b5a9f0921dba7dbf61b02447937b28ca4be3852fa32f0
6
+ metadata.gz: 446b75f6fd9d62edb92c3ba57ef32837e64fcb02834dcbb26c2abe146eebe083fce59bf34fcf3f90f1d2f4db2256d59bc0232a2ae36a4263344c192293650793
7
+ data.tar.gz: b0732cacf207e93be3b22cec558a6cb87307ef7b627cd68f2b1b63bf1363c0fce6c48f4baa2d7e4bb8d712053440fed962fec065f0074a1b20b5a7a34f07ec59
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gonative-cli (0.7.12)
4
+ gonative-cli (0.8.1)
5
5
  activesupport (~> 6.0)
6
6
  cocoapods (~> 1.10)
7
7
  colorize (~> 0.8.0)
@@ -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 'Embeds all extensions from plugins to the 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,15 @@ 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(name:, skip_build:, debug:, archs:, **)
13
+ def call(skip_build:, debug:, archs:, **)
14
14
  Plugins::IOS::Verify.call
15
- Plugins::IOS::BuildFramework.call(name, archs, debug) unless skip_build
15
+ Plugins::IOS::BuildFramework.call(archs, debug) unless skip_build
16
16
  Plugins::IOS::Release.call
17
17
  end
18
18
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GoNative
4
+ module Commands
5
+ module IOS
6
+ class SetBundleId < Base
7
+ desc 'Sets bundle Id '
8
+
9
+ argument :bundle_id, required: true, desc: 'Bundle id for the app'
10
+ option :with_entitlements, type: :boolean, default: false
11
+
12
+ def call(bundle_id:, with_entitlements:, **)
13
+ Plugins::IOS::SetBundleId.call(bundle_id, with_entitlements)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,6 +7,9 @@ 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-extensions', IOS::ExtractExtensions
11
+ register 'ios embed-extensions', IOS::EmbedExtensions
12
+ register 'ios set-bundle-id', IOS::SetBundleId
10
13
  register 'android create', Android::Create
11
14
  end
12
15
  end
@@ -16,8 +16,11 @@ module GoNative
16
16
 
17
17
  attr_reader :plugin_name, :archs, :persist_build_dir
18
18
 
19
- def initialize(plugin_name, archs, persist_build_dir)
20
- @plugin_name = plugin_name
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/**").map{ |file| classes_group.new_file("../../#{file}") }
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,72 @@
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
+ extension_group.new_file(extension['info'])
47
+ extension_group.new_file(extension['entitlements']) if extension['entitlements']
48
+ target.build_configurations.each do |config|
49
+ config.build_settings['INFOPLIST_FILE'] = "#{extension['name']}/#{extension['info']}"
50
+ config.build_settings['CODE_SIGN_ENTITLEMENTS'] = "#{extension['name']}/#{extension['entitlements']}" if extension['entitlements']
51
+ end
52
+ end
53
+
54
+ proj.save
55
+ end
56
+
57
+ def modify_podfile
58
+ extensions.each do |extension|
59
+ open('Podfile', 'a') do |f|
60
+ f.puts "target '#{extension['name']}' do"
61
+ f.puts "\tuse_frameworks!"
62
+ extension['dependencies'].each do |dep|
63
+ f.puts "\tpod #{dep['name']}, #{dep['requirement']}"
64
+ end
65
+ f.puts "end"
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,87 @@
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[:info] = `find . -name '*Info.plist'`.split("\n").first
35
+ target_definition[:entitlements] = `find -E . -regex ".*\.(entitlements)"`.split("\n").first
36
+ target_definition[:headers] = `find -E . -regex ".*\.(h)"`.split("\n")
37
+ target_definition[:source_files] = `find -E . -regex ".*\.(m|swift)"`.split("\n")
38
+ target_definition[:resources] = target
39
+ .resources_build_phase
40
+ .files
41
+ .map(&:file_ref)
42
+ .map(&:name)
43
+ .map { |name| `find . -name #{name}`.strip }
44
+
45
+ target_definition[:system_frameworks] = target
46
+ .frameworks_build_phase
47
+ .files
48
+ .map(&:file_ref)
49
+ .map(&:path)
50
+ .select{|p| p.start_with? 'System'}
51
+ .map{ |p| File.basename(p)}
52
+
53
+ target_definition[:dependencies] = podfile.target_definitions[extension_name].dependencies.map do |dependency|
54
+ {
55
+ name: dependency.name,
56
+ requirement: dependency.requirement.requirements.map { |r| r.map(&:to_s).join(' ') }.join(', ')
57
+ }
58
+ end
59
+
60
+ target_definition.slice(:info, :entitlements, :headers, :source_files, :resources).values.compact.flatten.each do |file_path|
61
+ system('ditto', file_path, "#{original_path}/#{extension_path}/#{file_path}")
62
+ end
63
+
64
+ File.open("#{original_path}/#{extension_path}.json","w") do |f|
65
+ f.write(JSON.pretty_generate(target_definition))
66
+ end
67
+
68
+ FileUtils.cd('..')
69
+ end
70
+ end
71
+
72
+ def podfile
73
+ @podfile ||= Pod::Podfile.from_file(Pathname.new(File.dirname(proj_path) + '/Podfile'))
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ # //:configuration = Debug
81
+ # CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements
82
+ #
83
+ # //:configuration = Release
84
+ # CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements
85
+ #
86
+ # //:completeSettings = some
87
+ # CODE_SIGN_ENTITLEMENTS
@@ -45,7 +45,7 @@ module GoNative
45
45
  end
46
46
 
47
47
  def push_to_pod_repo!
48
- system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private"
48
+ system "pod repo push #{GONATIVE_SOURCE_NAME} #{spec_name} --private --allow-warnings"
49
49
  end
50
50
 
51
51
  def spec_name
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'xcodeproj'
4
+ require 'cfpropertylist'
5
+
6
+ module GoNative
7
+ module Plugins
8
+ module IOS
9
+ class SetBundleId
10
+ extend DSL::Serviceable
11
+
12
+ attr_reader :bundle_id
13
+
14
+ def initialize(bundle_id, update_entitlements)
15
+ @bundle_id = bundle_id
16
+ @update_entitlements = update_entitlements
17
+ end
18
+
19
+ def call
20
+ update_project
21
+ update_entitlements if update_entitlements?
22
+ end
23
+
24
+ def update_project
25
+ proj = Xcodeproj::Project.open('./GoNativeIOS.xcodeproj')
26
+ proj.targets.each do |target|
27
+ case target.product_type
28
+ when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:application]
29
+ set_target_bundle_id(target, bundle_id)
30
+ when Xcodeproj::Constants::PRODUCT_TYPE_UTI[:app_extension]
31
+ set_target_bundle_id(target, bundle_id + '.' + target.name)
32
+ else
33
+ next
34
+ end
35
+ end
36
+
37
+ proj.save
38
+ end
39
+
40
+ def update_entitlements
41
+ entitlement_files = `find -E . -maxdepth 2 -regex ".*\.(entitlements)"`.split("\n")
42
+ entitlement_files.each do |entitlement_file|
43
+ plist = CFPropertyList::List.new(file: entitlement_file)
44
+ entitlements = CFPropertyList.native_types(plist.value)
45
+ entitlements['com.apple.security.application-groups'] = ['group.' + bundle_id]
46
+ plist.value = CFPropertyList.guess(entitlements)
47
+ plist.save(entitlement_file, CFPropertyList::List::FORMAT_XML)
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def set_target_bundle_id(target, bundle_id)
54
+ target.build_configurations.each do |config|
55
+ config.build_settings['PRODUCT_BUNDLE_IDENTIFIER'] = bundle_id
56
+ end
57
+ end
58
+
59
+ def update_entitlements?
60
+ @update_entitlements
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GoNative
4
- VERSION = "0.7.17"
4
+ VERSION = "0.9.0"
5
5
  end
@@ -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[];
@@ -0,0 +1,6 @@
1
+ framework module #{plugin_name} {
2
+ umbrella header "#{plugin_name}-umbrella.h"
3
+
4
+ export *
5
+ module * { export * }
6
+ }
@@ -14,7 +14,7 @@ TODO: Add long description of the pod here.
14
14
 
15
15
  s.ios.deployment_target = '10.0'
16
16
  s.swift_versions = '5.0'
17
- s.preserve_paths = 'plist/*.{plist}'
17
+ s.preserve_paths = ['plist/*.{plist}', 'Extensions/**/*']
18
18
 
19
19
  s.subspec 'Source' do |cs|
20
20
  cs.source_files = '#{plugin_name}/Classes/**/*.{h,m,swift}'
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.7.17
4
+ version: 0.9.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-01-19 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-cli
@@ -190,14 +190,20 @@ 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
196
+ - lib/gonative/commands/ios/set_bundle_id.rb
194
197
  - lib/gonative/commands/version.rb
195
198
  - lib/gonative/dsl/error_catchable.rb
196
199
  - lib/gonative/dsl/serviceable.rb
197
200
  - lib/gonative/plugins/android/create.rb
198
201
  - lib/gonative/plugins/ios/build_framework.rb
199
202
  - lib/gonative/plugins/ios/create.rb
203
+ - lib/gonative/plugins/ios/embed_extensions.rb
204
+ - lib/gonative/plugins/ios/extract_extensions.rb
200
205
  - lib/gonative/plugins/ios/release.rb
206
+ - lib/gonative/plugins/ios/set_bundle_id.rb
201
207
  - lib/gonative/plugins/ios/verify.rb
202
208
  - lib/gonative/utils.rb
203
209
  - lib/gonative/utils/content_evaluator.rb
@@ -205,6 +211,8 @@ files:
205
211
  - lib/gonative/utils/template_inflator.rb
206
212
  - lib/gonative/utils/ui.rb
207
213
  - lib/gonative/version.rb
214
+ - templates/build/ios/PLUGIN_NAME-umbrella.h.tpl
215
+ - templates/build/ios/PLUGIN_NAME.modulemap.tpl
208
216
  - templates/build/ios/Podfile.tpl
209
217
  - templates/build/ios/create-framework.sh.tpl
210
218
  - templates/plugins/android/build.gradle