mapHeaderSearchPaths.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = headerSearchPathIter;
  6. /**
  7. * Copyright (c) Facebook, Inc. and its affiliates.
  8. *
  9. * This source code is licensed under the MIT license found in the
  10. * LICENSE file in the root directory of this source tree.
  11. *
  12. */
  13. /**
  14. * Given Xcode project and path, iterate over all build configurations
  15. * and execute func with HEADER_SEARCH_PATHS from current section
  16. *
  17. * We cannot use builtin addToHeaderSearchPaths method since react-native init does not
  18. * use $(TARGET_NAME) for PRODUCT_NAME, but sets it manually so that method will skip
  19. * that target.
  20. *
  21. * To workaround that issue and make it more bullet-proof for different names,
  22. * we iterate over all configurations and look for `lc++` linker flag to detect
  23. * React Native target.
  24. *
  25. * Important: That function mutates `buildSettings` and it's not pure thus you should
  26. * not rely on its return value
  27. */
  28. const defaultHeaderPaths = ['"$(inherited)"'];
  29. function headerSearchPathIter(project, func) {
  30. const config = project.pbxXCBuildConfigurationSection();
  31. Object.keys(config).filter(ref => ref.indexOf('_comment') === -1).forEach(ref => {
  32. const {
  33. buildSettings
  34. } = config[ref];
  35. const shouldVisitBuildSettings = (Array.isArray(buildSettings.OTHER_LDFLAGS) ? buildSettings.OTHER_LDFLAGS : []).indexOf('"-lc++"') >= 0;
  36. if (shouldVisitBuildSettings) {
  37. const searchPaths = buildSettings.HEADER_SEARCH_PATHS ? [].concat(buildSettings.HEADER_SEARCH_PATHS) : defaultHeaderPaths;
  38. buildSettings.HEADER_SEARCH_PATHS = func(searchPaths);
  39. }
  40. });
  41. }
  42. //# sourceMappingURL=mapHeaderSearchPaths.js.map