configure_extensions 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 +7 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/bin/configure_extensions +44 -0
- data/lib/configure_extensions.rb +3 -0
- data/lib/configure_extensions/configure.rb +82 -0
- data/lib/configure_extensions/help.rb +28 -0
- data/lib/configure_extensions/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03dedb83051fa1bf3519f8f0f1d6292cd591b9f3
|
4
|
+
data.tar.gz: 349f9af25d3232c2b1f866ed9def75e2fe3bf01a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2996f8ab2a1a847fa5c527bc0a822cd22aa1548e23a089190f6d1c4e5a2dd52ad5f6b769eb7c665db528ef32c778597c071790763e9a915dc8887d557f2ee8af
|
7
|
+
data.tar.gz: cff989c719089ef75687424822043e2377d4c52c285bf8255c30baa7007170e2b06220b2eb3d88974473e96e651d718d658e3b85cb15e844f1c5be30b75be9e0
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Radosław Pietruszewski (http://radex.io/)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# configure_extensions
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'configure_extensions'
|
6
|
+
|
7
|
+
# Determine passed arguments
|
8
|
+
# configure_extensions <mode> <project> <app_target> <extensions...>
|
9
|
+
|
10
|
+
# add/remove mode
|
11
|
+
mode = ARGV.shift
|
12
|
+
|
13
|
+
unless %w(add remove).include? mode
|
14
|
+
ConfigureExtensions::HelpCommand.help
|
15
|
+
exit
|
16
|
+
end
|
17
|
+
|
18
|
+
# reference to .xcodeproj
|
19
|
+
project_file = ARGV.shift
|
20
|
+
|
21
|
+
if project_file.nil? || !project_file.end_with?('.xcodeproj')
|
22
|
+
abort "Pass proper Xcode project (.xcodeproj) file"
|
23
|
+
end
|
24
|
+
|
25
|
+
# main (app) target name
|
26
|
+
app_target_name = ARGV.shift
|
27
|
+
|
28
|
+
abort "Pass app target name (e.g. 'MyApp')" if app_target_name.nil?
|
29
|
+
|
30
|
+
# names of app extension target to add or remove
|
31
|
+
extension_names = ARGV
|
32
|
+
|
33
|
+
if extension_names.empty?
|
34
|
+
puts "[WARN] No extension names to add/remove were passed"
|
35
|
+
exit
|
36
|
+
end
|
37
|
+
|
38
|
+
# execute
|
39
|
+
ConfigureExtensions::ConfigureCommand.configure(
|
40
|
+
mode.to_sym,
|
41
|
+
project_file,
|
42
|
+
app_target_name,
|
43
|
+
extension_names
|
44
|
+
)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
module ConfigureExtensions
|
2
|
+
class ConfigureCommand
|
3
|
+
# If you want to use this as a standalone script without the Gem,
|
4
|
+
# run `sudo gem install xcodeproj` to install the required dependency
|
5
|
+
# copy the contents of the method below, and configure the four argument
|
6
|
+
# variables before everything else
|
7
|
+
def self.configure mode, project_file, app_target_name, extension_names
|
8
|
+
require 'xcodeproj'
|
9
|
+
|
10
|
+
# Find project and app target
|
11
|
+
|
12
|
+
xc = Xcodeproj::Project.open(project_file)
|
13
|
+
app_target = xc.targets.find { |t| t.name == app_target_name }
|
14
|
+
|
15
|
+
# Find app extensions' target objects
|
16
|
+
|
17
|
+
extension_targets = extension_names.map do |ext|
|
18
|
+
target = xc.targets.find { |t| t.name == ext }
|
19
|
+
abort "Couldn't find a '#{ext}' target in '#{project_name}'" if target.nil?
|
20
|
+
abort "'#{ext}' doesn't seem to be an application extension target" unless target.product_type.include? 'app-extension'
|
21
|
+
target
|
22
|
+
end
|
23
|
+
|
24
|
+
# Find .appex product files
|
25
|
+
|
26
|
+
extension_products = extension_targets.map { |target| target.product_reference }
|
27
|
+
|
28
|
+
# Add or remove dependency on extension targets
|
29
|
+
|
30
|
+
extension_targets.each do |target|
|
31
|
+
dependency = app_target.dependency_for_target(target)
|
32
|
+
|
33
|
+
if mode == :add
|
34
|
+
if dependency
|
35
|
+
puts "[WARN] App already has dependency on #{target.name}"
|
36
|
+
else
|
37
|
+
app_target.add_dependency(target)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
if dependency
|
41
|
+
app_target.dependencies.delete(dependency)
|
42
|
+
else
|
43
|
+
puts "[WARN] Couldn't find dependency on #{target.name}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Add or remove .appex copy jobs
|
49
|
+
|
50
|
+
embed_extensions_phase = app_target.copy_files_build_phases.find do |copy_phase|
|
51
|
+
copy_phase.symbol_dst_subfolder_spec == :plug_ins
|
52
|
+
end
|
53
|
+
|
54
|
+
abort "Couldn't find 'Embed App Extensions' phase" if embed_extensions_phase.nil?
|
55
|
+
|
56
|
+
extension_products.each do |appex|
|
57
|
+
appex_included = embed_extensions_phase.files_references.include? appex
|
58
|
+
|
59
|
+
if mode == :add
|
60
|
+
if appex_included
|
61
|
+
puts "[WARN] App already embeds #{appex.display_name}"
|
62
|
+
else
|
63
|
+
build_file = embed_extensions_phase.add_file_reference(appex)
|
64
|
+
build_file.settings = { "ATTRIBUTES" => ['RemoveHeadersOnCopy'] }
|
65
|
+
end
|
66
|
+
else
|
67
|
+
if appex_included
|
68
|
+
embed_extensions_phase.remove_file_reference(appex)
|
69
|
+
else
|
70
|
+
puts "[WARN] App doesn't seem to embed #{appex.display_name}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Save changes
|
76
|
+
|
77
|
+
xc.save()
|
78
|
+
|
79
|
+
puts "Done"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ConfigureExtensions
|
2
|
+
class HelpCommand
|
3
|
+
def self.help
|
4
|
+
puts "configure_extensions <mode> <project> <app_target> <extensions...>"
|
5
|
+
puts
|
6
|
+
puts "Add and remove app extensions from Xcode build"
|
7
|
+
puts
|
8
|
+
puts "mode"
|
9
|
+
puts " add - enables passed app extension targets"
|
10
|
+
puts " remove - disables extensions from being built and embedded in the app"
|
11
|
+
puts
|
12
|
+
puts "project"
|
13
|
+
puts " path to the Xcode project file"
|
14
|
+
puts
|
15
|
+
puts "app_target"
|
16
|
+
puts " name of the main (app) target in which extensions are to be enabled/disabled"
|
17
|
+
puts
|
18
|
+
puts "extensions"
|
19
|
+
puts " names of app extension targets to be enabled/disabled"
|
20
|
+
puts
|
21
|
+
puts "EXAMPLES"
|
22
|
+
puts
|
23
|
+
puts "configure_extensions add MyApp.xcodeproj MyApp NotificationsUI Share"
|
24
|
+
puts "configure_extensions remove Foo.xcodeproj Foo-iOS Share"
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: configure_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Radek Pietruszewski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: xcodeproj
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: CLI tool that allows you to enable/disable app extensions from being
|
42
|
+
built and embedded into your app. Use to maintain compatibility between two SDK
|
43
|
+
versions or for a fast build mode.
|
44
|
+
email: this.is@radex.io
|
45
|
+
executables:
|
46
|
+
- configure_extensions
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- bin/configure_extensions
|
53
|
+
- lib/configure_extensions.rb
|
54
|
+
- lib/configure_extensions/configure.rb
|
55
|
+
- lib/configure_extensions/help.rb
|
56
|
+
- lib/configure_extensions/version.rb
|
57
|
+
homepage: https://github.com/radex/configure_extensions
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.4.5.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Add and remove app extensions from Xcode build
|
81
|
+
test_files: []
|
82
|
+
has_rdoc:
|