ambient-xcode 0.1.0 → 0.2.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: 98615ee39dc25f247d8064579087ebdf523a796a
4
- data.tar.gz: 7c0663d987218c7d8426e4957d12000d04ae7c43
3
+ metadata.gz: 36a5027a9d319fa88b1bc45e45990b9553eca940
4
+ data.tar.gz: 2a9614d04af26567d4908708e4eb4d19bc4b34bd
5
5
  SHA512:
6
- metadata.gz: c504951669259411ab0d46c4c6423356afd05c913b2078fc0f77d7a9715d377d170e23d0fb7b8d7a50f66e9ea8308d447aa337a6db8819163ae0302c8868d16e
7
- data.tar.gz: 0b4bf94607805be90413cd7cc3219bfcc5f2f2611be0ee37f8b592447768070113d3fd9276f19f121fa84b8e3f9d87d25a817980f90c25dddc81330e6e2ef8c6
6
+ metadata.gz: 4d135a916846179681e5c28399993ad398619cb461f13922eb780c9becc88fa4741eac04837c55fc1d23ea8e8c67b9c91d563d1901f7bbf379113dbf5fa7f532
7
+ data.tar.gz: a8cee9b724b86123e98238f41e69f71b838b8cf93ee03fdcf6985d1088e210b28341516a235586b4d2e3adbbfa15986742e4f013a5406d90c5c75a7409a9069b
data/README.md CHANGED
@@ -8,9 +8,14 @@ An `xcconfig` file can be used in order to help abstract your settings away from
8
8
  Installation
9
9
  ============
10
10
 
11
- Add the following to your `Gemfile`:
11
+ Simply run:
12
12
  ```
13
- gem "ambient-xcode", git: "https://github.com/Dan2552/ambient-xcode"
13
+ gem install ambient-xcode
14
+ ```
15
+
16
+ Or if you use Bundler, add the following to your `Gemfile`:
17
+ ```
18
+ gem "ambient-xcode"
14
19
  ```
15
20
 
16
21
  Usage
@@ -18,9 +23,9 @@ Usage
18
23
 
19
24
  Create an `Ambientfile` defining your project in the same directory as your `*.xcodeproj` file.
20
25
 
21
- Here's an example of the `Ambientfile` structure:
26
+ Here's a sample of the `Ambientfile` structure:
22
27
  ```ruby
23
- enable_warnings_and_static_analyser!
28
+ enable_default_warnings!
24
29
  use_defaults_for_everything_not_specified_in_this_file!
25
30
 
26
31
  option "IPHONEOS_DEPLOYMENT_TARGET", "7.0"
@@ -36,7 +41,9 @@ target "MyProject" do
36
41
  end
37
42
  ```
38
43
 
39
- run `ambient` from the command line to write your settings into your project.
44
+ Run `ambient` from the command line to write your settings into your project.
45
+
46
+ The [example Ambientfile](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile) matches the exact settings of a new iOS project.
40
47
 
41
48
  Notes
42
49
  =====
