why isn't Xcode identifying PFFacebookUtils? - ios

Xcode 6 beta is recognizing Parse but not PFFacebookUtils when i am trying to initialize both in appdelegate.m
here is how i am doing the integration of Facebook SDK
i am using cocoa pods to add parse and Facebook to iOS project. i am using Xcode 6 beta.
i create pod file this way
platform :ios, '8.0'
pod 'Parse'
i run pod install at terminal and this downloads parse and Facebook SDK
Now i import parse in appdelegate.m
using
#import <Parse/Parse.h>

With v1.2.21 of the Parse library, PFFacebookUtils.h has moved into another Framework, ParseFacebookUtils. Xcode isn't recognising PFFacebookUtils.h because it most likely doesn't exist anymore.
You need to add the ParseFacebookUtils pod to your Podfile:
pod 'ParseFacebookUtils', '~> 1.2'
BUT, there is an issue with this. The Parse pod spec lists Facebook-iOS-SDK v3.17 as a dependency, and the ParseFacebookUtils spec lists an alternative Parse podspec (Parse-iOS) as well as Facebook-iOS-SDK v3.9.0 as a dependency, which is obviously a conflict. You don't need 2x parse libraries, and incompatible versions of the Facebook SDK floating around.
I've forked and updated a version of the ParseFacebookUtils spec on github, that solves both these problems. If you'd like to use it add the following to your podfile:
pod 'ParseFacebookUtils', :podspec => 'https://raw.githubusercontent.com/rickerbh/ParseFacebookUtilsSpec/master/ParseFacebookUtils.podspec.json'
And be sure to
#import <ParseFacebookUtils/PFFacebookUtils.h>
as well so your project knows about PFFacebookUtils

Related

How to integrate both Objective-C and Swift pods in same project in iOS app

I am doing Objective-C in iOS app. But the problem is I want to add few Objective-C apis into that I added successfully earlier with cocoa pods, But, now I want to add Swift Api through cocoa pods, but the problem getting while installing is following.
[!] Pods written in Swift can only be integrated as frameworks; add use_frameworks! to your Podfile or target to opt into using it. The Swift Pods being used are: apis
But I can't add this manually due to its large api and it contains sub folders.
But, if I remove "#" key from use_frameworks!, its getting installed, but, the old Objective-C apis getting file not found in my project.
Even I have very basic knowledge at installing frameworks/apis through cocoa pods.
Can any one suggest me how to over come this.
use_frameworks! will work with Objective-C pod only if they are dynamic frameworks not static libraries. Most of the popular third party libraries are using dynamic frameworks like AFNetworking, GoogleMaps etc.
Make sure all your Objective-C pods are dynamic frameworks. If you are not sure just create a sample project with cocoapods and use use_frameworks!. Try adding one by one, all the pods and find out which one is the culprit.
I had that problem once, what I did was use use_frameworks! like you mentioned, and then I changed how the Objective-C imports are written.
The command use_frameworks! turns each pod into a Framework, so in your projects the .h and .m files are no longer visible to the import like they would usually.
As a result, instead of using for example #import <AFNetworking/AFNetworking.h>, you do #import AFNetworking;
From my own experience, and maybe it was just a special case for my project. But turning everything into frameworks slowed down the compile time on Xcode and it made my App Package bigger for some reason.
Podfile file:
platform :ios, '10.0'
use_frameworks!
def pods
pod 'Alamofire', '= 4.4'
pod 'SwiftyJSON' '= 3.1.4'
pod 'MBProgressHUD'
end
target 'YourProject' do
pods
end
YourProject-Bridging-Header.h
#import <MBProgressHUD/MBProgressHUD.h>
Build Settings

Unable to use both Swift and Obj-C libs with Cocoapods

