krzysztofzablocki / crafter

Crafter - Xcode project configuration CLI made easy.
twitter.com/merowing_
547 stars 35 forks source link

Folder structure #16

Open ThomasGrunewald opened 9 years ago

ThomasGrunewald commented 9 years ago

Is there a way to define an initial folder structure (ViewControllers, Views, Cells etc.) for the Xcode-project?

Thank you for this great tool!

quantumarun commented 8 years ago

I am too looking for the same especially in this tool itself. One place for everything.

krzysztofzablocki commented 8 years ago

You can add arbitrary ruby code to .crafter steps, so you could potentialy create directories like this:

FileUtils.mkdir_p '/ViewControllers'
FileUtils.mkdir_p '/Models'
quantumarun commented 8 years ago

Didn't work? Execution was successful Also is there any was to set certificate and Provisional Profile for each build setting set Below is the sample build settings added to crafter.rb file

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafterDemo, :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'TEST DEBUG' }, configuration: :TEST_DEBUG)

bash-3.2# crafter duplicating configurations setting up variety of options set specified values for build settings preparing git ignore preparing pod file adding scripts Finished.

krzysztofzablocki commented 8 years ago

make sure you add require 'fileutils' to top of the file.

build settings you pasted are missing ' and are spelled incorrectly :)

as for provisioning profile you could: PROVISIONING_PROFILE=395525c8-8407-4d30-abbd-b65907223eec where the long hex number is the UUID of the profile. If you look inside a provisioning profile you'll find that most of it is ASCII, even though it's a binary file, and it has a section like this

UUID 395525c8-8407-4d30-abbd-b65907223eec

quantumarun commented 8 years ago

Still not able to create folder.

Also that build settings i edited here so missed ' :) Also where should i add this PROVISIONING_PROFILE option. It should be inside each set_build_settings. Correct me if i am wrong.

quantumarun commented 8 years ago

Any help on folder creation still not able to create folders.

quantumarun commented 8 years ago

Below is my sample crafter.rb file.

Please let me know if PROVISIONING_PROFILE is correctly added. Also i am not able to create folders.

require 'fileutils'

load "#{Crafter::ROOT}/config/default_scripts.rb"

All your configuration should happen inside configure block

Crafter.configure do

This are projects wide instructions

add_platform({:platform => :ios, :deployment => 7.0}) add_git_ignore duplicate_configurations({:TEST_DEBUG => :debug, :TEST_RELEASE => :release, :SIT_DEBUG => :debug, :SIT_RELEASE => :release, :UAT_DEBUG => :debug, :UAT_RELEASE => :release, :PROD_DEBUG => :debug, :PROD_RELEASE => :release})

set of options, warnings, static analyser and anything else normal xcode treats as build options

set_options %w( GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED GCC_WARN_MISSING_PARENTHESES GCC_WARN_ABOUT_RETURN_TYPE GCC_WARN_SIGN_COMPARE GCC_WARN_CHECK_SWITCH_STATEMENTS GCC_WARN_UNUSED_FUNCTION GCC_WARN_UNUSED_LABEL GCC_WARN_UNUSED_VALUE GCC_WARN_UNUSED_VARIABLE GCC_WARN_SHADOW GCC_WARN_64_TO_32_BIT_CONVERSION GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS GCC_WARN_UNDECLARED_SELECTOR GCC_WARN_TYPECHECK_CALLS_TO_PRINTF GCC_WARN_UNINITIALIZED_AUTOS CLANG_WARN_INT_CONVERSION CLANG_WARN_ENUM_CONVERSION CLANG_WARN_CONSTANT_CONVERSION CLANG_WARN_BOOL_CONVERSION CLANG_WARN_EMPTY_BODY CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION GCC_WARN_64_TO_32_BIT_CONVERSION

RUN_CLANG_STATIC_ANALYZER
GCC_TREAT_WARNINGS_AS_ERRORS

)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'TEST DEBUG', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :TEST_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'TEST RELEASE', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :TEST_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'SIT DEBUG', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :SIT_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'SIT RELEASE', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :SIT_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'UAT DEBUG', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :UAT_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'UAT RELEASE', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :UAT_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'PROD DEBUG', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :PROD_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.test.crafter', :'BUNLDE_DISPLAY_NAME_SUFFIX' => 'PROD RELEASE', PROVISIONING_PROFILE => xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx }, configuration: :PROD_RELEASE)

FileUtils.mkdir_p '/ViewController' FileUtils.mkdir_p '/Models' FileUtils.mkdir_p '/ExternalComponents' FileUtils.mkdir_p '/Common'

target specific options, :default is just a name for you, feel free to call it whatever you like

with :default do

# each target have set of pods
#pods << %w(NSLogger-CocoaLumberjack-connector TestFlightSDK)

# each target can have optional blocks, eg. crafter will ask you if you want to include networking with a project
#add_option :networking do
  #pods << 'AFNetworking'
