Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing locked files from a CocoaPods framework

I have an Xcode workspace that uses CocoaPods to include several third-party frameworks. I would like to edit a line of source code within one of these dependencies. However, when I do so, Xcode warns me that the file is locked and that any changes I make may not be saved. So my question is: will my changes to the source code be discarded when I run a pod install/update? If not, is there any other scenario, possibly unrelated to CocoaPods, that would discard my changes? And finally, is there any good way that I can edit the source code without running into such problems?

Thanks in advance.

like image 772
17nisa Avatar asked Jan 21 '16 05:01

17nisa


People also ask

How do you unlock a pod file?

Right click on that and choose Open With option in that you can open your Podfile in TextEditor or TextWrangler. If you have the CocoaPods app installed: open Podfile -a CocoaPods from the Podfile directory in Terminal will open the Podfile for editing in the app.

How do I edit a pod file?

Run the kubectl edit pod <pod name> command. This will open the pod specification in an editor (vi editor). Then edit the required properties.

What is Podfile lock file?

Podfile. lock is used to make sure that every members of the team has the same versions of pods installed on the project. This file is generated after you run the command: pod install. It gets updated when you run pod install or pod update.

Can I delete Podfile lock?

Generally you should not delete the podfile. lock, but if you do, I believe rerunning pod install should fix it.


2 Answers

You can not make changes in Original Pod file. If you want to add some more features then you have to fork that particular repo.

Follow steps to do so :

  1. Find library you want to use on Git.
  2. Fork library.
  3. Update Podfile which refer to your forked version. Suppose I want to fork GPUImage Library. Then point your fork in Podfile as given.

pod 'GPUImage', :git => 'https://github.com/UserName/GPUImage.git'

  1. Make your changes.
  2. Commit/push your changes to your forked repo.
  3. Submit a pull request to the original author of Library.
  4. If pull request is accepted and the pod is updated, revert back your Podfile to use the public pod.

You can create Category (Objective C) or Extension (Swift) to extend or add some features to existing class.

like image 94
technerd Avatar answered Sep 19 '22 13:09

technerd


You can do this simple. Just modify the pods src code. Switch to another brach and switch back. Xcode would rebuild pods with your modified code. If you want go back, you should remove the pod in Podfile, execute pod install.Then add pod back, execute pod install. This solution is just for debug. For permament, you should take @technerd 's answer

like image 28
Jules Avatar answered Sep 19 '22 13:09

Jules