crafter 0.1.3 → 0.1.4.1

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: bbdb5f063d5cc6d04ebeffe0f6c32eb57e2160cc
4
- data.tar.gz: abb7df528cb65029514055dc36b09be28eb0d186
3
+ metadata.gz: 068142308dca128dc9e38a30d943e3e2c7c32bbb
4
+ data.tar.gz: e9da89b46eff01cdd604570b0c4915f3d5fb5323
5
5
  SHA512:
6
- metadata.gz: 673e2a03b87918de15a1e14a2fd7bd9a10192041ac95fb7576bbab29d85af5dfe2ec26c799c430a61adea569f6c09a299c2a2a83796999fc6fe33431ef5ef253
7
- data.tar.gz: e604ef305fb4c6029057a094cf7215f50bd618c01ce1371739ad1f2f6a840c548ef0842db6e066d6e0d7472ca983d79de3481c37cc538469c97a57bf9d4dd7ed
6
+ metadata.gz: 9713ca76924b080d84954966219f3b62778f3d92f08aeadcdd23bba36787a8ffe63533db003bcb2e5f51c28e827fb557426dc523cdd1aaf6110faa5aa75a4550
7
+ data.tar.gz: c6ae2290717ac13c4ff46a94f5217c66403e6465963fb85e6bca7b61fd342b8e77fa9aff4b370ae83ea9be90edf91fa0b78d718f7bb78e18bec94b913ddc200b
@@ -0,0 +1,152 @@
1
+ How do you setup your Cocoa projects? Do you always set same warnings, clone configurations and do bunch of other stuff? Or maybe you work in a big company and you are missing some standardised setup?
2
+
3
+ Programmers tend to automatise boring and repetitive tasks, yet I often see people spending time and time again configuring their Xcode Projects, even thought they always set it up same way.
4
+
5
+ We all know that Xcode templating system is far from perfect, beside we often use different templates, but same level of warnings, scripts etc.
6
+
7
+ What if you could define your project setup once (even with optional stuff) then just apply that to all your projects?
8
+
9
+ ## Enter crafter
10
+ That's why I've created **crafter**, a ruby gem that you can install, setup your configuration once and enjoy hours of time saved.
11
+
12
+ ### So how does it work?
13
+ Install it by calling:
14
+ ```
15
+ gem install crafter
16
+ crafter reset
17
+ ```
18
+ this will create your personal configuration file at **~/.crafter.rb**
19
+
20
+ now open that file with your favourite editor and you will see default configuration, along with description of different parts:
21
+
22
+
23
+ ```ruby
24
+ load "#{Crafter::ROOT}/config/default_scripts.rb"
25
+
26
+ # All your configuration should happen inside configure block
27
+ Crafter.configure do
28
+
29
+ # This are projects wide instructions
30
+ add_platform({:platform => :ios, :deployment => 6.0})
31
+ add_git_ignore
32
+ duplicate_configurations({:adhoc => :debug, :profiling => :debug})
33
+
34
+ # set of options, warnings, static analyser and anything else normal xcode treats as build options
35
+ set_options %w(
36
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED
37
+ GCC_WARN_MISSING_PARENTHESES
38
+ GCC_WARN_ABOUT_RETURN_TYPE
39
+ GCC_WARN_SIGN_COMPARE
40
+ GCC_WARN_CHECK_SWITCH_STATEMENTS
41
+ GCC_WARN_UNUSED_FUNCTION
42
+ GCC_WARN_UNUSED_LABEL
43
+ GCC_WARN_UNUSED_VALUE
44
+ GCC_WARN_UNUSED_VARIABLE
45
+ GCC_WARN_SHADOW
46
+ GCC_WARN_64_TO_32_BIT_CONVERSION
47
+ GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS
48
+ GCC_WARN_UNDECLARED_SELECTOR
49
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF
50
+
51
+ RUN_CLANG_STATIC_ANALYZER
52
+ GCC_TREAT_WARNINGS_AS_ERRORS
53
+ )
54
+
55
+ # set non boolean options
56
+ set_build_settings ({
57
+ :'OTHER_CFLAGS' => '-Wall'
58
+ })
59
+
60
+ # target specific options, :default is just a name for you, feel free to call it whatever you like
61
+ with :default do
62
+
63
+ # each target have set of pods
64
+ pods << %w(NSLogger-CocoaLumberjack-connector TestFlightSDK)
65
+
66
+ # each target can have optional blocks, eg. crafter will ask you if you want to include networking with a project
67
+ add_option :networking do
68
+ pods << 'AFNetworking'
69
+ end
70
+
71
+ add_option :coredata do
72
+ pods << 'MagicalRecord'
73
+ end
74
+
75
+ # each target can have shell scripts added, in this example we are adding my icon versioning script as in http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/
76
+ scripts << {:name => 'icon versioning', :script => Crafter.icon_versioning_script}
77
+
78
+ # we can also execute arbitrary ruby code when configuring our projects, here we rename all our standard icon* to icon_base for versioning script
79
+ icon_rename = proc do |file|
80
+ extension = File.extname(file)
81
+ file_name = File.basename(file, extension)
82
+ File.rename(file, "#{File.dirname(file)}/#{file_name}_base#{extension}")
83
+ end
84
+
85
+ Dir['**/Icon.png'].each(&icon_rename)
86
+ Dir['**/Icon@2x.png'].each(&icon_rename)
87
+ Dir['**/Icon-72.png'].each(&icon_rename)
88
+ Dir['**/Icon-72@2x.png'].each(&icon_rename)
89
+ end
90
+
91
+ # more targets setup
92
+ with :tests do
93
+ add_option :kiwi do
94
+ pods << 'Kiwi'
95
+ scripts << {:name => 'command line unit tests', :script => Crafter.command_line_test_script}
96
+ end
97
+ end
98
+ end
99
+ ```
100
+
101
+ As you can see the configuration files is quite easy, yet is pretty flexible.
102
+ Once you set it up as you see fit, go to your project folder (the one with xcodeproj, workspace etc.) and call:
103
+
104
+ ```bash
105
+ crafter
106
+ ```
107
+
108
+ it will guide you through project setup, with default configuration it would look like this:
109
+ ```bash
110
+ 1. sample
111
+ 2. sampleTests
112
+ Which target should I use for default?
113
+ 1
114
+ 1. sample
115
+ 2. sampleTests
116
+ Which target should I use for tests?
117
+ 2
118
+ do you want to add networking? [Yn]
119
+ n
120
+ do you want to add coredata? [Yn]
121
+ y
122
+ do you want to add testing? [Yn]
123
+ n
124
+ duplicating configurations
125
+ setting up variety of options
126
+ preparing git ignore
127
+ preparing pod file
128
+ adding scripts
129
+ Finished.
130
+ ```
131
+
132
+ Now your project should have all options applied, generated Podfile (call pod install or set it up in your configuration).
133
+
134
+ I'm learning Ruby, so I'm looking forward to pull requests on [GitHub][5]
135
+
136
+ Send me your thoughts, I'm [merowing_ on twitter][7]
137
+
138
+ #### Acknowledgements:
139
+
140
+ [The App Business][1] (the company I worked for) for supporting my idea.
141
+
142
+ to [@alloy][2], [@orta][3], [@romainbriche][4] - for taking some of their valuable time and sharing their thoughts about beta version.
143
+
144
+ Inspired by [liftoff][6]
145
+
146
+ [1]: http://theappbusiness.com
147
+ [2]: http://twitter.com/alloy
148
+ [3]: http://twitter.com/orta
149
+ [4]: http://twitter.com/romainbriche
150
+ [5]: https://github.com/krzysztofzablocki/crafter
151
+ [6]: https://github.com/thoughtbot/liftoff
152
+ [7]: http://twitter.com/merowing_
@@ -6,7 +6,7 @@ $:.push File.expand_path("../../lib", __FILE__)
6
6
  if ARGV[0] == 'reset'
