在 xcode 中修改现有的 pod

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28625579/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:41:43  来源:igfitidea点击:

Modify existing pod in xcode

iosobjective-cxcodecocoapods

提问by Luca Davanzo

Working on a project in Xcode, I need to importa project class header in a pod class.

在 Xcode 中处理一个项目,我需要在 pod 类中导入一个项目类头。

Obviously if I use:

显然,如果我使用:

#import "MyProjectClass.h" 

fails. Where I have to specify path?

失败。我必须在哪里指定路径?

回答by rckoenes

You should not do it this way, you should just extend the class from the pod you are using your project and add the necessary change in the derived class.

你不应该这样做,你应该从你正在使用项目的 pod 中扩展类,并在派生类中添加必要的更改。

回答by Andrew Schreiber

Pods should not be directly edited, as any subsequent 'pod install' will wipe out your changes. As stated by rckoenes the easiest approach is to subclass the relevant class and add what you need.

不应直接编辑 Pod,因为任何后续的“pod install”都会清除您的更改。正如 rckoenes 所说,最简单的方法是对相关类进行子类化并添加您需要的内容。

If the changes you need can't be done in a subclass, you have another option. You can fork the repo for the pod, make any needed changes directly to the classes themselves, and point your podfile towards your fork. See this answer: Cocoapods and github forks

如果您需要的更改无法在子类中完成,您还有另一种选择。您可以为 pod 生成 repo,直接对类本身进行任何需要的更改,并将您的 podfile 指向您的 fork。看到这个答案:Cocoapods and github forks

回答by dengApro

#import "MyProjectClass.h" 

Directly import source, you should not use pods. Better to drag the source code, and directly put into you project.

直接导入源码,不应该使用pods。最好把源代码拖过来,直接放到你的项目中。

If needed modify pods and you seldom pod install, change the mode of pod file.

如果需要修改 pods 而你很少pod install,改变 pod 文件的模式。

cdyour pod folder, and run sudo chmod 777 your folder.

cd您的 pod 文件夹,然后运行sudo chmod 777 your folder.

Pods folder is readonly default.

Pods 文件夹默认为只读。

img

图片