How to ignore untracked files when using CocoaPods? - objective-c

I have a simple project and wanted to include a third party library (CocoaLumberjack) using CocoaPods. After creating the simple Podfile I ran pod install in my project directory. Everything worked fine, except I now have untracked files in my project that are marked with question marks in Xcode:
Is this how it's supposed to be? I don't remember having these question marks when I last used CocoaPods in a different project. Shouldn't CocoaPods automatically set up the correct gitignores for the pods?

CocoaPods doesn't do anything with your .gitignore.
I recommend using GitHub's Objective-C .gitignore (at least as a starting point). Alternatively, just make sure you ignore the Pods directory by adding an entry for Pods in your ignore file:
# CocoaPods
Pods

Related

How to convert framework in a cocapod?

I have create new cocoa-pod with an example project which in original project used a framework (X.framework).
So it was like:
Original_Proj
|- four Classes (A,B,C,D{.h,.m})
|-Main.m
|- etc by default xcode project files
|-X.framework
Now those four classes imported the X.framework and used its functionality. (Purpose being only few classes of framework exposed project).
========================================================================
Now in a xcworkspace created by cocoapod, i have added all the Four classes and other necc. files in EXAMPLE folder but now i want the X.framework to be as Development pod so i can import it in those Classes in cocoapod embed project.
Following is my Cocopod project structure
Now i wanted to ask whether i have to put the complete framework it self in Dev. pods folder OR all X.framework's source files in Dev. pods folder. Will it expose those files to others if they install the pod in their project? Please guide with proper way if I am doing something wrong? Detail explanation would be really appreciated.
Remove that pod. follow the below steps
1) Open terminal
2) sudo gem install cocoapods (gem will get installed in Ruby inside
System library)
3) pod setup
4) create a xcode project
5) cd "path to your project root directory"
6) pod init
7) open -a Xcode Podfile (podfile will get open in text mode. Initially it will be empty put the following line of code.)
8) pod frame_name veraion (It’s finally time to add your first dependency using CocoaPods! Copy and paste the following into your pod file, right after target "Project" do:)

Cocoapods Errors : Resource.sh not found

Folks,
Cocoapods : 0.39.0
FYI I have done enough research and I was able to take care of errors like:
Podfile.lock not found.
.menifest not found
and others while building my project.
Which still seem hack to me but as long as they let me build I dont care.
But one real problem is this :
Pod-resources.sh not found and this one is in the pod directory.
so for sure Its not in my source control as I dont check in pods dir into my project.
I have done more than enough weokspace deletion, podlock deletion, who pods dir deletion and pod install. but this problem is still there.
I am using apptentive which has a resource bundle, which need to be copied to the app binary.
At the moment I have disable Apptentive thru out the project to speed up the development and keep looking for solution.
Links that I have read are follows :
https://github.com/CocoaPods/CocoaPods/issues/2303
is from July 10, 2014 : seem too old to rely on.
CocoaPods Errors on Project Build
Error:"The sandbox is not in sync with the Podfile.lock..." after installing RestKit with cocoapods
The sandbox is not in sync with the Podfile.lock-ios
Error:"The sandbox is not in sync with the Podfile.lock..." after installing RestKit with cocoapods
How I solved my partial problem : delete workspace file, Pods Dir and .lock file. If this can help anybody.
Culprit was the path. It seem how Cocoapods is handling is different than earlier.
What it dont do is updating your project file for Copy Resources phase:
it seems they have update the path and now it has "/Target Support Files/Pods-ProjectName/" in it.
Older path: "${SRCROOT}/Pods/Pods-ProjectName-resources.sh"
New Path: "${SRCROOT}/Pods/Target Support
Files/Pods-projectName/Pods-Project-resources.sh"
So if you are having same errors like me you need to do is :
remove workspace file
remove .podlock file
remove .menifest file
do Pod install
update the path in build phase in xcode project file as shown above.
Now Build the project/workspace
Hope this will save someone's time.
You might have to add a PODS_ROOT user-defined build setting, as described here.

Should xcworkspace be in gitignore