7
7
  puts 'reseting to default setup in ~/.crafter.rb'
8
8
  root = File.expand_path('.', File.dirname(__FILE__))
9
- FileUtils.cp("#{root}/../lib/config/default.rb", File.join(Dir.home, '.crafter.rb'))
9
+ FileUtils.cp("#{root}/../lib/config/default.rb", File.join(ENV['HOME'], '.crafter.rb'))
10
10
  exit(0)
11
11
  end
12
12
 
@@ -3,12 +3,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = 'crafter'
6
- gem.version = '0.1.3'
6
+ gem.version = '0.1.4.1'
7
7
  gem.authors = ['Krzysztof Zabłocki']
8
8
  gem.email = ['merowing2@gmail.com']
9
9
  gem.description = %q{CLI for setting up new Xcode projects. Inspired by thoughtbot liftoff.}
10
10
  gem.summary = %q{Define your craft rules once, then apply it to all your Xcode projects.}
11
11
  gem.homepage = 'https://github.com/krzysztofzablocki/crafter'
12
+ gem.license = 'MIT'
12
13
 
13
14
  gem.add_dependency 'xcodeproj', '~> 0.5.5'
14
15
  gem.add_dependency 'highline', '~> 1.6'
@@ -17,4 +18,4 @@ Gem::Specification.new do |gem|
17
18
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
20
  gem.require_paths = ['lib']