#end

#add_option :coredata do
  #pods << 'MagicalRecord'
#end

# 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/
#scripts << {:name => 'icon versioning', :script => Crafter.icon_versioning_script}

# we can also execute arbitrary ruby code when configuring our projects, here we rename all our standard icon* to icon_base for versioning script
#icon_rename = proc do |file|
 # extension = File.extname(file)
 # file_name = File.basename(file, extension)
 # File.rename(file, "#{File.dirname(file)}/#{file_name}_base#{extension}")
#end

#Dir['**/Icon.png'].each(&icon_rename)
#Dir['**/Icon@2x.png'].each(&icon_rename)
#Dir['**/Icon-72.png'].each(&icon_rename)
#Dir['**/Icon-72@2x.png'].each(&icon_rename)

end

more targets setup

with :tests do

add_option :kiwi do

#  pods << 'Kiwi'
 # scripts << {:name => 'command line unit tests', :script => Crafter.command_line_test_script}
#end

end

end

ThomasGrunewald commented 8 years ago

Thanks for reply.
What I meant was the Groups-Structure in the Xcode-Project. Is there an way to predefining this structure like ViewControllers, Model, ViewModel etc. ? And than transport this structure to the project file structure (finder).

quantumarun commented 8 years ago

Hi, I have posted below my crafter.rb file. Had removed Provisional Profile and CodeSigning for security reasons. Below are the issues i am facing:

  1. Unable to create folder.
  2. For BUNDLE_ID_SUFFIX, BUNDLE_DISPLAY_NAME_SUFFIX, PROVISIONING_PROFILE its always taking values of only PROD_DEBUG and PROD_RELEASE of set_build_settings. So what ever values i am passing in TEST_DEBUG, TEST_RELEASE, SIT_DEBUG..... they are all ignored. So for all debug profiles i am getting BundleId as com.proddebug.crafter and Display Name as $(PRODUCT_NAME)_PRDD and for all release profiles its com.prodrelease.crafter and and $(PRODUCT_NAME)_PRDR
    1. Deployment target is not getting set as 7.0 its 9.1 by default as i am using Xcode7.1 beta

What am i missing here?

!/usr/bin/env ruby

require 'fileutils'

load "#{Crafter::ROOT}/config/default_scripts.rb"

All your configuration should happen inside configure block

Crafter.configure do FileUtils.mkdir_p '/Models'

This are projects wide instructions

add_platform({:platform => :ios, :deployment => 7.0}) add_git_ignore duplicate_configurations({:TEST_DEBUG => :debug, :TEST_RELEASE => :release, :SIT_DEBUG => :debug, :SIT_RELEASE => :release, :UAT_DEBUG => :debug, :UAT_RELEASE => :release, :PROD_DEBUG => :debug, :PROD_RELEASE => :release})

set of options, warnings, static analyser and anything else normal xcode treats as build options

set_options %w( GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED GCC_WARN_MISSING_PARENTHESES GCC_WARN_ABOUT_RETURN_TYPE GCC_WARN_SIGN_COMPARE GCC_WARN_CHECK_SWITCH_STATEMENTS GCC_WARN_UNUSED_FUNCTION GCC_WARN_UNUSED_LABEL GCC_WARN_UNUSED_VALUE GCC_WARN_UNUSED_VARIABLE GCC_WARN_SHADOW GCC_WARN_64_TO_32_BIT_CONVERSION GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS GCC_WARN_UNDECLARED_SELECTOR GCC_WARN_TYPECHECK_CALLS_TO_PRINTF GCC_WARN_UNINITIALIZED_AUTOS CLANG_WARN_INT_CONVERSION CLANG_WARN_ENUM_CONVERSION CLANG_WARN_CONSTANT_CONVERSION CLANG_WARN_BOOL_CONVERSION CLANG_WARN_EMPTY_BODY CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION GCC_WARN_64_TO_32_BIT_CONVERSION RUN_CLANG_STATIC_ANALYZER GCC_TREAT_WARNINGS_AS_ERRORS )

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.testdebug.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_TESTD', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :TEST_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.testrelease.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_TESTR', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :TEST_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.sitdebug.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_SITD', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :SIT_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.sitrelease.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_SITR', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :SIT_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.uatdebug.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_UATD', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :UAT_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.uatrelease.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_UATR', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :UAT_RELEASE)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.proddebug.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_PRDD', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :PROD_DEBUG)

set_build_settings({ :'BUNDLE_ID_SUFFIX' => 'com.prodrelease.crafter', :'BUNDLE_DISPLAY_NAME_SUFFIX' => '$(PRODUCT_NAME)_PRDR', :'CODE_SIGN_IDENTITY[sdk=iphoneos*]' => '', :'CODE_SIGN_IDENTITY' => '', :'PROVISIONING_PROFILE' => '' }, configuration: :PROD_RELEASE) end