ambient-xcode 0.5.1 → 0.6.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: 7bbb7285b674c2fb1324c0f6d6afccbac5ffd1e2
4
- data.tar.gz: a377e66021a4f78dcccf8214994824f0431e059f
3
+ metadata.gz: 71ecb6caa8059718bc5587df94fefe7a7ded74e5
4
+ data.tar.gz: ace88b9f5419157c109fe6826af14e504a6e89fb
5
5
  SHA512:
6
- metadata.gz: 34ed62a46022138cd638cadf3dcdc558a5e8d73e20d66e38c4a00c062e58d824c75d7890a6f6d0161ed236d9a5a07d9dacd5d3f44b6d254b1b658bffa934e230
7
- data.tar.gz: b2f7e2018f8ed49945969744472d3468206eda18b5246057076ede084fcce3985b3f0ba73e6e32770adb44c0c7518adfb392307fcb7fc50498d155a6d2f7b583
6
+ metadata.gz: 75d57629a7ad52ab157454e511ef074475cfb5c7e656ef58e679bd942a78fc56a15d9566d1864da252383308042e05aea388ca2f9463f4475147190d09033603
7
+ data.tar.gz: 96233c4bb64322f6aac12d535aa44d04c0233384572ee65f2c8047703ed750aff898ef3babfc18b3e0204752e808928b195807cfd21e1d75c94309e603589ac6
data/README.md CHANGED
@@ -1,20 +1,21 @@
1
1
  Ambient environment for Xcode projects
2
2
  ======================================
3
3
 
4
- Ambient lets you define all of your xcode project environment settings all in one easy to read Ruby file, and re-apply it to your Xcode project to ensure settings are correct.
4
+ Ambient lets you define all of your Xcode project environment settings all in one easy to read Ruby file, and re-apply it to your Xcode project to ensure settings are correct.
5
5
 
6
6
  An `xcconfig` file can be used in order to help abstract your settings away from the main project file. The disadvantage of `xcconfig` files though is that they can still be overridden by settings defined in the project. Ambient doesn't have this issue as it simply overwrites the values in the project file.
7
7
 
8
+
8
9
  Installation
9
10
  ============
10
11
 
11
12
  Simply run:
12
- ```
13
+ ```bash
13
14
  gem install ambient-xcode
14
15
  ```
15
16
 
16
17
  Or if you use Bundler, add the following to your `Gemfile`:
17
- ```
18
+ ```ruby
18
19
  gem "ambient-xcode"
19
20
  ```
20
21
 
@@ -25,13 +26,7 @@ Create an `Ambientfile` defining your project in the same directory as your `*.x
25
26
 
26
27
  Here's a sample of the `Ambientfile` structure:
27
28
  ```ruby
28
- enable_default_warnings!
29
- use_defaults_for_everything_not_specified_in_this_file!
30
-
31
- option "IPHONEOS_DEPLOYMENT_TARGET", "7.0"
32
- option "SDKROOT", "iphoneos"
33
- option "CLANG_ENABLE_OBJC_ARC", true
34
- option "CLANG_ENABLE_MODULES", true
29
+ base_ios_settings! "MyProject"
35
30
 
36
31
  target "MyProject" do
37
32
  capability :healthkit
@@ -42,17 +37,17 @@ target "MyProject" do
42
37
  option "BUNDLE_DISPLAY_NAME_SUFFIX", "uk.danielgreen.MyProject"
43
38
  end
44
39
  end
45
- ```
46
40
 
47
- Name of the constant that can be used as an option is located in the **Quick Settings**
48
- ![Constants](example/images/Constant.png)
41
+ plist("MyProject/Info.plist") do
42
+ entry "LSApplicationQueriesSchemes", [ "dbapi-2", "dbapi-8-emm"]
43
+ end
44
+ ```
49
45
 
50
46
  Run `ambient` from the command line to write your settings into your project.
51
47
 
52
- The [example Ambientfile](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile) or [example Ambientfile-swift](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile-swift) matches the exact settings of a new iOS project.
48
+ If you want, you can have a multiple `Ambientfile` for the same project. Just name it something else and run `ambient [filename]` (e.g. `ambient Ambientfile-enterprise`)
53
49
 
54
- If for any reason you want multiple Ambientfile (maybe for example if you wanted different capabilities for an Enterprise build vs an AppStore build), you can:
55
- ```
50
+ ```ruby
56
51
  use_settings_from 'Ambientfile' # inherits all of the settings from Ambientfile
57
52
 
58
53
  target "Monies" do
@@ -61,14 +56,15 @@ target "Monies" do
61
56
  end