20
- end
21
+ end
@@ -2,6 +2,7 @@ load "#{Crafter::ROOT}/config/default_scripts.rb"
2
2
 
3
3
  # All your configuration should happen inside configure block
4
4
  Crafter.configure do
5
+
5
6
  # This are projects wide instructions
6
7
  add_platform({:platform => :ios, :deployment => 6.0})
7
8
  add_git_ignore
@@ -23,6 +24,14 @@ Crafter.configure do
23
24
  GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS
24
25
  GCC_WARN_UNDECLARED_SELECTOR
25
26
  GCC_WARN_TYPECHECK_CALLS_TO_PRINTF
27
+ GCC_WARN_UNINITIALIZED_AUTOS
28
+ CLANG_WARN_INT_CONVERSION
29
+ CLANG_WARN_ENUM_CONVERSION
30
+ CLANG_WARN_CONSTANT_CONVERSION
31
+ CLANG_WARN_BOOL_CONVERSION
32
+ CLANG_WARN_EMPTY_BODY
33
+ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION
34
+ GCC_WARN_64_TO_32_BIT_CONVERSION
26
35
 
27
36
  RUN_CLANG_STATIC_ANALYZER
28
37
  GCC_TREAT_WARNINGS_AS_ERRORS
@@ -30,6 +39,7 @@ Crafter.configure do
30
39
 
31
40
  # target specific options, :default is just a name for you, feel free to call it whatever you like
32
41
  with :default do
42
+
33
43
  # each target have set of pods
34
44
  pods << %w(NSLogger-CocoaLumberjack-connector TestFlightSDK)
35
45
 
@@ -43,7 +53,7 @@ Crafter.configure do
43
53
  end
44
54
 
45
55
  # each target can have shell scripts added, in this example we are adding my icon versioning script as in http://www.merowing.info/2013/03/overlaying-application-version-on-top-of-your-icon/
46
- scripts << {:name => 'icon versioning', :script => @icon_versioning_script}
56
+ scripts << {:name => 'icon versioning', :script => Crafter.icon_versioning_script}
47
57
 
48
58
  # we can also execute arbitrary ruby code when configuring our projects, here we rename all our standard icon* to icon_base for versioning script
49
59
  icon_rename = proc do |file|
@@ -62,7 +72,7 @@ Crafter.configure do
62
72
  with :tests do
