Merge: Nitsmell : Adding new code smells and print console updated
[nit.git] / src / platform / ios.nit
index c221598..0cb1ce0 100644 (file)
@@ -95,15 +95,22 @@ private class IOSToolchain
                        end
                end
 
-               var icon_dir = project_root / "ios" / "AppIcon.appiconset"
-               var icons_found = icon_dir.file_exists
-               if icons_found then
+               # Copy all resources
+               var app_files = [project_root]
+               app_files.add_all app_project.files
+
+               var icons_found = false
 
-                       # Prepare the `Assets.xcassets` folder
-                       var target_assets_dir = compile_dir / "Assets.xcassets"
-                       if not target_assets_dir.file_exists then target_assets_dir.mkdir
+               for path in app_files do
+                       var icon_dir = path / "ios" / "AppIcon.appiconset"
+                       if icon_dir.file_exists then
+                               icons_found = true
 
-                       """
+                               # Prepare the `Assets.xcassets` folder
+                               var target_assets_dir = compile_dir / "Assets.xcassets"
+                               if not target_assets_dir.file_exists then target_assets_dir.mkdir
+
+                               """
 {
   "info" : {
        "version" : 1,
@@ -111,9 +118,10 @@ private class IOSToolchain
   }
 }""".write_to_file target_assets_dir / "Contents.json"
 
-                       # copy the res folder to the compile dir
-                       icon_dir = icon_dir.realpath
-                       toolcontext.exec_and_check(["cp", "-R", icon_dir, target_assets_dir], "iOS project error")
+                               # copy the res folder to the compile dir
+                               icon_dir = icon_dir.realpath
+                               toolcontext.exec_and_check(["cp", "-R", icon_dir, target_assets_dir], "iOS project error")
+                       end
                end
 
                # TODO Register asset files
@@ -158,17 +166,25 @@ private class IOSToolchain
                # Compile with `xcodebuild`
                #
                # TODO support more than the iPhone and the simulator.
+               var compile_mode = if release then "Release" else "Debug"
                var args = ["sh", "-c", "cd {ios_project_root}; " +
-                       "xcodebuild -target '{project_name}' " +
+                       "xcodebuild -quiet -target '{project_name}' " +
                        "-destination 'platform=iOS Simulator,name=iPhone' " +
-                       "-configuration {if release then "Release" else "Debug"} " +
+                       "-configuration {compile_mode} " +
                         "ONLY_ACTIVE_ARCH=NO "+
                        "-sdk iphonesimulator build"]
                toolcontext.exec_and_check(args, "iOS project error")
 
                # Move compiled app to destination
-               if outfile.file_exists then outfile.rmdir
-               args = ["mv", "{ios_project_root}/build/Debug-iphonesimulator/{project_name}.app", outfile]
+               if outfile.file_exists then
+                       var error = outfile.rmdir
+                       if error != null then
+                               print_error error
+                               exit 1
+                       end
+               end
+
+               args = ["mv", "{ios_project_root}/build/{compile_mode}-iphonesimulator/{project_name}.app", outfile]
                toolcontext.exec_and_check(args, "iOS project error")
        end
 end