@@ -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.1.0'
6
+ gem.version = '0.2.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.}
@@ -0,0 +1,63 @@
1
+ PROJECT = "MyProject"
2
+ PREFIX = "uk.danielgreen."
3
+
4
+ use_defaults_for_everything_not_specified_in_this_file!
5
+ enable_default_warnings!
6
+
7
+ option "ALWAYS_SEARCH_USER_PATHS", false
8
+ option "CLANG_CXX_LANGUAGE_STANDARD", "gnu++0x"
9
+ option "CLANG_CXX_LIBRARY", "libc++"
10
+ option "CLANG_ENABLE_MODULES", true
11
+ option "CLANG_ENABLE_OBJC_ARC", true
12
+
13
+ option "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Developer"
14
+ option "COPY_PHASE_STRIP", false
15
+
16
+ option "ENABLE_STRICT_OBJC_MSGSEND", true
17
+ option "GCC_C_LANGUAGE_STANDARD", "gnu99"
18
+ option "GCC_NO_COMMON_BLOCKS", true
19
+ option "SDKROOT", "iphoneos"
20
+ option "IPHONEOS_DEPLOYMENT_TARGET", "9.0"
21
+
22
+ scheme "Debug" do
23
+ option "DEBUG_INFORMATION_FORMAT", "dwarf"
24
+ option "ENABLE_TESTABILITY", true
25
+ option "MTL_ENABLE_DEBUG_INFO", true
26
+ option "ONLY_ACTIVE_ARCH", true
27
+ option "GCC_DYNAMIC_NO_PIC", false
28
+ option "GCC_OPTIMIZATION_LEVEL", "0"
29
+ option "GCC_PREPROCESSOR_DEFINITIONS", ["DEBUG=1", "$(inherited)"]
30
+ end
31
+
32
+ scheme "Release" do
33
+ option "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"
34
+ option "ENABLE_NS_ASSERTIONS", false
35
+ option "MTL_ENABLE_DEBUG_INFO", false
36
+ option "VALIDATE_PRODUCT", true
37
+ end
38
+
39
+ target "#{PROJECT}" do
40
+ option "INFOPLIST_FILE", "#{PROJECT}/Info.plist"
41
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{PREFIX}#{PROJECT}"
42
+ option "ASSETCATALOG_COMPILER_APPICON_NAME", "AppIcon"
43
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks"
44
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
45
+ end
46
+
47
+ target "#{PROJECT}Tests" do
48
+ option "INFOPLIST_FILE", "#{PROJECT}Tests/Info.plist"
49
+ option "BUNDLE_LOADER", "$(TEST_HOST)"
50
+ option "TEST_HOST", "$(BUILT_PRODUCTS_DIR)/#{PROJECT}.app/#{PROJECT}"
51
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{PREFIX}#{PROJECT}Tests"
52
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
53
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
54
+ end
55
+
56
+ target "#{PROJECT}UITests" do
57
+ option "INFOPLIST_FILE", "#{PROJECT}UITests/Info.plist"
58
+ option "TEST_TARGET_NAME", "#{PROJECT}"
59
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{PREFIX}#{PROJECT}UITests"
60
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
61
+ option "USES_XCTRUNNER", "YES"
62
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
63
+ end
@@ -17,7 +17,9 @@ module Ambient
17
17
  @project_options = {}
18
18
  @shared_target_options = {}
19
19
  @target_options = {}
20
+ @scheme_options = {}
20
21
  @parents = {}
22
+
21
23
  def configure(&block)
22
24
  instance_eval &block
23
25
  end
@@ -42,12 +44,16 @@ module Ambient
42
44
  @target_options[target][scheme] ||= {}
43
45
  @target_options[target][scheme][option] = value
44
46
  else
45
- # require 'pry'; binding.pry
46
47
  @shared_target_options[target] ||= {}
47
48
  @shared_target_options[target][option] = value
48
49
  end
49
50
  else
50
- @project_options[option] = value
51
+ if scheme
52
+ @scheme_options[scheme] ||= {}
53
+ @scheme_options[scheme][option] = value
54
+ else
55
+ @project_options[option] = value
56
+ end
51
57
  end
52
58
  end
53
59
 
@@ -56,6 +62,7 @@ module Ambient
56
62
  reset_project_to_defaults
57
63
  reset_targets_to_defaults
58
64
  process_project_options
65
+ process_scheme_options
59
66
  process_shared_target_options
60
67
  process_target_options
61
68
  end
@@ -79,6 +86,11 @@ module Ambient
79
86
  project_helper.process_project_options(@project_options)
80
87
  end
81
88
 
89
+ def process_scheme_options
90
+ puts "applying ambient scheme settings"
91
+ project_helper.process_scheme_options(@scheme_options)
92
+ end
93
+
82
94
  def process_shared_target_options
83
95
  puts "applying ambient shared target settings"
84
96
  project_helper.process_shared_target_options(@shared_target_options)
data/lib/dsl.rb CHANGED
@@ -2,7 +2,7 @@ def option(name, value)
2
2
  Ambient.configure { set_option(name, value) }
3
3
  end
4
4
 
