From 5f5fbca0c83281fa56d706bb1304a3679b94dacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Fri, 21 Mar 2014 17:07:53 +0100 Subject: [PATCH] [iOS] Fail build if one of the resources is a dir called `Resources'. Fixes http://hipbyte.myjetbrains.com/youtrack/issue/RM-450. --- lib/motion/project/template/ios.rb | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/motion/project/template/ios.rb b/lib/motion/project/template/ios.rb index 061cbc11..d6d785c8 100644 --- a/lib/motion/project/template/ios.rb +++ b/lib/motion/project/template/ios.rb @@ -40,21 +40,36 @@ desc "Build everything" task :build => ['build:simulator', 'build:device'] namespace :build do - desc "Build the simulator version" - task :simulator do + def pre_build_actions(platform) # TODO: Ensure Info.plist gets regenerated on each build so it has ints for # Instruments and strings for normal builds. - rm_f File.join(App.config.app_bundle('iPhoneSimulator'), 'Info.plist') + rm_f File.join(App.config.app_bundle(platform), 'Info.plist') + # TODO this should go into a iOS specific Builder class which performs this + # check before building. + App.config.resources_dirs.each do |dir| + Dir.entries(dir).grep(/Resources/i).each do |basename| + path = File.join(dir, basename) + if File.directory?(path) + suggestion = basename == 'Resources' ? 'Assets' : 'assets' + App.fail "An iOS application cannot be installed if it contains a " \ + "directory called `resources'. Please rename the " \ + "directory at path `#{path}' to, for instance, " \ + "`#{File.join(dir, suggestion)}'." + end + end + end + end + + desc "Build the simulator version" + task :simulator do + pre_build_actions('iPhoneSimulator') App.build('iPhoneSimulator') end desc "Build the device version" task :device do - # TODO: Ensure Info.plist gets regenerated on each build so it has ints for - # Instruments and strings for normal builds. - rm_f File.join(App.config.app_bundle('iPhoneOS'), 'Info.plist') - + pre_build_actions('iPhoneOS') App.build('iPhoneOS') App.codesign('iPhoneOS') end