How do I make a new header file of my own library visible in a CocoaPods-based project? - xcode

I use CocoaPods for developing an app that also uses a private library "MyLib" I develop in parallel to the app. MyLib maintains its own podspec and is referenced in the app's podfile like so:
pod 'MyLib', :path => '~/Projects/iOS/Own/Frameworks/mylib'
I noticed that CocoaPods maintains its own public header file directory for MyLib at /pods/Headers/Public/MyLib and includes that directory in compiling source files from the app.
My question: what makes CocoaPods update this header files directory if I add a new public category to MyLib.xcodeproj that I want to use in the app?
Thanks in advance.

pod install or pod update need to be executed whenever your add a new file to your pod doesn't matter if it is public header or private implementation file. Old files can be changed without updating

Related

Adding cocoapods-art plugin to podspec for private repo dependency

I've been using a private cocoapod library in my app which is installed via cocoapods-art. Now I have created a wrapper for this library and want to make our own cocoapod for it so we can use it into multiple other applications. But I don't know if it's possible to use a cocoapods-art plugin in the podspec file
I couldn't find an example on how to add a cocoapods-art lib as a dependency in the podspec file. The way it's installed in my Podfile:
plugin 'cocoapods-art', :sources => [
'PRIVATE_REPO'
]
source 'https://github.com/CocoaPods/Specs.git

Using Cocoapods in a Workspace with two apps

