ambient-xcode 0.2.0 → 0.3.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
  SHA1:
3
- metadata.gz: 36a5027a9d319fa88b1bc45e45990b9553eca940
4
- data.tar.gz: 2a9614d04af26567d4908708e4eb4d19bc4b34bd
3
+ metadata.gz: 74297d6847b0d837aeb70f2f86eecf4ff2644f6e
4
+ data.tar.gz: 8b4450eab0effc1c41ddcebc70c350d0aa9b05c7
5
5
  SHA512:
6
- metadata.gz: 4d135a916846179681e5c28399993ad398619cb461f13922eb780c9becc88fa4741eac04837c55fc1d23ea8e8c67b9c91d563d1901f7bbf379113dbf5fa7f532
7
- data.tar.gz: a8cee9b724b86123e98238f41e69f71b838b8cf93ee03fdcf6985d1088e210b28341516a235586b4d2e3adbbfa15986742e4f013a5406d90c5c75a7409a9069b
6
+ metadata.gz: 079fe3f096c467c9f7a35423cec8b13b14e601e88d14ee418987deac1fcadf9443ce3dd559fa257c831d90edaea443431344b20611e5f62b480ca49376dd74cc
7
+ data.tar.gz: 329c5495cf88b45dc37fb8c7078669ffc08c2da508c9cbf84552daa326835c222c94cb1acb61a63b213a701ca103d8c4cabefd21cf7c907e05cfc1b28b01208e
data/README.md CHANGED
@@ -34,6 +34,9 @@ option "CLANG_ENABLE_OBJC_ARC", true
34
34
  option "CLANG_ENABLE_MODULES", true
35
35
 
36
36
  target "MyProject" do
37
+ capability :healthkit
38
+ capability :apple_pay
39
+
37
40
  scheme "Debug" do
38
41
  option "PRODUCT_NAME", "Debug"
39
42
  option "BUNDLE_DISPLAY_NAME_SUFFIX", "uk.danielgreen.MyProject"
@@ -45,6 +48,17 @@ Run `ambient` from the command line to write your settings into your project.
45
48
 
46
49
  The [example Ambientfile](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile) matches the exact settings of a new iOS project.
47
50
 
51
+ If for any reason you want multiple Ambientfile, you can:
52
+ ```
53
+ use_settings_from 'Ambientfile'
54
+
55
+ target "Babylon" do
56
+ capability :apple_pay
57
+ end
58
+ ```
59
+
60
+ Just run `ambient [filename]` (i.e. `ambient Ambientfile-enterprise`)
61
+
48
62
  Notes
49
63
  =====
50
64
 
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'ambient-xcode'
6
- gem.version = '0.2.0'
6
+ gem.version = '0.3.0'
7
7
  gem.authors = ['Daniel Green']
8
8
  gem.email = ['dan2552@gmail.com']
9
9
  gem.description = %q{CLI for configuring Xcode projects from a Ruby file.}
@@ -12,7 +12,6 @@ Gem::Specification.new do |gem|
12
12
  gem.license = 'MIT'
13
13
 
14
14
  gem.add_dependency 'xcodeproj', '~> 0.25'
15
- gem.add_dependency 'highline', '~> 1.6'
16
15
 
17
16
  gem.files = `git ls-files`.split($/)
18
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/bin/ambient CHANGED
@@ -4,4 +4,5 @@ require 'fileutils'
4
4
  $:.push File.expand_path("../../lib", __FILE__)
5
5
 
6
6
  require 'ambient'
7
- Ambient.setup_project
7
+ file = ARGV[0] || 'Ambientfile'
8
+ Ambient.setup_project(file)
data/lib/ambient.rb CHANGED
@@ -7,6 +7,7 @@ unless Kernel.respond_to?(:require_relative)
7
7
  end
8
8
 
9
9
  require_relative 'project_helper'
10
+ require_relative 'capabilities_helper'
10
11
  require_relative 'dsl'
11
12
 
12
13
  module Ambient
@@ -19,6 +20,7 @@ module Ambient
19
20
  @target_options = {}
20
21
  @scheme_options = {}
21
22
  @parents = {}
23
+ @capabilities = {}
22
24
 
23
25
  def configure(&block)
24
26
  instance_eval &block
@@ -57,28 +59,38 @@ module Ambient
57
59
  end
58
60
  end
