cocoapods-playon-network 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3c1e3b40ce6b4bf1ac2aad4530e2498e04337864f049a4d5fe7ff82e5033bfd8
4
+ data.tar.gz: 146c2b2e38a6f4c6c01f93cfced26877f7fb56a0cbf28a8b398fc82d48dd2ca9
5
+ SHA512:
6
+ metadata.gz: c920be13895bfe6401dbe566821b4f7e19a94b59e9bba6134057ebeff390f94bf93323d466460bbf617c53e95e0ac6e9bf0032d298bb18130b29c4c7e07cfdf8
7
+ data.tar.gz: 4f0c5f24be82b23d4176b1ca1f5cd2a2f1d3cb056022f6be8d432c3116d7d0f86c249929b6116d849cb8b37696a7f67ffc4a7fff29edcb7e243049286e04f451
@@ -0,0 +1,18 @@
1
+ #
2
+ # This podspec is NOT to be published. It is only used as a local source!
3
+ # This is a generated file; do not edit or check into version control.
4
+ #
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = 'Flutter'
8
+ s.version = '1.0.0'
9
+ s.summary = 'A UI toolkit for beautiful and fast apps.'
10
+ s.homepage = 'https://flutter.dev'
11
+ s.license = { :type => 'BSD' }
12
+ s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
13
+ s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
14
+ s.ios.deployment_target = '12.0'
15
+ # Framework linking is handled by Flutter tooling, not CocoaPods.
16
+ # Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
17
+ s.vendored_frameworks = 'path/to/nothing'
18
+ end
@@ -0,0 +1,33 @@
1
+ module Pod
2
+ class Deintegrator
3
+ alias parent_delete_pods_file_references delete_pods_file_references
4
+
5
+ def delete_pods_file_references(project)
6
+ puts "Removing PLAYON Network."
7
+
8
+ frameworks_group = project.groups.find { |group| group.name == 'Frameworks' }
9
+
10
+ # Remove the framework references in the Xcode project.
11
+ unless frameworks_group.nil?
12
+ _remove_from_project frameworks_group, 'Flutter'
13
+ _remove_from_project frameworks_group, 'App', :needs_env => true
14
+ end
15
+
16
+ # Remove the PLAYON Network SDK from the filesystem.
17
+ path = "Frameworks/PLAYON-Network-SDK"
18
+ FileUtils.remove_dir path if Dir.exist? path
19
+
20
+ parent_delete_pods_file_references project
21
+ end
22
+
23
+ def _remove_from_project(frameworks_group, name, needs_env: false)
24
+ path = "#{frameworks_path "$(CONFIGURATION)", "$(PLAYON_NETWORK_ENV)", :needs_env => needs_env}/#{name}.xcframework"
25
+
26
+ file = frameworks_group.children.find do
27
+ |child| child.path == path
28
+ end
29
+
30
+ file.remove_from_project unless file.nil?
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module CocoapodsPlayonNetwork
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,102 @@
1
+ require 'xcodeproj'
2
+ require 'zip'
3
+
4
+ def unzip_file (file, destination)
5
+ Zip::File.open(file) { |zip_file|
6
+ zip_file.each { |f|
7
+ f_path=File.join(destination, f.name)
8
+ FileUtils.mkdir_p(File.dirname(f_path))
9
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
10
+ }
11
+ }
12
+ end
13
+
14
+ def open_xcode_project
15
+ paths = Pathname.glob('*.xcodeproj')
16
+ project_path = paths.first if paths.size == 1
17
+
18
+ help! 'A valid Xcode project file is required.' unless project_path
19
+ help! "#{project_path} does not exist." unless project_path.exist?
20
+ unless project_path.directory? && (project_path + 'project.pbxproj').exist?
21
+ help! "#{project_path} is not a valid Xcode project."
22
+ end
23
+
24
+ Xcodeproj::Project.open(project_path)
25
+ end
26
+
27
+ def framework_exist?(frameworks_group, path)
28
+ frameworks_group.children.find { |child| child.path == path }
29
+ end
30
+
31
+ def get_frameworks_build_phase(target)
32
+ name = "Embed Frameworks"
33
+ embed_frameworks_build_phase = target.copy_files_build_phases.find { |phase| phase.name == name and phase.symbol_dst_subfolder_spec == :frameworks }
34
+
35
+ if embed_frameworks_build_phase.nil?
36
+ embed_frameworks_build_phase = target.new_copy_files_build_phase 'Embed Frameworks'
37
+ embed_frameworks_build_phase.symbol_dst_subfolder_spec = :frameworks
38
+ end
39
+
40
+ embed_frameworks_build_phase
41
+ end
42
+
43
+ def _embed_and_sign(framework:, in_target:)
44
+ target = in_target
45
+ target.add_resources([framework])
46
+ target.frameworks_build_phase.add_file_reference framework, true
47
+ target.resources_build_phase.add_file_reference framework, true
48
+ embed_frameworks_build_phase = get_frameworks_build_phase target
49
+ build_file = embed_frameworks_build_phase.add_file_reference framework, true
50
+ build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }
51
+ end
52
+
53
+ def add_config_value(key, debug_value, release_value = nil, in_project:, in_target: nil)
54
+ if release_value.nil?
55
+ release_value = debug_value
56
+ end
57
+
58
+ target = target_for_project in_project, in_target
59
+
60
+ _set_config_value _xcconfig_path(:debug, target.name), key, debug_value
61
+ _set_config_value _xcconfig_path(:release, target.name), key, release_value
62
+ end
63
+
64
+ def _set_config_value(path, key, value)
65
+ config = Xcodeproj::Config.new path
66
+ config.merge! key => value
67
+ config.save_as Pathname.new path
68
+ end
69
+
70
+ def _xcconfig_path(config, target_name)
71
+ "Pods/Target Support Files/Pods-#{target_name}/Pods-#{target_name}.#{config}.xcconfig"
72
+ end
73
+
74
+ def target_for_project(project, target)
75
+ if target.nil?
76
+ project.targets.first
77
+ else
78
+ project.targets.find { |t| t.name == target }
79
+ end
80
+ end
81
+
82
+ def add_framework(name, print_name, in_project:, in_target: nil, needs_env: false)
83
+ frameworks_group = in_project.groups.find { |group| group.name == 'Frameworks' }
84
+ path = "#{frameworks_path "$(CONFIGURATION)", "$(PLAYON_NETWORK_ENV)", :needs_env => needs_env}/#{name}.xcframework"
85
+
86
+ unless frameworks_group.nil? or framework_exist? frameworks_group, path
87
+ puts "Configuring project to use #{print_name} framework."
88
+
89
+ framework = frameworks_group.new_reference path
90
+ target = target_for_project in_project, in_target
91
+
92
+ _embed_and_sign :framework => framework, :in_target => target
93
+ end
94
+ end
95
+
96
+ def frameworks_path(config, env = nil, needs_env: nil)
97
+ if env.nil? or needs_env == false
98
+ return "Frameworks/PLAYON-Network-SDK/#{config}"
99
+ end
100
+
101
+ "Frameworks/PLAYON-Network-SDK/#{config}/#{env}"
102
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-playon-network/gem_version'
@@ -0,0 +1,161 @@
1
+ require 'yaml'
2
+ require 'xcodeproj'
3
+ require 'open-uri'
4
+ require 'cocoapods-playon-network/deintegrate'
5
+ require 'cocoapods-playon-network/helpers'
6
+
7
+ # TODO - Waiting this fix https://github.com/CocoaPods/CocoaPods/issues/11277
8
+ #Pod::HooksManager.register('cocoapods-playon-network', :post_integrate) do |context|
9
+ # puts "cocoapods-playon-network post_integrate!!!!"
10
+ #end
11
+
12
+ # Install all the pods needed to use the PLAYON Network games.
13
+ def use_playon_network
14
+ #plugin "cocoapods-playon-network", :target => target
15
+ puts "Installing PLAYON Network Pods"
16
+
17
+ url = _configure_aws_credentials
18
+
19
+ # Framework linking is handled by the plugin, not CocoaPods.
20
+ # Add a dummy pod to satisfy `s.dependency 'Flutter'` plugin podspecs.
21
+ pod 'Flutter', :path => File.join(File.dirname(__FILE__), 'Flutter'), :inhibit_warnings => true
22
+
23
+ _download_framework 'App.xcframework.zip', url
24
+ _download_flutter_framework url
25
+
26
+ _get_all_plugins(url).each do |plugin|
27
+ _pod_plugin plugin, url
28
+ end
29
+
30
+ pod 'PlayonNetworkSdk', :git => 'https://github.com/PlayON-Network/ios-sdk.git'
31
+ end
32
+
33
+ def post_install_playon_network(installer, version: "12.0")
34
+ %w[Debug Profile Release].each do |config|
35
+ _unzip_framework 'Flutter', 'Engine', config
36
+
37
+ %w[Staging Production].each do |env|
38
+ _unzip_framework 'App', 'Fantasy Game', config, env
39
+ end
40
+ end
41
+
42
+ _configure_pods installer, version
43
+ end
44
+
45
+ # https://www.rubydoc.info/gems/xcodeproj
46
+ def post_integrate_playon_network(target: nil, debug: :staging, release: :production)
47
+ project = open_xcode_project
48
+
49
+ add_config_value 'PLAYON_NETWORK_ENV', debug.capitalize, release.capitalize, :in_project => project, :in_target => target
50
+
51
+ add_framework 'Flutter', 'Engine', :in_project => project, :in_target => target
52
+ add_framework 'App', 'Fantasy Game', :in_project => project, :in_target => target, :needs_env => true
53
+
54
+ project.save
55
+ end
56
+
57
+ def _get_all_plugins(url)
58
+ response = list_s3_objects :url => "#{url}/plugins"
59
+ response.common_prefixes.map { |item| item[:prefix].split('/').last }
60
+ end
61
+
62
+ def _pod(name, url, configuration)
63
+ pod name, :podspec => "#{url}/#{configuration}", :configuration => configuration
64
+ end
65
+
66
+ def _pod_plugin(plugin, url)
67
+ pod plugin, :podspec => "#{url}/plugins/#{plugin}/#{plugin}.podspec"
68
+ end
69
+
70
+ def _configure_aws_credentials
71
+ playon_network_params = YAML.load_file('playon-network.yaml')
72
+ username = playon_network_params['username']
73
+ access_key = playon_network_params["sdk"]["accessKey"]
74
+ secret_key = playon_network_params["sdk"]["secretKey"]
75
+
76
+ set_aws_credentials :region => 'eu-west-1', :access_key => access_key, :secret_key => secret_key
77
+
78
+ "s3://playon-network-sdk/ios/#{username}"
79
+ end
80
+
81
+ def _download_flutter_framework(url)
82
+ response = YAML.load get_s3_object :url => "#{url}/Flutter.yaml"
83
+
84
+ %w[Debug Profile Release].each do |config|
85
+ path = frameworks_path config
86
+ FileUtils.mkdir_p path unless Dir.exist? path
87
+
88
+ url = response[config]
89
+ download = URI.open(url)
90
+ IO.copy_stream(download, "#{path}/Flutter.xcframework.zip")
91
+ end
92
+ end
93
+
94
+ def _download_framework(name, url)
95
+ %w[Debug Profile Release].each do |config|
96
+ %w[Staging Production].each do |env|
97
+ path = frameworks_path config, env
98
+ FileUtils.mkdir_p path unless Dir.exist? path
99
+
100
+ get_s3_object :url => "#{url}/#{env.downcase}/#{config}-#{name}", :target => "#{path}/#{name}"
101
+ end
102
+ end
103
+ end
104
+
105
+ def _unzip_framework(name, print_name, config, env = nil)
106
+ framework_name = "#{name}.xcframework"
107
+ path = "#{frameworks_path config, env}"
108
+ framework_zip = "#{path}/#{framework_name}.zip"
109
+
110
+ unless env.nil?
111
+ path = "#{path}/#{framework_name}"
112
+ end
113
+
114
+ if File.exist? framework_zip
115
+ unless File.exist? path
116
+ Dir.mkdir path
117
+ end
118
+
119
+ if env.nil?
120
+ puts "Adding PLAYON Network #{print_name} Framework for #{config}"
121
+ else
122
+ puts "Adding PLAYON Network #{print_name} Framework for #{env}:#{config}"
123
+ end
124
+
125
+ unzip_file framework_zip, path
126
+ FileUtils.rm_f framework_zip
127
+ end
128
+ end
129
+
130
+ def _configure_pods(installer, version)
131
+ puts "Configuring PLAYON Network Pods"
132
+
133
+ installer.pods_project.targets.each do |target|
134
+ target.build_configurations.each do |config|
135
+ config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = 'NO'
136
+ config.build_settings['CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES'] = 'YES'
137
+
138
+ # https://stackoverflow.com/q/76590131
139
+ config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'
140
+
141
+ # https://stackoverflow.com/a/77513296
142
+ if config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f < version.to_f
143
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = version
144
+ end
145
+
146
+ config.build_settings['OTHER_LDFLAGS'] = '$(inherited) "-framework Flutter"'
147
+
148
+ path = "#{Dir.pwd}/#{frameworks_path config.type}/Flutter.xcframework"
149
+
150
+ Dir.new(path).each_child do |xcframework_file|
151
+ next if xcframework_file.start_with?('.') # Hidden file, possibly on external disk.
152
+ if xcframework_file.end_with?('-simulator') # ios-arm64_x86_64-simulator
153
+ config.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{path}/#{xcframework_file}\" $(inherited)"
154
+ elsif xcframework_file.start_with?('ios-') # ios-arm64
155
+ config.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]'] = "\"#{path}/#{xcframework_file}\" $(inherited)"
156
+ # else Info.plist or another platform.
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-playon-network
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - PlayON Network
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: xcodeproj
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods-s3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1'
83
+ description: Cocoapods plugin used to setup the PLAYON Network SDK for iOS
84
+ email:
85
+ - devs@playon.network
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/Flutter/Flutter.podspec
91
+ - lib/cocoapods-playon-network.rb
92
+ - lib/cocoapods-playon-network/deintegrate.rb
93
+ - lib/cocoapods-playon-network/gem_version.rb
94
+ - lib/cocoapods-playon-network/helpers.rb
95
+ - lib/cocoapods_plugin.rb
96
+ homepage: https://playon.network
97
+ licenses:
98
+ - Apache-2.0
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubygems_version: 3.0.9
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Setup the PLAYON Network SDK for iOS easily
119
+ test_files: []