Bundle resources and skps directories into iOS app.

Will bundle resources/ for viewer (and skps/ if
that directory exists in the main Skia directory).
Also updates file code on iOS to fall back to bundle directory.

Docs-Preview: https://skia.org/?cl=76803
Bug: skia:7339
Change-Id: I244f67559c866451a6d02c3f1c4948d89457ec84
Reviewed-on: https://skia-review.googlesource.com/76803
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index f37f4c6..416a42d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -983,6 +983,37 @@
         ]
       }
 
+      bundle_ios_data =
+          defined(invoker.bundle_ios_data) && invoker.bundle_ios_data
+
+      if (bundle_ios_data) {
+        has_skps =
+            "True" == exec_script("//gn/checkdir.py",
+                                  [ rebase_path("skps", root_build_dir) ],
+                                  "trim string")
+        bundle_data("${app_name}_bundle_resources") {
+          sources = [
+            "resources",
+          ]
+          outputs = [
+            # iOS reserves the folders 'Resources' and 'resources' so store one level deeper
+            "{{bundle_resources_dir}}/data/resources",
+          ]
+        }
+
+        if (has_skps) {
+          bundle_data("${app_name}_bundle_skps") {
+            sources = [
+              "skps",
+            ]
+            outputs = [
+              # Store in same folder as resources
+              "{{bundle_resources_dir}}/data/skps",
+            ]
+          }
+        }
+      }
+
       executable("${app_name}_generate_executable") {
         forward_variables_from(invoker,
                                "*",
@@ -1022,6 +1053,12 @@
           ":${app_name}_bundle_executable",
           ":${app_name}_bundle_info_plist",
         ]
+        if (bundle_ios_data) {
+          deps += [ ":${app_name}_bundle_resources" ]
+          if (has_skps) {
+            deps += [ ":${app_name}_bundle_skps" ]
+          }
+        }
 
         # should only code sign when running on a device, not the simulator
         if (target_cpu != "x64") {
@@ -1747,6 +1784,9 @@
   if (skia_enable_gpu) {
     test_app("viewer") {
       is_shared_library = is_android
+      if (is_ios) {
+        bundle_ios_data = true
+      }
       sources = [
         "tools/viewer/GMSlide.cpp",
         "tools/viewer/ImageSlide.cpp",