Module: CocoaPodsKeys
- Extended by:
- FileUtils
- Defined in:
- lib/plugin.rb,
lib/keyring.rb,
lib/key_master.rb,
lib/preinstaller.rb,
lib/cocoapods_keys.rb,
lib/name_whisperer.rb,
lib/keyring_liberator.rb
Defined Under Namespace
Classes: KeyMaster, Keyring, KeyringLiberator, NameWhisperer, PreInstaller
Constant Summary
collapse
- VERSION =
'2.0.0'.freeze
Class Method Summary
collapse
Class Method Details
.add_keys_to_pods(podfile, keys_path, options) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/plugin.rb', line 56
def add_keys_to_pods(podfile, keys_path, options)
keys_targets = options['target'] || options['targets']
if keys_targets
keys_target_list = ([] << keys_targets).flatten
keys_target_list.each do |keys_target|
pod_target = podfile.root_target_definitions.flat_map(&:children).find do |target|
target.label == "Pods-#{keys_target}"
end
if pod_target
pod_target.store_pod 'Keys', :path => keys_path.to_path
else
Pod::UI.puts "Could not find a target named '#{keys_target}' in your Podfile. Stopping keys".red
end
end
else
podfile.pod 'Keys', :path => keys_path.to_path
end
end
|
.setup(podfile, options) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/plugin.rb', line 14
def setup(podfile, options)
require 'preinstaller'
unless PreInstaller.new(options).setup
raise Pod::Informative, 'Could not load key data'
end
installation_root = Pod::Config.instance.installation_root
keys_path = installation_root.+('Pods/CocoaPodsKeys/')
mkdir_p keys_path
podspec_path = Pathname(__dir__) + '../templates' + 'Keys.podspec.json'
cp podspec_path, keys_path
local_user_options = options || {}
project = local_user_options.fetch('project') { CocoaPodsKeys::NameWhisperer.get_project_name }
keyring = KeyringLiberator.get_current_keyring(project, Dir.getwd) ||
Keyring.new(project, Dir.getwd, local_user_options['keys'])
raise Pod::Informative, 'Could not load keyring' unless keyring
key_master = KeyMaster.new(keyring)
interface_file = keys_path + (key_master.name + '.h')
implementation_file = keys_path + (key_master.name + '.m')
File.write(interface_file, key_master.interface)
File.write(implementation_file, key_master.implementation)
add_keys_to_pods(podfile, keys_path.relative_path_from(installation_root), options)
Pod::HooksManager.register('cocoapods-keys', :post_install) do
shared_scheme_path = 'Pods/Pods.xcodeproj/xcshareddata/xcschemes/Keys.xcscheme'
FileUtils.rm(shared_scheme_path) if File.exist?(shared_scheme_path)
end
end
|