I am using GitHubObjectiveCGitIgnore
When I go in sourcetree to commit I see :
project.xcworkspace
This file is not ignored using Github .gitignore file.
I am not sure do I need to commit and push this file?
If you're using Cocoapods, I actually find that the answer depends on a few things.
If you just want the project to be compilable and runable "out of the box", then go ahead and check everything in; xcworkspace and all pods.
If there is a pod that you need to modify for some reason and you want to include that change with your project, then check everything in. For instance, I've found bugs that haven't been fixed for one reason or another and it was easier to just fix them myself and check in the pod along with my project rather than wait for the updated pod or integrating the library manually (which is essentially the same result as checking the pod in anyways). Alternatively, fork the repo, push your changes to it, and point your pod to your fork.
If you have no issues with any of the pods and you've verified that everything works with the versions of the pods you've specified, then you don't have to check in the xcworkspace file or pods. Of course, you'll have to run pod install in this case.
There's no hard and fast rule on what to do here. Sometimes it's worth the extra overhead to just check everything in, and sometimes it's not necessary. It depends on what's most convenient for you.
In short yes it should be commited.
I have my xcworkspace file checked in to my repo. If you don't use a workspace it probably isn't needed but as I use Cocoapods this creates a xcworkspace with the original project and the pods project inside of it.
Use a workspace is the correct way on handling multiple project sets/dependencies.
If you have/or plan to have several projects in the workspace (for example sub projects of your project) then you should not add it to .gitignore.
Cocoa pods just adds its own project to the workspace if a workspace exists when you do a pod install.
In general it is safer to include the workspace file in the git commit, even if you exclude pods.
You will have to do a pod install anyway to compile your project so even if you commit a workspace file that already has the cocoa pod project added it wont cause any issues.

How to add GitHub's Mantle to Xcode using CocoaPods

I have added GitHub's Mantle project to a iOS 6 project using CocoaPods:
$ pod search Mantle
$ vim Podfile // here I added pod 'Mantle'
$ pod install // this installs Mantle 1.0
Then I have added the ($inherited) variable to the Header Search Paths of project's 'Build Settings' section, before my custom search paths. When importing the Mantle header file Xcode complains with
#import "Mantle.h" // => 'Mantle/MTLJSONAdapter.h' file not found
Am I missing some step? I have other pods installed as well (AFNetworking and SSKeychain) but only Mantle is giving me issues.
I have also added SSToolkit but following the instructions on its 'Getting started', i.e. not using CocoaPods.
Since the problem seemed to be related with the Xcode project/workspace configuration I tried all kind of 'cleaning' solutions:
Delete the Pods directory, the Podfile.lock file and install everything from scratch.
Delete the MyProject.xcworkspace directory and repeat step 1
Enter MyProject.xcodeproj, delete project.xcworkspace and xcuserdata directories and repeat step 1.
Go to the global Xcode directory (/Users/my_user/Library/Developer/Xcode), remove everything related to the project, specially the DerivedData subdirectory, and repeat step 1.
The final step seems to be the final solution, though I cannot tell which file/folder removal did the trick.
Have you added Mantle to your Podfile? You mention running pod install Mantle which doesn't/shouldn't do anything but show an error. ([!] Unrecognized argument:Mantle'`)
After you add Mantle to your Podfile and run pod install you should be able to link Mantle.h directly and there will be a few directories in your xcworkspace and the Pods project. After this you can use #import "Mantle.h" no issues.
I had the same problem, but the problem appears to simply be that my Mantle pod was too old. Changed version to '2.0.5' and pod updated, things work fine.

Cocoapods: how to create own pods for 3rd party library?

I am using Cocoapods, and one of the libraries I use is ZUUIRevealController, currently the version is 0.9.6 in Cocoapods, which is not the latest one, if I want to create my own pods for that, what are the steps for doing it?
Thanks!
To update for everyone:
OK, so all the cocoapods are held inside a big specs repository Here. We want to go down to the ZUUIRevealController part of the repo. We can see just the 0.9.6 which is how cocoapods knows what version it is.
So, fork the cocoa pods spec repository and open the folder in SublimeMate Pro. You're going to want to add the next version to this folder, so let's say you were going to use 0.9.7. Make a folder for that and copy it over ZUUIRevealController.podspec from version 0.9.6.
The new podspec will need some changing as it refers to the git tag "v0.9.6" and ideally you want to use 0.9.7. Now I've checked for you, there isn't a 0.9.7 which means you'll have to create an issue asking for a new tag, which someone has already done.
With the new tag in the repo you can move that tag into your podfile. Then in the Specs directory run pod specs lint ZUUIRevealController which will tell you whether your podspec has passed or failed linting. If you don't do this it will be done automatically on your pull request, and it's likely that it will be me telling you how to fix it.
If it passes, you can then commit that change and submit a pull request to the Cocoapods/Specs repo on github.
To update for just you:
in your podspec, you can set the commit that you want to override the normal podfile's commit with ( for example )
pod 'ZUUIRevealController', :git => 'git://github.com/orta/ZUUIRevealController', :commit => 'd4c9d810e0f0d1982472c8d1d5469841b09854ab'
This may require deleting your Pods directory first as it might have cached the url / commit.