module Pod class Sandbox attr_accessor :standard_sandbox def standard_sandbox_root return root if standard_sandbox.nil? standard_sandbox.root end end # The sandbox provides support for the directory that CocoaPods uses for an # installation. In this directory the Pods projects, the support files and # the sources of the Pods are stored. # # CocoaPods assumes to have control of the sandbox. # # Once completed the sandbox will have the following file structure: # # Pods # | # +-- Headers # | +-- Private # | | +-- [Pod Name] # | +-- Public # | +-- [Pod Name] # | # +-- Local Podspecs # | +-- External Sources # | +-- Normal Sources # | # +-- Target Support Files # | +-- [Target Name] # | +-- Pods-acknowledgements.markdown # | +-- Pods-acknowledgements.plist # | +-- Pods-dummy.m # | +-- Pods-prefix.pch # | +-- Pods.xcconfig # | # +-- [Pod Name] # | # +-- Manifest.lock # | # +-- Pods.xcodeproj # (if installation option 'generate_multiple_pod_projects' is enabled) # | # +-- PodTarget1.xcodeproj # | # ... # | # +-- PodTargetN.xcodeproj # # class JxedtPrebuildSandbox < Sandbox # [Pod::Sandbox] standard_sandbox def self.from_standard_sandbox(sandbox, sandbox_path: nil, real_path_compiler: false) prebuild_sandbox_path = Pathname.new(sandbox.root).realpath + '../Pods-Source' prebuild_sandbox = new(prebuild_sandbox_path) # initialize prebuild_sandbox.standard_sandbox = sandbox # prepare prebuild_sandbox.prepare_dir prebuild_sandbox end def real_path_compiler? @real_path_compiler ||= begin prebuild_sandbox_path = Jxedt.config.prebuild_sandbox_path real_path_compiler = prebuild_sandbox_path && prebuild_sandbox_path.length > 0 if real_path_compiler prebuild_sources_root = Pathname.new(prebuild_sandbox_path) prebuild_sources_root.rmtree if prebuild_sources_root.exist? prebuild_sources_root.mkpath end real_path_compiler end end def prepare_dir # clear root.children.each { |child| child.rmtree if '.xcodeproj' != child.extname } # copy standard_sandbox.root.children.each do |child| # skip headers_root & target_support_files_root & project_path should_skip_paths = [standard_sandbox.headers_root, standard_sandbox.target_support_files_root, standard_sandbox.project_path] next if should_skip_paths.include?(child) should_copy_paths = [standard_sandbox.specifications_root, standard_sandbox.manifest_path] if should_copy_paths.include?(child) # copy Local Podspecs & manifest path FileUtils.cp_r(child, root + child.basename) else # 真实的路径去编译,则拷贝文件到prebuild_sandbox FileUtils.cp_r(child, sources_root) if real_path_compiler? end end end def sources_root if real_path_compiler? # 真实的路径去编译,则返回prebuild sources root return @prebuild_sources_root ||= Pathname.new(Jxedt.config.prebuild_sandbox_path) end standard_sandbox.root end def project_path root + 'Pods-Source.xcodeproj' end def clean_source_project! return if Jxedt.config.keep_source_project? sources_root.rmtree if sources_root.exist? root.rmtree if root.exist? end end end module Pod class Installer # The {UserProjectIntegrator} integrates the libraries generated by # TargetDefinitions of the {Podfile} with their correspondent user # projects. # class UserProjectIntegrator alias_method :old_create_workspace, :create_workspace def create_workspace old_create_workspace unless sandbox.is_a?(Pod::JxedtPrebuildSandbox) end end end end