21

I want to use some Swift pods in my Objective-C app, so I need to use frameworks instead of static libraries. But enabling use_frameworks! in my Podfile causes tones of #import errors.

My Podfile:

platform :ios, '8.0'
use_frameworks!

pod 'AFNetworking', '2.6.0'
pod 'Typhoon'
pod 'SSKeychain'
pod 'JBWebViewController'
pod 'TTTAttributedLabel'
pod 'HockeySDK'
pod 'GoogleAnalytics'
pod 'Intercom'
pod 'FBSDKCoreKit'
pod 'FBSDKLoginKit'
pod 'UIButton+Activity'
pod 'HexColors'
pod 'AFNetworkActivityLogger'
pod 'HCSStarRatingView', :git => 'https://github.com/hsousa/HCSStarRatingView.git'
pod 'LGSideMenuController'
pod 'DateTools'
pod 'SDWebImage'
pod 'SSCWhatsAppActivity'
pod 'UIViewController+BlockSegue'

The first problem was with SSKeychain pod:

SSKeychain Error

In code I'm including SSKeychain using "quotes" #import "SSKeychain/SSKeychain.h", but if I understand right, I need to use <angle> from now #import <SSKeychain/SSKeychain.h>? But in this case I receive same error, but in my code.

My Build Phases:

Build Phases

Anyway I have found fork of SSKeychain with "quotes" import (https://github.com/adamwulf/sskeychain/commit/2b7fd878415e8e4f23f74636cdd8c993466d0749) and switched to those version.

But now I have same issue with many other pods (almost with all of them):

FBSDKCoreKit error

Import in app: #import "FBSDKCoreKit/FBSDKCoreKit.h"

Do I really need to fork each repo and change import statements?? Or I'm including pods in wrong way?

PS: I'm cleaning derived data and project before each build attempt.

Cocoapods Version: 0.39.0

Mr Lister
  • 42,557
  • 14
  • 95
  • 136
Ponf
  • 1,190
  • 1
  • 12
  • 28

4 Answers4

12

As you've used Modules in your Podfile, why don't you just:

@import SSKeychain;

instead of:

#import <SSKeychain/SSKeychain.h>

To test that:

  • create a simple iOS project, just with one ViewController
  • create a Podfile using your code above
  • run pod install
  • open the Workspace
  • build & run: it compiles OK
Community
  • 1
  • 1
Diego Freniche
  • 4,737
  • 3
  • 29
  • 40
  • When I'm trying use `@import` instead of `#import` I receive error that framework not found: https://s.mail.ru/GNxY2NAxse12/img-2015-12-23-12-42-25.png. I think this is a main problem – Ponf Dec 23 '15 at 09:43
  • I've tested in an empty project and it works, please create a test project to ensure this works, then compare your target with the new project's target – Diego Freniche Dec 23 '15 at 09:52
  • I have finally figured out it! The problem was fixed by removing `Pods.framework` from **Link Binary With Libraries** and adding them again manually. Thank you for your help! You can edit your answer and I will accept it :) – Ponf Dec 23 '15 at 09:55
  • 1
    Better: auto-answer yourself. You've found what works! – Diego Freniche Dec 23 '15 at 09:57
  • Thanks Diego. I found that after adding `use_frameworks!` the classic `#import`s were giving me problems (duplicate definitions and such). By replacing them with `@import`s my build is fixed again. – Ferran Maylinch May 09 '17 at 15:02
7

I have finally figured out it! The problem was fixed by removing Pods.framework from Link Binary With Libraries and adding them again manually.

Thanks for help!

Ponf
  • 1,190
  • 1
  • 12
  • 28
  • That's weird, did you actually open the workspace rather than the project ? – Tancrede Chazallet Dec 23 '15 at 11:45
  • 1
    @AncAinu yes, also I have 2 targets in project and frameworks were linked only against one of them, so I had to add **Embed Pods Frameworks** build step manually :( – Ponf Dec 23 '15 at 11:53
  • 3
    Next time, it would be useful to run this (https://github.com/CocoaPods/cocoapods-deintegrate) to remove all traces of CocoaPods, then `pod install` again – Diego Freniche Dec 23 '15 at 15:54
  • 1
    @Ponf Happened to me too, had 3 targets but did link the `Pods.framework` to the first of them only in **Build Settings > Embed Pods Frameworks**. Sad it doesn't do that automatically. – Kevin Hirsch Mar 08 '16 at 10:33
  • Where is this "Link Binary With Libraries" I don't see it? – mehmetsen80 Nov 26 '16 at 06:58
1

Also check error messages on pod install.

In my case I was using a custom import in FRAMEWORK_SEARCH_PATHS, and just because I was doing that, whenever I did pod install the extra search paths that CocoaPods adds were not being added. So I had to remove my custom path and then they showed up. Then I added my custom path.

Might be a good idea to do pod deintegrate, delete de xcworkspace file and do pod install once more. Then add your custom build settings.

This is the error I was getting:

[!] The App [Debug] target overrides the FRAMEWORK_SEARCH_PATHS
build setting defined in Pods/Target Support Files/Pods-AppLib/Pods-AppLib.debug.xcconfig. 
This can lead to problems with the CocoaPods installation
HotFudgeSunday
  • 1,353
  • 2
  • 22
  • 28
0

In my case, what was an issue I already downloaded few ObjC Pods for my Objective C Project then I need one swift pod so I enable use_framwork in my pod file and install that swift pod, After installing that swift pod import issue arrives for ObjeC Libraries in many classes, So

What I did to fix this issue?

  1. Cut all Objective C pods from pod file
  2. Open terminal and run command: cd path/myProject
  3. Terminal run command: pod install
  4. Past it (all Objective C pods) again in pod file and save it
  5. Terminal run command: pod install
jayesh lathiya
  • 728
  • 6
  • 18