向每个目标添加相同的 Pod 是多余的。
def RedundantPod
pod "Pod"
end
target 'targetOne' do
RedundantPod
end
target 'targetTwo' do
RedundantPod
end
以下设置引发类型错误:[ ! ] Invalid Podfile file: uninitialized constant
。这是怎么回事?
对于未来的读者来说,问题来自命名RedundantPod
不应该以大写R
开头。
事实上,以大写字母开头的名称在 Ruby 中是常量。仍然可以为方法使用常量名称,但如果没有括号,您将无法调用它,因为交互器将查找该名称作为常量。
您需要显式调用该方法:
def RedundantPod
pod "Pod"
end
target 'targetOne' do
RedundantPod()
end
或不带大写字母重命名:
def redundantPod
pod "Pod"
end
target 'targetOne' do
redundantPod
end