59
61
 
60
- def setup_project
62
+ def set_capability(target_name, capability_name)
63
+ capabilities = @capabilities[target_name] ||= []
64
+ capabilities << capability_name
65
+ end
66
+
67
+ def setup_project(ambientfile)
68
+ run_ambientfile(ambientfile)
61
69
  project_helper.print_info
62
- reset_project_to_defaults
63
- reset_targets_to_defaults
70
+ reset_project_to_defaults if @use_defaults
71
+ reset_targets_to_defaults if @use_defaults
72
+ reset_capabilites_to_defaults if @use_defaults
64
73
  process_project_options
65
74
  process_scheme_options
66
75
  process_shared_target_options
67
76
  process_target_options
77
+ process_capabilities
78
+ project_helper.save_changes
68
79
  end
69
80
 
70
81
  def reset_project_to_defaults
71
- if @use_defaults
72
- puts "resetting project settings to xcode default settings"
73
- project_helper.reset_project_to_defaults
74
- end
82
+ puts "resetting project settings to xcode default settings"
83
+ project_helper.reset_project_to_defaults
75
84
  end
76
85
 
77
86
  def reset_targets_to_defaults
78
- if @use_defaults
79
- puts "resetting target settings to xcode default settings"
80
- project_helper.reset_targets_to_defaults
81
- end
87
+ puts "resetting target settings to xcode default settings"
88
+ project_helper.reset_targets_to_defaults
89
+ end
90
+
91
+ def reset_capabilites_to_defaults
92
+ puts "resetting capabilities to xcode default settings"
93
+ project_helper.reset_capabilities_to_defaults
82
94
  end
83
95
 
84
96
  def process_project_options
@@ -102,6 +114,11 @@ module Ambient
102
114
  project_helper.process_target_options(@target_options)
103
115
  end
104
116
 
117
+ def process_capabilities
118
+ puts "applying ambient capabilities"
119
+ project_helper.process_capabilities(@capabilities)
120
+ end
121
+
105
122
  def load_in_parent_target_values
106
123
  @parents.each do |target, parents|
107
124
  parents.each do |child, parent|
@@ -115,8 +132,10 @@ module Ambient
115
132
  end
116
133
  end
117
134
 
118
- ambient = File.join(Dir.pwd, 'Ambientfile')
119
- raise "ambient not found" unless File.exists?(ambient)
120
-
121
- load ambient
135
+ def run_ambientfile(filename)
136
+ puts "Reading settings from #{filename}"
137
+ ambient = File.join(Dir.pwd, filename)
138
+ raise "#{filename} not found in current directory." unless File.exists?(ambient)
139
+ load ambient
140
+ end
122
141
  end
@@ -0,0 +1,59 @@
1
+ require 'xcodeproj'
2
+ class CapabilitiesHelper
3
+ CAPABILITIES = {
4
+ application_group_ios: "ApplicationGroups.iOS",
5
+ background_modes: "BackgroundModes",
6
+ data_protection: "DataProtection",
7
+ game_center: "GameCenter",
8
+ healthkit: "HealthKit",
9
+ health_kit: "HealthKit",
10
+ homekit: "HomeKit",
11
+ home_kit: "HomeKit",
12
+ in_app_purchase: "InAppPurchase",
13
+ inter_app_audio: "InterAppAudio",
14
+ keychain: "Keychain",
15
+ maps: "Maps.iOS",
16
+ apple_pay: "OMC",
17
+ passbook: "Passbook",
18
+ wallet: "Passbook",
19
+ safari_keychain: "SafariKeychain",
20
+ personal_vpn: "VPNLite",
21
+ wireless_accessory_configuration: "WAC",
22
+ icloud: "iCloud"
23
+ }
24
+
25
+ def initialize(project, target)
26
+ @project = project
27
+ @target = target
28
+ end
29
+
30
+ def clear_capabilities
31
+ capabilities.delete_if { |_, _| true } if capabilities
32
+ end
33
+
34
+ def enable_capability(capability)
35
+ capabilities[capability_key(capability)] = {"enabled"=>"1"}
36
+ end
37
+
38
+ def disable_capability(capability)
39
+ capabilities.delete(capability_key(capability))
40
+ end
41
+
42
+ private
43
+
44
+ def capabilities
45
+ target_attributes["SystemCapabilities"]
46
+ end
47
+
48
+ def target_attributes
49
+ @project.root_object.attributes["TargetAttributes"][@target.uuid]
50
+ end
51
+
52
+ def capability_key(capability)
53
+ capability = CAPABILITIES[capability] || capability.to_s
54
+ prefix = "com.apple."
55
+ capability = "#{prefix}#{capability}" unless capability.start_with? prefix
56
+ capability
57
+ end
58
+
59
+ end
data/lib/dsl.rb CHANGED
@@ -1,3 +1,7 @@
1
+ def use_settings_from(filename)
2
+ Ambient.configure { run_ambientfile(filename) }
3
+ end
4
+
1
5
  def option(name, value)