5
- def enable_warnings_and_static_analyser!
5
+ def enable_extra_warnings_and_static_analyser!
6
6
  warnings = %w(GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED
7
7
  GCC_WARN_MISSING_PARENTHESES
8
8
  GCC_WARN_ABOUT_RETURN_TYPE
@@ -31,6 +31,28 @@ def enable_warnings_and_static_analyser!
31
31
  warnings.each { |w| option(w, true) }
32
32
  end
33
33
 
34
+ def enable_default_warnings!
35
+ truthy = %w(CLANG_WARN_BOOL_CONVERSION
36
+ CLANG_WARN_CONSTANT_CONVERSION
37
+ CLANG_WARN_EMPTY_BODY
38
+ CLANG_WARN_ENUM_CONVERSION
39
+ CLANG_WARN_INT_CONVERSION
40
+ CLANG_WARN_UNREACHABLE_CODE
41
+ CLANG_WARN__DUPLICATE_METHOD_MATCH
42
+ GCC_WARN_64_TO_32_BIT_CONVERSION
43
+ GCC_WARN_UNDECLARED_SELECTOR
44
+ GCC_WARN_UNUSED_FUNCTION
45
+ GCC_WARN_UNUSED_VARIABLE)
46
+ error = %w(CLANG_WARN_DIRECT_OBJC_ISA_USAGE
47
+ CLANG_WARN_OBJC_ROOT_CLASS
48
+ GCC_WARN_ABOUT_RETURN_TYPE)
49
+ aggressive = %w(GCC_WARN_UNINITIALIZED_AUTOS)
50
+
51
+ truthy.each { |w| option(w, true) }
52
+ error.each { |w| option(w, "YES_ERROR") }
53
+ aggressive.each { |w| option(w, "YES_AGGRESSIVE") }
54
+ end
55
+
34
56
  def target(name, &block)
35
57
  TargetScope.new(name).configure(&block)
36
58
  end
@@ -39,6 +61,10 @@ def use_defaults_for_everything_not_specified_in_this_file!
39
61
  Ambient.configure { @use_defaults = true }
40
62
  end
41
63
 
64
+ def scheme(name, parent: nil, &block)
65
+ SchemeScope.new(nil, name, parent).configure(&block)
66
+ end
67
+
42
68
  class TargetScope
43
69
  attr_reader :name
44
70
 
@@ -67,7 +93,10 @@ class SchemeScope
67
93
  @parent = parent
68
94
 
69
95
  child = name
70
- Ambient.configure { set_parent_target(target.name, child, parent) }
96
+
97
+ if @target
98
+ Ambient.configure { set_parent_target(target.name, child, parent) }
99
+ end
71
100
  end
72
101
 
73
102
  def configure(&block)
@@ -79,9 +108,10 @@ class SchemeScope
79
108
  name = @name
80
109
  parent = @parent
81
110
 
82
- Ambient.configure do
83
- # require 'pry'; binding.pry
84
- set_option(option_name, value, target: target.name, scheme: name, parent: parent)
111
+ if target
112
+ Ambient.configure { set_option(option_name, value, target: target.name, scheme: name, parent: parent) }
113
+ else
114
+ Ambient.configure { set_option(option_name, value, scheme: name, parent: parent) }
85
115
  end
86
116
  end
87
117
  end
@@ -62,6 +62,17 @@ class ProjectHelper
62
62
  save_changes
63
63
  end
64
64
 
65
+ def process_scheme_options(options)
66
+ @project.build_configurations.each do |configuration|
67
+ scheme_options = options[configuration.to_s] || {}
68
+ scheme_options.each do |key, value|
69
+ configuration.build_settings[key] = value
70
+ configuration.build_settings.delete(key) if value == nil
71
+ end
72
+ end
73
+ save_changes
74
+ end
75
+
65
76
  def print_info
66
77
  puts "Targets:"
67
78
  @project.targets.each { |t| puts "- #{t.to_s}" }
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.1.0
4
+ version: 0.2.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-06-29 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -49,6 +49,7 @@ files:
49
49
  - README.md
50
50
  - ambient-xcode.gemspec
51
51
  - bin/ambient
52
+ - example/Ambientfile
52
53
  - lib/ambient.rb
53
54
  - lib/dsl.rb
54
55
  - lib/project_helper.rb