Module: CocoapodsPodfileLocal::PodsProjectIntegration

Defined in:
lib/cocoapods_podfile_local/pods_project_integration.rb

Overview

把 Podfile.local 挂到 Pods.xcodeproj 的根分组里(和 CocoaPods 自带的 Podfile 引用方式一致),这样打开 .xcworkspace 后能在 Xcode 左侧导航里直接点开编辑;若本地删掉了 Podfile.local,下次 install 会去掉引用。

Constant Summary collapse

PODFILE_RELATIVE =

Pods 工程在 ‘项目/Pods/` 下,根目录的 Podfile.local 相对路径就是上一级目录里的文件。

'../Podfile.local'

Class Method Summary collapse

Class Method Details

.register_post_install_hook!Object

向 CocoaPods 注册「安装结束后」执行的钩子;同一 Ruby 进程里只注册一次,避免重复执行。



15
16
17
18
19
20
21
22
23
# File 'lib/cocoapods_podfile_local/pods_project_integration.rb', line 15

def register_post_install_hook!
  return if @post_install_registered

  @post_install_registered = true
  # post_install 时 CocoaPods 已生成/更新完 Pods.xcodeproj,此时改工程文件是安全的。
  Pod::HooksManager.register('cocoapods-podfile-local', :post_install) do |context|
    sync_podfile_local_file_reference(context)
  end
end