2
6
  Ambient.configure { set_option(name, value) }
3
7
  end
@@ -84,6 +88,11 @@ class TargetScope
84
88
  def scheme(name, parent: nil, &block)
85
89
  SchemeScope.new(self, name, parent).configure(&block)
86
90
  end
91
+
92
+ def capability(capability_name)
93
+ target_name = @name
94
+ Ambient.configure { set_capability(target_name, capability_name) }
95
+ end
87
96
  end
88
97
 
89
98
  class SchemeScope
@@ -1,5 +1,4 @@
1
1
  require 'xcodeproj'
2
- require 'highline/import'
3
2
 
4
3
  class ProjectHelper
5
4
  PROJECTS = Dir.glob('*.xcodeproj')
@@ -13,7 +12,6 @@ class ProjectHelper
13
12
  build_settings = configuration.build_settings
14
13
  build_settings.each { |k, _| build_settings.delete(k) }
15
14
  end
16
- save_changes
17
15
  end
18
16
 
19
17
  def reset_targets_to_defaults
@@ -25,6 +23,12 @@ class ProjectHelper
25
23
  end
26
24
  end
27
25
 
26
+ def reset_capabilities_to_defaults
27
+ @project.targets.each do |target|
28
+ CapabilitiesHelper.new(@project, target).clear_capabilities
29
+ end
30
+ end
31
+
28
32
  def process_project_options(options)
29
33
  @project.build_configurations.each do |configuration|
30
34
  options.each do |key, value|
@@ -32,7 +36,6 @@ class ProjectHelper
32
36
  configuration.build_settings.delete(key) if value == nil
33
37
  end
34
38
  end
35
- save_changes
36
39
  end
37
40
 
38
41
  def process_shared_target_options(shared_target_options)
@@ -44,7 +47,6 @@ class ProjectHelper
44
47
  end
45
48
  end
46
49
  end
47
- save_changes
48
50
  end
49
51
 
50
52
  def process_target_options(target_options)
@@ -59,7 +61,17 @@ class ProjectHelper
59
61
  end
60
62
  end
61
63
  end
62
- save_changes
64
+ end
65
+
66
+ def process_capabilities(capabilities_hash)
67
+ capabilities_hash.each do |target_name, capabilities|
68
+ @project.targets.each do |target|
69
+ if target_name == target.to_s
70
+ helper = CapabilitiesHelper.new(@project, target)
71
+ capabilities.each { |c| helper.enable_capability(c) }
72
+ end
73
+ end
74
+ end
63
75
  end
64
76
 
65
77
  def process_scheme_options(options)
@@ -70,7 +82,6 @@ class ProjectHelper
70
82
  configuration.build_settings.delete(key) if value == nil
71
83
  end
72
84
  end
73
- save_changes
74
85
  end
75
86
 
76
87
  def print_info
@@ -82,9 +93,8 @@ class ProjectHelper
82
93
  puts ""
83
94
  end
84
95
 
85
- private
86
-
87
96
  def save_changes
88
97
  @project.save
89
98
  end
99
+
90
100
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ambient-xcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Green
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.25'
27
- - !ruby/object:Gem::Dependency
28
- name: highline
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.6'
41
27
  description: CLI for configuring Xcode projects from a Ruby file.
42
28
  email:
43
29
  - dan2552@gmail.com
@@ -51,6 +37,7 @@ files:
51
37
  - bin/ambient
52
38
  - example/Ambientfile
53
39
  - lib/ambient.rb
40
+ - lib/capabilities_helper.rb
54
41
  - lib/dsl.rb
55
42
  - lib/project_helper.rb
56
43
  homepage: https://github.com/Dan2552/ambient