Top Level Namespace
Defined Under Namespace
Modules: CocoapodsPlayonNetwork, Pod
Instance Method Summary
collapse
-
#_configure_aws_credentials ⇒ Object
-
#_configure_pods(installer, version) ⇒ Object
-
#_download_flutter_framework(url) ⇒ Object
-
#_download_framework(name, url) ⇒ Object
-
#_embed_and_sign(framework:, in_target:) ⇒ Object
-
#_get_all_plugins(url) ⇒ Object
-
#_pod(name, url, configuration) ⇒ Object
-
#_pod_plugin(plugin, url) ⇒ Object
-
#_set_config_value(path, key, value) ⇒ Object
-
#_unzip_framework(name, print_name, config, env = nil) ⇒ Object
-
#_xcconfig_path(config, target_name) ⇒ Object
-
#add_config_value(key, debug_value, release_value = nil, in_project:, in_target: nil) ⇒ Object
-
#add_framework(name, print_name, in_project:, in_target: nil, needs_env: false) ⇒ Object
-
#framework_exist?(frameworks_group, path) ⇒ Boolean
-
#frameworks_path(config, env = nil, needs_env: nil) ⇒ Object
-
#get_frameworks_build_phase(target) ⇒ Object
-
#open_xcode_project ⇒ Object
-
#post_install_playon_network(installer, version: "12.0") ⇒ Object
-
#post_integrate_playon_network(target: nil, debug: :staging, release: :production) ⇒ Object
-
#target_for_project(project, target) ⇒ Object
-
#unzip_file(file, destination) ⇒ Object
-
#use_playon_network ⇒ Object
Install all the pods needed to use the PLAYON Network games.
Instance Method Details
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/cocoapods_plugin.rb', line 70
def _configure_aws_credentials
playon_network_params = YAML.load_file('playon-network.yaml')
username = playon_network_params['username']
access_key = playon_network_params["sdk"]["accessKey"]
secret_key = playon_network_params["sdk"]["secretKey"]
set_aws_credentials :region => 'eu-west-1', :access_key => access_key, :secret_key => secret_key
"s3://playon-network-sdk/ios/#{username}"
end
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/cocoapods_plugin.rb', line 130
def _configure_pods(installer, version)
puts "Configuring PLAYON Network Pods"
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = 'NO'
config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < version.to_f
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = version
end
config.build_settings['OTHER_LDFLAGS'] = '$(inherited) "-framework Flutter"'
path = "#{Dir.pwd}/#{frameworks_path config.type}/Flutter.xcframework"
Dir.new(path).each_child do |xcframework_file|
next if xcframework_file.start_with?('.') if xcframework_file.end_with?('-simulator') config.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{path}/#{xcframework_file}\" $(inherited)"
elsif xcframework_file.start_with?('ios-') config.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{path}/#{xcframework_file}\" $(inherited)"
end
end
end
end
end
|
#_download_flutter_framework(url) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/cocoapods_plugin.rb', line 81
def _download_flutter_framework(url)
response = YAML.load get_s3_object :url => "#{url}/Flutter.yaml"
%w[Debug Profile Release].each do |config|
path = frameworks_path config
FileUtils.mkdir_p path unless Dir.exist? path
url = response[config]
download = URI.open(url)
IO.copy_stream(download, "#{path}/Flutter.xcframework.zip")
end
end
|
#_download_framework(name, url) ⇒ Object
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/cocoapods_plugin.rb', line 94
def _download_framework(name, url)
%w[Debug Profile Release].each do |config|
%w[Staging Production].each do |env|
path = frameworks_path config, env
FileUtils.mkdir_p path unless Dir.exist? path
get_s3_object :url => "#{url}/#{env.downcase}/#{config}-#{name}", :target => "#{path}/#{name}"
end
end
end
|
#_embed_and_sign(framework:, in_target:) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 43
def _embed_and_sign(framework:, in_target:)
target = in_target
target.add_resources([framework])
target.frameworks_build_phase.add_file_reference framework, true
target.resources_build_phase.add_file_reference framework, true
embed_frameworks_build_phase = get_frameworks_build_phase target
build_file = embed_frameworks_build_phase.add_file_reference framework, true
build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }
end
|
#_get_all_plugins(url) ⇒ Object
57
58
59
60
|
# File 'lib/cocoapods_plugin.rb', line 57
def _get_all_plugins(url)
response = list_s3_objects :url => "#{url}/plugins"
response.common_prefixes.map { |item| item[:prefix].split('/').last }
end
|
#_pod(name, url, configuration) ⇒ Object
62
63
64
|
# File 'lib/cocoapods_plugin.rb', line 62
def _pod(name, url, configuration)
pod name, :podspec => "#{url}/#{configuration}", :configuration => configuration
end
|
#_pod_plugin(plugin, url) ⇒ Object
66
67
68
|
# File 'lib/cocoapods_plugin.rb', line 66
def _pod_plugin(plugin, url)
pod plugin, :podspec => "#{url}/plugins/#{plugin}/#{plugin}.podspec"
end
|
#_set_config_value(path, key, value) ⇒ Object
64
65
66
67
68
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 64
def _set_config_value(path, key, value)
config = Xcodeproj::Config.new path
config.merge! key => value
config.save_as Pathname.new path
end
|
#_unzip_framework(name, print_name, config, env = nil) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/cocoapods_plugin.rb', line 105
def _unzip_framework(name, print_name, config, env = nil)
framework_name = "#{name}.xcframework"
path = "#{frameworks_path config, env}"
framework_zip = "#{path}/#{framework_name}.zip"
unless env.nil?
path = "#{path}/#{framework_name}"
end
if File.exist? framework_zip
unless File.exist? path
Dir.mkdir path
end
if env.nil?
puts "Adding PLAYON Network #{print_name} Framework for #{config}"
else
puts "Adding PLAYON Network #{print_name} Framework for #{env}:#{config}"
end
unzip_file framework_zip, path
FileUtils.rm_f framework_zip
end
end
|
#_xcconfig_path(config, target_name) ⇒ Object
70
71
72
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 70
def _xcconfig_path(config, target_name)
"Pods/Target Support Files/Pods-#{target_name}/Pods-#{target_name}.#{config}.xcconfig"
end
|
#add_config_value(key, debug_value, release_value = nil, in_project:, in_target: nil) ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 53
def add_config_value(key, debug_value, release_value = nil, in_project:, in_target: nil)
if release_value.nil?
release_value = debug_value
end
target = target_for_project in_project, in_target
_set_config_value _xcconfig_path(:debug, target.name), key, debug_value
_set_config_value _xcconfig_path(:release, target.name), key, release_value
end
|
#add_framework(name, print_name, in_project:, in_target: nil, needs_env: false) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 82
def add_framework(name, print_name, in_project:, in_target: nil, needs_env: false)
frameworks_group = in_project.groups.find { |group| group.name == 'Frameworks' }
path = "#{frameworks_path "$(CONFIGURATION)", "$(PLAYON_NETWORK_ENV)", :needs_env => needs_env}/#{name}.xcframework"
unless frameworks_group.nil? or framework_exist? frameworks_group, path
puts "Configuring project to use #{print_name} framework."
framework = frameworks_group.new_reference path
target = target_for_project in_project, in_target
_embed_and_sign :framework => framework, :in_target => target
end
end
|
#framework_exist?(frameworks_group, path) ⇒ Boolean
27
28
29
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 27
def framework_exist?(frameworks_group, path)
frameworks_group.children.find { |child| child.path == path }
end
|
#frameworks_path(config, env = nil, needs_env: nil) ⇒ Object
96
97
98
99
100
101
102
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 96
def frameworks_path(config, env = nil, needs_env: nil)
if env.nil? or needs_env == false
return "Frameworks/PLAYON-Network-SDK/#{config}"
end
"Frameworks/PLAYON-Network-SDK/#{config}/#{env}"
end
|
#get_frameworks_build_phase(target) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 31
def get_frameworks_build_phase(target)
name = "Embed Frameworks"
embed_frameworks_build_phase = target.copy_files_build_phases.find { |phase| phase.name == name and phase.symbol_dst_subfolder_spec == :frameworks }
if embed_frameworks_build_phase.nil?
embed_frameworks_build_phase = target.new_copy_files_build_phase 'Embed Frameworks'
embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks
end
embed_frameworks_build_phase
end
|
#open_xcode_project ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 14
def open_xcode_project
paths = Pathname.glob('*.xcodeproj')
project_path = paths.first if paths.size == 1
help! 'A valid Xcode project file is required.' unless project_path
help! "#{project_path} does not exist." unless project_path.exist?
unless project_path.directory? && (project_path + 'project.pbxproj').exist?
help! "#{project_path} is not a valid Xcode project."
end
Xcodeproj::Project.open(project_path)
end
|
#post_install_playon_network(installer, version: "12.0") ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/cocoapods_plugin.rb', line 33
def post_install_playon_network(installer, version: "12.0")
%w[Debug Profile Release].each do |config|
_unzip_framework 'Flutter', 'Engine', config
%w[Staging Production].each do |env|
_unzip_framework 'App', 'Fantasy Game', config, env
end
end
_configure_pods installer, version
end
|
#post_integrate_playon_network(target: nil, debug: :staging, release: :production) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/cocoapods_plugin.rb', line 46
def post_integrate_playon_network(target: nil, debug: :staging, release: :production)
project = open_xcode_project
add_config_value 'PLAYON_NETWORK_ENV', debug.capitalize, release.capitalize, :in_project => project, :in_target => target
add_framework 'Flutter', 'Engine', :in_project => project, :in_target => target
add_framework 'App', 'Fantasy Game', :in_project => project, :in_target => target, :needs_env => true
project.save
end
|
#target_for_project(project, target) ⇒ Object
74
75
76
77
78
79
80
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 74
def target_for_project(project, target)
if target.nil?
project.targets.first
else
project.targets.find { |t| t.name == target }
end
end
|
#unzip_file(file, destination) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'lib/cocoapods-playon-network/helpers.rb', line 4
def unzip_file (file, destination)
Zip::File.open(file) { |zip_file|
zip_file.each { |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.(f, f_path) unless File.exist?(f_path)
}
}
end
|
#use_playon_network ⇒ Object
Install all the pods needed to use the PLAYON Network games.
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/cocoapods_plugin.rb', line 13
def use_playon_network
puts "Installing PLAYON Network Pods"
url = _configure_aws_credentials
pod 'Flutter', :path => File.join(File.dirname(__FILE__), 'Flutter'), :inhibit_warnings => true
_download_framework 'App.xcframework.zip', url
_download_flutter_framework url
_get_all_plugins(url).each do |plugin|
_pod_plugin plugin, url
end
pod 'PlayonNetworkSdk', :git => 'https://github.com/PlayON-Network/ios-sdk.git'
end
|