I have just started a new Swift project and I would like to use different libraries. In particular, I would like to use Realm.io, an Obj-C library. But, I would also like to use pure Swift libraries such as Alamofire or Dollar.
I use Cocoapods for managing my dependencies. I use the latest version (0.37.0) and the new use_frameworks! flag. pod install is successful anytime.
Unfortunately, when I try to build my project I get two errors (for my main target):
Umbrella header Realm.h not found from module.modulemap
Could not build Objective-C module Realm from any file using import Realm
Other imports work fine.
I have noticed the following: if I remove pure Swift libs and use_frameworks, everything works fine. I am aware about this current issue from Cocoapods. However, it should not be a problem for Realm asks developers to use that flag.
Here is my Podfile:
platform :ios, '8.0'
use_frameworks!
target 'rothrock' do
pod 'Realm'
pod 'Cent'
pod 'SwiftyJSON'
pod 'Alamofire'
end
target 'rothrockTests', :exclusive => true do
end
I use no bridging header. Should I?
Any idea or workaround?
Alright, here is the full walkthrough:
Install dependencies using Cocoapods and the use_frameworks! flag.
As you need to use a Objective-C dependency, create a Bridging header. You can create one easily by importing an Objective-C class to your Swift project, than remove it (the wizard should ask you if need a bridging header). Otherwise, create a new header file. Then, navigate to your target configuration and enter the name of your file in Swift Compiler - Code Generation > Objective-C Bridging header.
Still in your target configuration, add a new entry in Search Paths > User Header Search Paths: Pods as value and flag it as recursive.
Remove any import instruction from your code, relative to your Objective-C library.
Build your project. You should have a success.
You need a bridging header and import your Objective-C library headers there.
If you are using only Realm you can check out this documentation for Swift http://realm.io/docs/cocoa/ (go to CocoaPods down in the tabs)
Swift
Install CocoaPods 0.36.0 or later ([sudo] gem install cocoapods).
In your Podfile, add use_frameworks! and pod 'Realm' to your app target.
From the command line, run pod install.
Use the .xcworkspace file generated by CocoaPods to work on your project!
Download the latest release of Realm and extract the zip.
Drag the file at Swift/RLMSupport.swift into the File Navigator of your Xcode project, checking the Copy items if needed checkbox.
I just installed the Realm library in a project I have with some of the libraries you mention above like Alamofire and SwiftyJSON and others and it works fine when you build the project and even put the import Realm, no compilation errors at all.
I'm using Cocoapods 0.36.0, the stable version and this is my PodFile :
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '8.0'
link_with 'ApiWorkflow', 'ApiWorkflowTests'
pod 'SwiftyJSON', '~> 2.2'
pod 'Alamofire', '~> 1.2'
pod 'Typhoon', '~> 3.0'
pod 'SwiftCSV', '~> 0.1'
pod 'Realm'
I hope this help you

Facebook iOS SDK v 4.1.0 in Swift with Cocoapods: cannot import modules

I tried to update my Swift project to Facebook SDK v 4.1.0 today (FBSDKCoreKit and FBSDKLoginKit), but it doesn't seem to be working. I cannot import the modules as they are not found.
I basically removed the line
pod 'Facebook-iOS-SDK'
and added the lines
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
and then did a pod install. The Facebook doc says the new SDK supports direct imports, so I tried
import FBSDKCoreKit
in one of my project files, but it says No such module 'FBSDKCoreKit'
I looked around and found the following links which talk about bug with building module, and the Facebook bug report and changelog:
issue using FBSDK in swift iOS application
https://developers.facebook.com/bugs/362995353893156/
https://developers.facebook.com/docs/ios/change-log-4.x
However, it seems to claim that the issue has been fixed in v 4.1.0 (seems to be the main reason for the update), so this isn't the problem in my case? Anyone have any information about this / have a solution?
Try adding use_frameworks! to the top of your podfile, as suggested by this answer. Here's a blogpost that explains the issue.
I just ran into this problem of not being able to import the FBSDK directly into my files after I installed the sdk using cocoapods..
But after performing a build, the import statements worked fine!
For some people experiencing this problem it might be as simple as that.
I know its an old post but thought to update the podfile for someone who would face the same issue i was facing.
You can use this with iOS 9 and swift,once you run pod install you are good to go for
import FBSDKLoginKit
import FBSDKShareKit
import FBSDKCoreKit
in swift files
-----Podfile------
# Uncomment this line to define a global platform for your project
platform :ios, '9.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'FBIntegration' do
pod 'Bolts'
pod 'FBSDKCoreKit'
pod 'FBSDKShareKit'
pod 'FBSDKLoginKit'
end
If you have already added a bridging_header file you also can just add
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
into it. Then import directly
import FBSDKLoginKit
Check here. Try with this in podfile:
pod 'FBSDKCoreKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
pod 'FBSDKLoginKit', :git => 'https://github.com/facebook/facebook-ios-sdk.git', :branch => 'dev'
You should use
PROJECT.xcworkspace
file after editing Podfile and executing
pod install
command,

Facebook Cocoapods integration

I am integrating 3rd party libraries into my project using cocoapods. Everything was working smoothly but when i try to integrate facebook ios sdk I encounter a very strange issue, my pods project has the following warning:
If i click on it i get the following dialog:
I checked the Headers in the build phases part of the target "Pods-Facebook-iOS-SDK". Every header file is repeating:
When i try to build my project it fails because it is not able to find "FacebookSDK/FacebookSDK.h".
My last option is to just integrate facebook sdk manually and not use cocoapods for it but I dont want to take that route and for the life of me I cannot understand what I am doing wrong. For refrence following is my pod file:
platform :ios, '7.0'
pod 'DTCoreText'
pod 'UIView+AnimationExtensions'
pod 'EZAudio'
pod 'MZTimerLabel'
pod 'AWSAutoScaling'
pod 'AWSCloudWatch'
pod 'AWSCore'
pod 'AWSDynamoDB'
pod 'AWSEC2'
pod 'AWSElasticLoadBalancing'
pod 'AWSKinesis'
pod 'AWSS3'
pod 'AWSSES'
pod 'AWSSNS'
pod 'AWSSQS'
pod 'AWSSimpleDB'
pod 'Facebook-iOS-SDK'
Following is the information regarding my developement environment:
XCode: 6.1
Architectures: armv7, arm64
Base SDK: iOS 8.1
I was having a similar problem. My project previously had not used Cocoapods and I was now attempting to add the Facebook SDK via Cocapods.
Based on #MingLi's comment, I replaced all instances of #import <FacebookSDK/FacebookSDK.h> with #import <FBSDKCoreKit/FBSDKCoreKit.h> and things started working again.
When I compiled in Xcode, it showed me files that need #import <FBSDKLoginKit/FBSDKLoginKit.h> and #import <FBSDKShareKit/FBSDKShareKit.h>
You will also likely have to go through and adjust things that changed between Facebook SDK 3.x and 4.x. For instance, I had to replace [FBSettings setDefaultAppId:123456789] with [FBSDKSettings appId:123456789] and replace [FBAppEvent activateApp] with [FBSDKAppEvents activateApp].
Xcode is sometimes helpful about finding the needed change, if you compile and then click the red dot (in your code) next to each compile error.
It can take a good bit of work to sort through all of the changes, you may have to recompile many times.
If you are having problems figuring out how to replace specific functions/classes when upgrading from SDK 3.x to 4.x, you can refer to Facebook's Change Log:
https://developers.facebook.com/docs/ios/change-log-4.x
You can also find additional information here:
https://developers.facebook.com/docs/ios/getting-started

Restkit via cocoapods fails to build on new project, RKLog not found

I'm trying to use Restkit via CocoaPods for my first time, on a brand new project, but I encounter some issues building the project once Restkit is introduced:
I have followed these exact steps:
Created a brand new Xcode project, default options.
Created a podfile with the following contents :
platform :ios, '6.1'
pod 'RestKit/Testing', '~> 0.20.0pre'
pod 'RestKit/Search', '~> 0.20.0pre'
Run pod install then opened the workspace
Updated the prefix file as instructed here.
I'm running these versions, all valid according to the Restkit documentation:
Git git version 1.8.1.2
CocoaPods 0.16.2
Xcode 4.6
Can anyone suggest what I may have done wrong, or what I can do to solve this? Thanks
You have to include the base of Restkit as well. Add
pod 'RestKit', '~> 0.20.0pre'
To your Podfile.
Found a solution described here.
It involves searching the project for #import and replacing it with #import . The project compiles!
//#import <RestKit/RestKit.h>
#import <RestKit/CoreData.h>
In this case the offending file was RKOperationStateMachine

Resources