I have two apps (xcode projects) that i want to have in one workspace. Since Cocoapods usually generates the workspace, i looked to see if it was possible to do this and found some answer. The recommended Podfile would look like:
workspace 'TestWorkspace'
target 'TestApp1' do
xcodeproj 'testApp1/testApp1.xcodeproj'
workspace 'TestWorkspace'
pod 'AFNetworking'
end
workspace 'TestWorkspace'
target 'TestApp2' do
xcodeproj 'TestApp2/TestApp2.xcodeproj'
pod 'MBProgressHUD'
end
(sorry wasn't sure how to have SO format the Ruby code)
So my folder structure looks like a TestWorkspace folder, with the two App projects folders, and the Podfile. Running pod install
[!] xcodeproj was renamed to project. Please update your Podfile accordingly.
and..
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target TestApp1 to ../Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig or include the ../Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig in your build configuration (TestApp1/Pods/Target Support Files/Pods-TestApp1/Pods-TestApp1.debug.xcconfig).
So my question is what changes must be made to wind up with my TestWorkspace workspace having three projects: TestApp1, TestApp2, and Pods?
(btw, i changed the true names of my projects/workspaces to pseudo-aliases for the purposes of posting here. Hopefully, I changed everything faithfully.)
EDIT: Ok so i fixed the first warning (just a change in podfile syntax from xcodeproj to project). However, my workspace is definitely not being configured properly. I don't even see a Pod project after pod installing.
EDIT2: OK so i fixed the second warning by setting both project configuration files (debug and release) to "none". So now I have no errors, but the Pod project is still no where to be found. (Sorry if i'm solving parts of the question but I think its better to add edits than to create a new question).
Use the targets as scopes for the xcproject/workspaces. Update the podfile to something like this:
workspace 'TestWorkspace'
target 'TestApp1' do
xcodeproj 'testApp1/testApp1.xcodeproj'
workspace 'TestWorkspace'
pod 'AFNetworking'
end
target 'TestApp2' do
xcodeproj 'TestApp2/TestApp2.xcodeproj'
workspace 'TestWorkspace'
pod 'MBProgressHUD'
end
Now run pod install --verbose

Cannot find module FBSDKCoreKit Cocoapods

I'm trying to integrate facebook into my app using CocoaPods, using the use_frameworks! tag, and according to facebook's instructions here, also included the pod bolts. When I try use import FBSDKCoreKit in my appdelegate, I get a no such module 'FBSDKCoreKit error. I've included my podfile below:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.2'
use_frameworks!
pod 'Bolts'
pod 'Alamofire', '~> 3.0'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
Additionally, in my Pods folder, there is a question mark next to Bolts, FBSDKCoreKit, and FBSDKSharekit, but not one next to alamofire, which I had been using previously. In the Frameworks folder in my Pods project, FBSDKCoreKit and Bolts are listed there, but are both red.
Any ideas? I've tried cleaning my project, and reinstalling and updating the pods.
For people moving from Carthage to Cocoapods make sure to remove the Carthage references of the FBSDKCoreKit from the Link Binary With Libraries under Build Phases option.
Please try below steps,
Explicitly mention the versions i.e.
pod 'FBSDKCoreKit', '~>5.8.0'
pod 'FBSDKShareKit', '~>5.8.0'
pod 'FBSDKLoginKit', '~>5.8.0'
Update pod repo using sudo pod repo update
Update pod using pod update
Seems that the facebook pods are Objective-C and they need a special way of importing in a swift project.
This is how I got it to work:
Create a bridging header in your project, if you dont have one(I created a new header file called Bridging-Header.h and set it as a bridging header in the project settings, like in the screenshot)
Then in this file import the facebook modules. Here's how my file looks like:
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import FBSDKCoreKit;
#import FBSDKLoginKit;
#endif /* Bridging_Header_h */
Let me know if this workout for you or you need more help.
I fixed this by
Removing the Bridging Header. Facebook SDK doesn't need them anymore after version 4.1
Adding all of the .frameworks to the Projects Build Phases -> Link Binary With Libraries
Selecting each framework and building it. You can do this by selecting your project name next to the run arrow.
Cleaning the project and restarting my computer.
Very simple solution, if you are using Apple Swift Packages:
Go to Navigator pane and select the project
Then make sure you choose project name under "Project" not under "Targets"
Then select Package Dependencies tab
You will find the Facebook package there, double click on it
Change version to 9.0.0 and click "Done"
Rebuild, and it should be corrected.
Note that you may need this url to add Facebook SDK as Apple Swift Packages rather than Cocoapods.
You can try :
pod 'FBSDKCoreKit/Swift'
first add in pod file
pod 'FacebookCore'
pod 'FacebookLogin'
pod 'FacebookShare'
this is facebook swift library,after that before using FBSDKCoreKit,just use FacebookCore then import FBSDKCoreKit

Creating a static library with Cocoapod Dependencies

I'm trying to create a static library in Xcode. My library consists of a single class. It depends on another library (RXCollections).
My tests also depend on other libraries: OCMock, and Foundry.
For my static library project, I created a podfile for my static library project as such:
platform :ios, "7.1"
pod "RXCollections", '~> 1.0'
target :LibraryTests, :exclusive => true do
pod "OCMock", '3.1.1'
pod "Foundry"
end
Everything builds successfully, but when I run my tests, I get a runtime exception when I try to use RXCollections methods: -[__NSCFSet rx_mapWithBlock:]: unrecognized selector sent to instance 0x7feaf414c410.
What's going wrong here?
UPDATE
Well, that didn't take long ;) Turns out, CocoaPods was automatically adding LibPods.a to my target's "Link Binary with Libraries" build phase, but for some reason, I had to remove that and add the LibRXCollections.a specifically. Still not sure why. Any ideas?

Using CocoaPods with Swift

I'm new to Cocoapods and am trying to use a pod named DateTools in my OS X app Swift project.
I installed Cocoapods, created the podfile, added pod 'DateTools' to it, ran pod install and everything seemed to work fine. (I'm a Ruby dev so I think I got this part right).
As asked by Cocoapods, I now opened my project using the new .xcworkspace file created. I correctly see two projects in Xcode: mine and Pods.
I added a sample model file to my project, let's call it SampleModel but in the code, when I do this:
let date = NSDate()
var year = date.year
I get the error: 'NSDate' does not have a member named 'year'. According to DateTools README, this should work.
As I'm new to both Xcode and Cocoapods, I can't figure out what is the likely error: DateTools not working with Swift or did I fail to import something, somewhere?
You need to import module into your source file
import DateTools
Also, by default is CocoaPods building static libraries - to use those you would need to configure bridging header. Easier way is to make it build dynamic framework by specifying so in Podfile (and run pod install):
use_frameworks!
pod 'DateTools'

Resources