Class: Pod::Installer::Xcode::PodsProjectGenerator::PodTargetInstaller

Inherits:
TargetInstaller
  • Object
show all
Defined in:
lib/cocoapods-lhj-bin/native/pod_target_installer.rb

Overview

Creates the target for the Pods libraries in the Pods project and the relative support files.

Instance Method Summary collapse

Instance Method Details

#add_swift_library_compatibility_header_phase(native_target) ⇒ Object

[View source]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/cocoapods-lhj-bin/native/pod_target_installer.rb', line 24

def add_swift_library_compatibility_header_phase(native_target)
  UI.warn("========= swift add_swift_library_compatibility_header_phase")
  if $ARGV[1] == "auto"
    UI.warn("========= auto swift add_swift_library_compatibility_header_phase")

    if custom_module_map
      raise Informative, 'Using Swift static libraries with custom module maps is currently not supported. ' \
                       "Please build `#{target.label}` as a framework or remove the custom module map."
    end

    build_phase = native_target.new_shell_script_build_phase('Copy generated compatibility header')

    relative_module_map_path = target.module_map_path.relative_path_from(target.sandbox.root)
    relative_umbrella_header_path = target.umbrella_header_path.relative_path_from(target.sandbox.root)

    build_phase.shell_script = "    COMPATIBILITY_HEADER_PATH=\"${BUILT_PRODUCTS_DIR}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h\"\n    MODULE_MAP_PATH=\"${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap\"\n\n    ditto \"${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h\" \"${COMPATIBILITY_HEADER_PATH}\"\n    ditto \"${PODS_ROOT}/\#{relative_module_map_path}\" \"${MODULE_MAP_PATH}\"\n    ditto \"${PODS_ROOT}/\#{relative_umbrella_header_path}\" \"${BUILT_PRODUCTS_DIR}\"\n    \n    COPY_PATH=\"${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}\"\n    UMBRELLA_PATH=\"${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}-umbrella.h\"\n    SWIFTMODULE_PATH=\"${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.swiftmodule\" \n\n    ditto \"${MODULE_MAP_PATH}\" \"${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap\"\n    ditto \"${COMPATIBILITY_HEADER_PATH}\" \"${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h\"\n    ditto \"${COMPATIBILITY_HEADER_PATH}\" \"${COPY_PATH}\"\n    ditto \"${UMBRELLA_PATH}\" \"${COPY_PATH}\"\n    ditto \"${SWIFTMODULE_PATH}\" \"${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule\"\n    ditto \"${SWIFTMODULE_PATH}\" \"${COPY_PATH}/${PRODUCT_MODULE_NAME}.swiftmodule\"\n    \n    if [ ${PRODUCT_MODULE_NAME} != ${PRODUCT_NAME} ] ; then\n         ditto \"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}-umbrella.h\" \"${COPY_PATH}\"\n         ditto \"${COPY_PATH}\" \"${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_NAME}\"\n    fi\n    \n    MODULE_MAP_SEARCH_PATH = \"${PODS_CONFIGURATION_BUILD_DIR}/${PRODUCT_MODULE_NAME}/${PRODUCT_MODULE_NAME}.modulemap\"\n    \n    if [${MODULE_MAP_PATH} != ${MODULE_MAP_SEARCH_PATH}] ; then\n        printf \"\\\\n\\\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\\\n  header \\\\\"${COPY_PATH}/Swift Compatibility Header/${PRODUCT_MODULE_NAME}-Swift.h\\\\\"\\\\n  requires objc\\\\n}\\\\n\" >> \"${MODULE_MAP_SEARCH_PATH}\"\n    fi\n\n    printf \"\\\\n\\\\nmodule ${PRODUCT_MODULE_NAME}.Swift {\\\\n  header \\\\\"${COMPATIBILITY_HEADER_PATH}\\\\\"\\\\n  requires objc\\\\n}\\\\n\" >> \"${MODULE_MAP_PATH}\"\n\n    SH\n    build_phase.input_paths = %W(\n    ${DERIVED_SOURCES_DIR}/${PRODUCT_MODULE_NAME}-Swift.h\n    ${PODS_ROOT}/\#{relative_module_map_path}\n    ${PODS_ROOT}/\#{relative_umbrella_header_path}\n    )\n    build_phase.output_paths = %W(\n    ${BUILT_PRODUCTS_DIR}/${PRODUCT_MODULE_NAME}.modulemap\n    ${BUILT_PRODUCTS_DIR}/\#{relative_umbrella_header_path.basename}\n    ${BUILT_PRODUCTS_DIR}/Swift\\ Compatibility\\ Header/${PRODUCT_MODULE_NAME}-Swift.h\n  )\n  else\n    UI.warn(\"========= null swift add_swift_library_compatibility_header_phase\")\n    old_add_swift_library_compatibility_header_phase(native_target)\n  end\n\nend\n".strip_heredoc

#old_add_swift_library_compatibility_header_phaseVoid

Adds a shell script phase, intended only for library targets that contain swift, to copy the ObjC compatibility header (the -Swift.h file that the swift compiler generates) to the built products directory. Additionally, the script phase copies the module map, appending a ‘.Swift` submodule that references the (moved) compatibility header. Since the module map has been moved, the umbrella header is also copied, so that it is sitting next to the module map. This is necessary for a successful archive build.

Parameters:

  • native_target (PBXNativeTarget)

    the native target to add the Swift static library script phase into.

Returns:

  • (Void)
[View source]

22
# File 'lib/cocoapods-lhj-bin/native/pod_target_installer.rb', line 22

alias old_add_swift_library_compatibility_header_phase add_swift_library_compatibility_header_phase