是否可以在post_install挂钩中访问我的项目的xcodeproj实例

时间:2018-10-10 20:23:38

标签: cocoapods podfile

假设我关注了Podfile。

project 'MyProject.xcodeproj'

target "MyTarget" do
  pod "..."
end

post_install do |installer|
  # I want to access to MyProject here
end

是否可以在post_install挂钩中访问“ MyProject.xcodeproj”的xcodeproj实例?我想在运行pod install之后修改一些构建步骤。

我试图在代码块中使用Xcodeproj :: Project.open,但有时project.save()不能反映我的更改。我不是100%不确定,但是看起来像save正在用cocoapod命令本身中的原始xcodeproj实例调用,这会覆盖我在块中的更改。

post_install do |installer|
  project = Xcodeproj::Project.open("MyProject.xcodeproj")
  target = project.targets.find { |target| target.name == 'MyTarget' }
  # do some modification against project file
  project.save() # this doesn't always work.
end

所以我想访问cocoapod命令包含在其中的Xcodeproj实例。

有什么想法吗?

0 个答案:

没有答案