diff --git a/.gitignore b/.gitignore index 46bbbe30f..0f84644ba 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,8 @@ *.so **/*.framework/* !**/*.framework/*.meta +**/*.framework.dSYM/* +!**/*.framework.dSYM/*.meta bazel-* diff --git a/build.py b/build.py index 5d4f2a63b..36be939d7 100644 --- a/build.py +++ b/build.py @@ -69,9 +69,13 @@ def _copy(self, source, dest, mode=0o755): self.console.v(f"Changing the mode of '{dest}'...") os.chmod(dest, mode) - def _copytree(self, source, dest): + def _copytree(self, source, dest, ignore_nonexistent_source=False): self.console.v(f"Copying '{source}' to '{dest}' recursively...") + if ignore_nonexistent_source and not os.path.exists(source): + self.console.v(f"Tried to copy '{source}', but it does not exist") + return + if not os.path.exists(dest): self.console.v(f"Creating '{dest}'...") os.makedirs(dest, 0o755) @@ -158,8 +162,15 @@ def run(self): if self.command_args.ios: self.console.info('Building native libaries for iOS...') + ios_plugin_dst = os.path.join(_BUILD_RUNTIME_PATH, 'Plugins', 'iOS') self._run_command(self._build_ios_commands()) - self._unzip(self._find_latest_built_framework(), os.path.join(_BUILD_RUNTIME_PATH, 'Plugins', 'iOS')) + self._unzip(self._find_latest_built_framework(), ios_plugin_dst) + + # Copy dSYM files if they exist (when built with `--apple_generate_dsym`) + self._copytree( + os.path.join(_BAZEL_BIN_PATH, 'mediapipe_api', 'objc', 'MediaPipeUnity.framework.dSYM'), + os.path.join(ios_plugin_dst, 'MediaPipeUnity.framework.dSYM'), + ignore_nonexistent_source=True) self.console.info('Built native libraries for iOS')