63
73
  add_option :kiwi do
64
74
  pods << 'Kiwi'
65
- scripts << {:name => 'command line unit tests', :script => @command_line_test_script}
75
+ scripts << {:name => 'command line unit tests', :script => Crafter.command_line_test_script}
66
76
  end
67
77
  end
68
78
  end
@@ -1,6 +1,8 @@
1
1
  module Crafter
2
2
  extend self
3
3
 
4
+ attr_reader :icon_versioning_script, :command_line_test_script
5
+
4
6
  @icon_versioning_script = %q[
5
7
  commit=`git rev-parse --short HEAD`
6
8
  branch=`git rev-parse --abbrev-ref HEAD`
@@ -9,27 +11,31 @@ version=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}"`
9
11
  function processIcon() {
10
12
  export PATH=$PATH:/usr/local/bin
11
13
  base_file=$1
12
- if [ ! -f $base_file ]; then return; fi
14
+ base_path=`find ${SRCROOT} -name $base_file`
15
+
16
+ if [[ ! -f ${base_path} || -z ${base_path} ]]; then
17
+ return;
18
+ fi
13
19
 
14
20
  target_file=`echo $base_file | sed "s/_base//"`
15
21
  target_path="${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${target_file}"
16
22
 
17
23
  if [ $CONFIGURATION = "Release" ]; then
18
- cp ${base_file} $target_path
19
- return
24
+ cp ${base_file} $target_path
25
+ return
20
26
  fi
21
27
 
22
- width=`identify -format %w ${base_file}`
28
+ width=`identify -format %w ${base_path}`
23
29
 
24
30
  convert -background '#0008' -fill white -gravity center -size ${width}x40\
25
- caption:"${version} ${branch} ${commit}"\
26
- ${base_file} +swap -gravity south -composite ${target_path}
31
+ caption:"${version} ${branch} ${commit}"\
32
+ ${base_path} +swap -gravity south -composite ${target_path}
27
33
  }
28
34
 
29
35
  processIcon "Icon_base.png"
30
- processIcon "Icon_base@2x.png"
31
- processIcon "Icon_base~iPad.png"
32
- processIcon "Icon_base@2x~iPad.png"
36
+ processIcon "Icon@2x_base.png"
37
+ processIcon "Icon-72_base.png"
38
+ processIcon "Icon-72@2x_base.png"
33
39
  ]
34
40
 
35
41
 
@@ -17,6 +17,7 @@ module Crafter
17
17
  @targets = {}
18
18
  @add_git_ignore = false
19
19
  @platforms = []
20
+ @build_settings = {}
20
21
 
21
22
  def configure(&block)
22
23
  instance_eval &block
@@ -54,10 +55,15 @@ module Crafter
54
55
  @options = options
55
56
  end
56
57
 
58
+ def set_build_settings(build_settings, configuration: 'crafter_common')
59
+ @build_settings[configuration] = build_settings
60
+ end
61
+
57
62
  def setup_project
58
63
  process_optional()
59
- process_configurations() unless @configuration.empty?
60
- process_options() unless @options.empty?
64
+ process_configurations() if @configuration && !@configuration.empty?
65
+ process_options() if @options && !@options.empty?
66
+ process_build_settings() if @build_settings && !@build_settings.empty?
61
67
  process_git() if @add_git_ignore
62
68
  process_pods()
63
69
  process_scripts()
@@ -77,6 +83,11 @@ module Crafter
77
83
  self.project.enable_options(@options)
78
84
  end
79
85
 
86
+ def process_build_settings
87
+ puts 'set specified values for build settings'
88
+ self.project.set_build_settings(@build_settings)
89
+ end
90
+
80
91
  def process_git
81
92
  puts 'preparing git ignore'
82
93
  GitHelper.new.generate_files
@@ -108,7 +119,7 @@ module Crafter
108
119
  @targets.each { |_, v| v.process_scripts(self.project) }
109
120
  end