62
57
  ```
63
58
 
64
- Just run `ambient [filename]` (e.g. `ambient Ambientfile-enterprise`)
65
59
 
66
60
  Notes
67
61
  =====
68
62
 
63
+ - The [example Ambientfile](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile) or [example Ambientfile-objc](https://github.com/Dan2552/ambient-xcode/blob/master/example/Ambientfile-objc) matches the exact settings of a new iOS project.
69
64
  - Use the `use_defaults_for_everything_not_specified_in_this_file!` setting to ensure your project file is clean. Warning though: this setting will clear all your targets' settings, so be sure to define absolutely every setting in the `Ambientfile` if you want to use this.
70
65
  - When defining settings directly within a target, the setting is set to each scheme.
71
-
66
+ - The name of the constants used for `option` is located in the **Quick Help** section in Xcode
67
+ ![Constants](example/images/Constant.png)
72
68
 
73
69
  Possible future features
74
70
  ========================
@@ -77,6 +73,4 @@ Possible future features
77
73
  - Helper method to change build phases to default
78
74
  - Version number + build number
79
75
  - Provisioning profiles from searching by name rather than storing a uuid (so it actually works across teams)
80
- - `Info.plist` definitions
81
- - ?
82
76
  - Ability to not have to commit `*.xcodeproj` into version control (maybe too far?)
@@ -3,8 +3,8 @@ $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.5.1'
7
- gem.authors = ['Daniel Green']
6
+ gem.version = '0.6.0'
7
+ gem.authors = ['Daniel Inkpen']
8
8
  gem.email = ['dan2552@gmail.com']
9
9
  gem.description = %q{CLI for configuring Xcode projects from a Ruby file.}
10
10
  gem.summary = %q{Define your envrionment settings all in one easy to read Ruby file, and re-apply it to your Xcode project to ensure settings are correct.}
@@ -12,6 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.license = 'MIT'
13
13
 
14
14
  gem.add_dependency 'xcodeproj', '~> 1.1.0'
15
+ gem.add_dependency 'plist', '~> 3.2.0'
15
16
 
16
17
  gem.files = `git ls-files`.split($/)
17
18
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
data/example/Ambientfile CHANGED
@@ -1,63 +1,7 @@
1
- PROJECT = "MyProject"
1
+ PROJECT = "EmptyProject"
2
2
  PREFIX = "uk.danielgreen."
3
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
4
+ base_ios_settings! PROJECT,
5
+ prefix: PREFIX,
6
+ tests: true,
7
+ ui_tests: true
@@ -0,0 +1,8 @@
1
+ PROJECT = "EmptyProject"
2
+ PREFIX = "uk.danielgreen."
3
+
4
+ base_ios_settings! PROJECT,
5
+ prefix: PREFIX,
6
+ tests: true,
7
+ ui_tests: true,
8
+ swift: false
@@ -1,6 +1,3 @@
1
- PROJECT = "EmptySwiftProject"
2
- PREFIX = "uk.danielgreen."
3
-
4
1
  use_defaults_for_everything_not_specified_in_this_file!
5
2
  enable_default_warnings!
6
3
 
data/lib/ambient.rb CHANGED
@@ -8,6 +8,7 @@ end
8
8
 
9
9
  require_relative 'project_helper'
10
10
  require_relative 'capabilities_helper'
11
+ require_relative 'plist_helper'
11
12
  require_relative 'dsl'
12
13
 
13
14
  module Ambient
@@ -151,7 +152,7 @@ module Ambient
151
152
  end
152
153
 
153
154
  def run_ambientfile(filename)
154
- puts "Reading settings from #{filename}"
155
+ puts "# Reading settings from #{filename}"
155
156
  ambient = File.join(Dir.pwd, filename)
156
157
  raise "#{filename} not found in current directory." unless File.exists?(ambient)
157
158
  load ambient
data/lib/dsl.rb CHANGED
@@ -6,6 +6,80 @@ def option(name, value)
6
6
  Ambient.configure { set_option(name, value) }
7
7
  end
8
8
 
9
+ def base_ios_settings!(project_name, prefix: "", tests: false, ui_tests: false, swift: true, target: nil, test_target: nil, ui_test_target: nil)
10
+ use_defaults_for_everything_not_specified_in_this_file!
11
+ enable_default_warnings!
12
+
13
+ target ||= "project_name"
14
+ test_target ||= "#{project_name}Tests"
15
+ ui_test_target ||= "#{project_name}UITests"
16
+ tests = true if test_target
17
+ ui_tests = true if ui_test_target
18
+
19
+ option "ALWAYS_SEARCH_USER_PATHS", false
20
+ option "CLANG_CXX_LANGUAGE_STANDARD", "gnu++0x"
21
+ option "CLANG_CXX_LIBRARY", "libc++"
22
+ option "CLANG_ENABLE_MODULES", true
23
+ option "CLANG_ENABLE_OBJC_ARC", true
24
+
25
+ option "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Developer"
26
+ option "COPY_PHASE_STRIP", false
27
+
28
+ option "ENABLE_STRICT_OBJC_MSGSEND", true
29
+ option "GCC_C_LANGUAGE_STANDARD", "gnu99"
30
+ option "GCC_NO_COMMON_BLOCKS", true
31
+ option "SDKROOT", "iphoneos"
32
+ option "IPHONEOS_DEPLOYMENT_TARGET", "9.0"
33
+
34
+ scheme "Debug" do
35
+ option "DEBUG_INFORMATION_FORMAT", "dwarf"
36
+ option "ENABLE_TESTABILITY", true
37
+ option "MTL_ENABLE_DEBUG_INFO", true
38
+ option "ONLY_ACTIVE_ARCH", true
39
+ option "GCC_DYNAMIC_NO_PIC", false
40
+ option "GCC_OPTIMIZATION_LEVEL", "0"
41
+ option "GCC_PREPROCESSOR_DEFINITIONS", ["DEBUG=1", "$(inherited)"]
42
+ option "SWIFT_OPTIMIZATION_LEVEL", "-Onone" if swift
43
+ end
44
+
45
+ scheme "Release" do
46
+ option "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"
47
+ option "ENABLE_NS_ASSERTIONS", false
48
+ option "MTL_ENABLE_DEBUG_INFO", false
49
+ option "VALIDATE_PRODUCT", true
50
+ end
51
+
52
+ target project_name do
53
+ option "INFOPLIST_FILE", "#{project_name}/Info.plist"
54
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}"
55
+ option "ASSETCATALOG_COMPILER_APPICON_NAME", "AppIcon"
56
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks"
57
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
58
+ end
59
+
60
+ if tests
61
+ target test_target do
62
+ option "INFOPLIST_FILE", "#{project_name}Tests/Info.plist"
63
+ option "BUNDLE_LOADER", "$(TEST_HOST)"
64
+ option "TEST_HOST", "$(BUILT_PRODUCTS_DIR)/#{project_name}.app/#{project_name}"
65
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}Tests"
66
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
67
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
68
+ end
69
+ end
70
+
71
+ if ui_tests
72
+ target ui_test_target do
73
+ option "INFOPLIST_FILE", "#{project_name}UITests/Info.plist"
74
+ option "TEST_TARGET_NAME", "#{project_name}"
75
+ option "PRODUCT_BUNDLE_IDENTIFIER", "#{prefix}#{project_name}UITests"
76
+ option "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"
77
+ option "USES_XCTRUNNER", "YES"
78
+ option "PRODUCT_NAME", "$(TARGET_NAME)"
79
+ end
80
+ end
81
+ end
82
+
9
83
  def enable_extra_warnings_and_static_analyser!
10
84
  warnings = %w(GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED
11
85
  GCC_WARN_MISSING_PARENTHESES
@@ -69,6 +143,26 @@ def scheme(name, parent: nil, &block)
69
143
  SchemeScope.new(nil, name, parent).configure(&block)
70
144
  end
71
145
 
146
+ def plist(path, &block)
147
+ PlistScope.new(path).configure(&block)
148
+ end
149
+
150
+ class PlistScope
151
+ attr_reader :helper
152
+
153
+ def initialize(path)
154
+ @helper = PlistHelper.new(path)
155
+ end
156
+
157
+ def configure(&block)
158
+ instance_eval(&block)
159
+ end
160
+
161
+ def entry(key, value)
162
+ helper.add_entry(key, value)
163
+ end
164
+ end
165
+
72
166
  class TargetScope
73
167
  attr_reader :name
74
168
 
@@ -0,0 +1,29 @@
1
+ require 'plist'
2
+
3
+ class PlistHelper
4
+ attr_reader :path
5
+
6
+ def initialize(path)
7
+ @path = path
8
+ end
9
+
10
+ def add_entry(key, value)
11
+ plist_as_dictionary[key] = value
12
+ puts "applying to plist: #{path} #{key}"
13
+ save
14
+ end
15
+
16
+ private
17
+
18
+ def plist_as_dictionary
19
+ @plist_as_dictionary ||= Plist::parse_xml(path)
20
+ end
21
+
22
+ def to_plist
23
+ plist_as_dictionary.to_plist
24
+ end
25
+
26
+ def save
27
+ File.open(path, 'w') { |file| file.write(to_plist) }
28
+ end
29
+ end
@@ -96,6 +96,7 @@ class ProjectHelper
96
96
  end
97
97
 
98
98
  def print_info
99
+ puts ""
99
100
  puts "Targets:"
100
101
  @project.targets.each { |t| puts "- #{t.to_s}" }
101
102
  puts ""
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.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
- - Daniel Green
7
+ - Daniel Inkpen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: plist
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.0
27
41
  description: CLI for configuring Xcode projects from a Ruby file.
28
42
  email:
29
43
  - dan2552@gmail.com
@@ -36,11 +50,13 @@ files:
36
50
  - ambient-xcode.gemspec
37
51
  - bin/ambient
38
52
  - example/Ambientfile
39
- - example/Ambientfile-swift
53
+ - example/Ambientfile-objc
54
+ - example/Ambientfile-verbose
40
55
  - example/images/Constant.png
41
56
  - lib/ambient.rb
42
57
  - lib/capabilities_helper.rb
43
58
  - lib/dsl.rb
59
+ - lib/plist_helper.rb
44
60
  - lib/project_helper.rb
45
61
  homepage: https://github.com/Dan2552/ambient
46
62
  licenses: