Editing locked files from a CocoaPods framework - ios

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.

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 :
Find library you want to use on Git.
Fork library.
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'
Make your changes.
Commit/push your changes to your forked repo.
Submit a pull request to the original author of Library.
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.

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

In fact there is another way in which you can modify the library as per your custom needs and get future updates from the library, all while still maintaining it via cocoapods
I have written article/tutorial explaining the same.
https://medium.com/#mihirpmehta/how-to-modify-cocoapods-library-within-pods-647d2bf7e1cb

Related

Editing pods in xcode project - enabling edits to be compiled

I often use pods in my Obj-C and Swift projects and quite often need to tweak a pod for my use-cases. I noted recently that my edits were having no effect, that the original bits were being used, and there were many times I was stumped at a situation that I thought my editing corrected, only to realize the compiled bits did not include my latest brilliant hack.
Then I discovered that simply cleaning the build folder (shift-cmd-K) will reset everything and the next build incorporates my edits. I now do this as a matter of regular business with each pod edit, but wondered if there was a simpler way to set a pod to be included in each rebuild.
Editing pods is not ideal, simply because all your changes will be removed after the next pod update.
The best way here would be to fork the pod, modify it and use your own version instead.

How to use development pods across our team?

When I set path for my development pod, I cant commit podfile - it will break pod install for other devs. So I keep podfile in another change list and its really annoying. Is there a better way to develop pod?
I found this: link, it suggest to change to path every time I want to update something in my pod. But it's even worth than uncommited podfile.
You can use relative paths for development pods.
You can ask your co-developers to always use the same folder hierarchy between your current project (with the podfile) and the others developments projects/pods (with the podspec).
You can also use Repo to automatically do it for you (could be useful when a new guy comes, and/or if you have plenty of different development pods). It will install different projects/(development)pods according to the hierarchy set in its manifest. You can check this related answer if needed.

Access iOS source files under pod

What is the best approach to access project source files (.h/.m or Assets.xcassets) under podfile. I'm using a library and want to access my source files in my project. I don't want to hard code anything because I'm using some globally defined parameters.
- I guess podspec is one option (not sure), but I don't want to call pod update each time I made a change in podfile.
See attached image:
If you are using those classes in a single project, then there is no advantage in putting them in a separate pod. If they are used in multiple projects and are rarely modified, then you can consider creating a private Pod. In that case, however, you will need to call pod update every time you release a new build to your private pod.

Is there a way to find out automatically if a third party library has been updated

Im using a couple of libraries I found on GitHub, and I was wondering is there a way to know when a third party library used in an app has been updated? For example, a bug fix.
Must we continuously visit the users repository to find out for our selfs, or does using a dependency manager like Cocoa Pods have this functionality?
Thanks in advance.
Cocoa pods allows you to manage third party library, one feature it has it is pod outdated which checks for new releases of library's and also check if a project has new commits
more info on cocoa pods, see link
example 1 (library with releases only):
say you have AFNetwoking in your project using cocoapods with the following syntax: pod "AFNetworking" if you wanted to just check for updates do pod outdated, or to update the library if there are releases you would do pod update
example 2(library with most recent commits):
there times were you want to get most recent commits regardless of if it stability. On cocoapods you can do pod 'AFNetworking', :git => 'https://github.com/AFNetworking/AFNetworking.git'. this gets the most recent commit on git
CocoaPods handles this. Just type pod install every once in a while. It will fetch all available updates for you... I've been using CocoaPods for a long time without problems... You can even create private pods or development pods if you need to.

How do I incorporate a custom control from github to my project and stay up to date

I use a couple of custom controls from github, thus far I've always added source code files as new resources to my project in XCode. But I have now seen this repo getting updated frequently, it made me wonder if I can add source files and get them updated (manually or automatic) when something new is pushed. Sorry it might be a noob question.
This is the repo : BlockAlertsAnd-ActionSheets
Sounds like you want a git submodule.
As far as I know, there's no way to do this within Xcode, so you'd need to do this from the command line.
And if you're comfortable with using git via the Terminal command line, here's a tutorial on how to get this set up.
you can use CocoaPods. and there is a pod for this repo.
it's really useful to manage your dependencies. to get a new version of a pod, you'll need just update your Podfile and run 'pod install'. Check the website, you'll find more info there.

Resources