110
121
 
111
- if File.exists?(File.join(Dir.home, '.crafter.rb')) then
122
+ if File.exists?(File.join(ENV['HOME'], '.crafter.rb')) then
112
123
  load '~/.crafter.rb'
113
124
  else
114
125
  load "#{Crafter::ROOT}/config/default.rb"
@@ -17,6 +17,19 @@ class ProjectHelper
17
17
  save_changes
18
18
  end
19
19
 
20
+ def set_build_settings(build_settings)
21
+ @project.build_configurations.each do |configuration|
22
+ build_settings.each do |configuration_name, settings|
23
+ if configuration_name.to_s.downcase == "crafter_common" || configuration.name.downcase == configuration_name.to_s.downcase
24
+ settings.each do |key, value|
25
+ configuration.build_settings[key] = value
26
+ end
27
+ end
28
+ end
29
+ end
30
+ save_changes
31
+ end
32
+
20
33
  def add_shell_script(target, name, script)
21
34
  if target.shell_script_build_phases.to_a.index { |phase| phase.name == name }
22
35
  puts "Skipping adding \"#{name}\" script for target #{target} as it already exist"
@@ -17,7 +17,7 @@ class TargetConfiguration
17
17
  def process_optional
18
18
  @options.each do |key, obj|
19
19
  key_string = key.to_s
20
- if ask_question "do you want to add #{key_string}? [Yn]"
20
+ if ask_question "do you want to add #{key_string}? [y/n]"
21
21
  raise unless obj.is_a? Proc
22
22
  obj.call()
23
23
  end
@@ -26,7 +26,7 @@ class TargetConfiguration
26
26
 
27
27
  def write_pods(f)
28
28
  return if @pods.empty?
29
- f.puts "target :#{@target.name}, :exclusive => true do"
29
+ f.puts "target '#{@target.name}', :exclusive => true do"
30
30
  pods.flatten.each do |pod|
31
31
  f.puts " pod '#{pod}'"
32
32
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crafter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Zabłocki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-02 00:00:00.000000000 Z
11
+ date: 2014-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.5.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: highline
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  description: CLI for setting up new Xcode projects. Inspired by thoughtbot liftoff.
@@ -46,14 +46,7 @@ executables:
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
- - .idea/.name
50
- - .idea/encodings.xml
51
- - .idea/misc.xml
52
- - .idea/modules.xml
53
- - .idea/scopes/scope_settings.xml
54
- - .idea/takeoff.iml
55
- - .idea/vcs.xml
56
- - .idea/workspace.xml
49
+ - README.md
57
50
  - bin/crafter
58
51
  - craft.gemspec
59
52
  - lib/config/default.rb
@@ -63,7 +56,8 @@ files:
63
56
  - lib/project_helper.rb
64
57
  - lib/target_configuration.rb
65
58
  homepage: https://github.com/krzysztofzablocki/crafter
66
- licenses: []
59
+ licenses:
60
+ - MIT
67
61
  metadata: {}
68
62
  post_install_message:
69
63
  rdoc_options: []
@@ -71,18 +65,19 @@ require_paths:
71
65
  - lib
72
66
  required_ruby_version: !ruby/object:Gem::Requirement
73
67
  requirements:
74
- - - '>='
68
+ - - ">="
75
69
  - !ruby/object:Gem::Version
76
70
  version: '0'
77
71
  required_rubygems_version: !ruby/object:Gem::Requirement
78
72
  requirements:
79
- - - '>='
73
+ - - ">="
80
74
  - !ruby/object:Gem::Version
81
75
  version: '0'
82
76
  requirements: []
83
77
  rubyforge_project:
84
- rubygems_version: 2.0.2
78
+ rubygems_version: 2.2.2
85
79
  signing_key:
86
80
  specification_version: 4
87
81
  summary: Define your craft rules once, then apply it to all your Xcode projects.
88
82
  test_files: []
83
+ has_rdoc: