3

向每个目标添加相同的 pod 是多余的。

   def RedundantPod

        pod "Pod"
    end

    target 'targetOne' do
        RedundantPod
    end

    target 'targetTwo' do
        RedundantPod
    end

以下设置引发类型错误:[ ! ] Invalid Podfile file: uninitialized constant. 这里有什么问题?

4

1 回答 1

5

对于未来的读者来说,问题来自RedundantPod不应该以大写字母开头的命名R

事实上,以大写字母开头的名称在 Ruby 中是常量。仍然可以为方法使用常量名称,但是如果没有括号,您将无法调用它,因为解释器将查找名称作为常量。

您需要显式调用该方法:

def RedundantPod
   pod "Pod"
end

target 'targetOne' do
   RedundantPod()
end

或不大写重命名:

def redundantPod
   pod "Pod"
end

target 'targetOne' do
   redundantPod
end
于 2019-06-19T13:52:47.090 回答