18

I had a clean swift project, using some cocoapods : Parse, AFNetworking and RESideMenu. I need to use STZPopupView pod, so I updated cocoapods with the last version:

gem install cocoapods

Then I relaunched it for my project:

pod install

Because of this error :

[!] Pods written in Swift can only be integrated as frameworks; this feature is still in beta. Add `use_frameworks!` to your Podfile or target to opt into using it.

I updated my podfile adding "use_frameworks!"

My podfile is now:

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

target 'isam' do
pod 'RESideMenu', '~> 4.0.7'
pod 'AFNetworking', '~> 2.5'
pod 'Parse', '~> 1.6'
pod 'STZPopupView', '~> 1.0'
end

target 'isamTests' do

end

Since, I have 2 errors when I build :

  • "RESideMenu.h" file not found
  • Failed to import bridging header "..../isam/Swift-Bridging-Header.h"

I didn't changed anything else in my project.

My Swift-Bridging-Header.h doesn't change :

#ifndef isam_Swift_Bridging_Header_h
#define isam_Swift_Bridging_Header_h

#import <Parse/Parse.h>
#import <RESideMenu.h>

#endif

In my build settings, I have :

builds settings

I think it's because of "use_frameworks!" in my podfile, but I don't know how to do to use all of my pods to build my app correctly.

EDIT :

The exact errors are :

/path_of_my_project/Swift-Bridging-Header.h:12:9: error: 'RESideMenu.h' file not found
#import <RESideMenu.h>
        ^
<unknown>:0: error: failed to import bridging header '/path_of_my_project/Swift-Bridging-Header.h'
cmii
  • 3,556
  • 8
  • 38
  • 69
  • Remove these statements from the bridging header file: #ifndef isam_Swift_Bridging_Header_h & #define isam_Swift_Bridging_Header_h and endif. It should work. – Dilip Lilaramani Jul 07 '15 at 20:41
  • @dilip.ajm The #ifndef simply keeps it from getting imported multiple times as far as I can tell – Andrew Jul 07 '15 at 20:49
  • @SantaClaus I tried with and without quotes, but it doesn't work – cmii Jul 07 '15 at 20:52

3 Answers3

16

I'm actually on the same problem. You could try this: http://www.innerexception.com/2015/05/cocoapods-useframeworks-means-bridging.html

When using use_frameworks! in CocoaPods all of your pods will be used as frameworks, not only the swift pods. So you don't need an bridging header for this. Just import your pods into all swift files you need. In your example you have to write: import RESideMenu

Dan Beaulieu
  • 19,406
  • 19
  • 101
  • 135
DasDany
  • 185
  • 10
  • This fixed it for me. However I also I got a "duplication of interface declaration" that I fixed by changing my Objective-C files that were importing headers from frameworks into using global includes instead of local: `#import "Framework.h"` to `#import `. – Scott Fister May 18 '16 at 02:40
2

Try removing isam/ from the Objective-C Bridging Header and have only Swift-Bridging-Header.h

Coming from personal experience, CocoaPods still have some issues when combining swift and Objective C frameworks. You can use Alamofire which is almost equivalent of AFNetworking for swift.

Hope this helps.

Edit : Also why use Objectice-C Parse in swift when you can directly use swift libraries.

mosn
  • 311
  • 3
  • 16
  • Remove isam/ doesn't work. Indeed, I need the pod STZPopupView because I would like to custom the uialertcontroller : http://stackoverflow.com/questions/31254931/add-an-animation-image-per-image-inside-a-uialertcontroller-swift – cmii Jul 07 '15 at 21:01
  • ok I was able to successfully build the project using your specification. only thing that I needed to change was to modify this #import Also try removing target 'isam' do from your pod file and make sure to run all pod terminal commands inside the project directory – mosn Jul 07 '15 at 22:15
  • when you said "remove the target isam", you ask me to remove completely the line "target 'isam' do"/"end" in my podfile? – cmii Jul 08 '15 at 07:25
  • target 'isam' do should be removed from the pod File, but asked before to remove it from Header file location in Build Settings. I dont have that and never had to include project directory in Build Setting. I'd recommend just add Header.h in there are create a new hear file with the name Header to make things simplified (Naming this way is not best practice but can help you narrowing down and find the issue) – mosn Jul 08 '15 at 07:35
  • what is your cocoa pods version? – cmii Jul 08 '15 at 12:06
  • I follow your instructions it doesn't work too :( I copy the exact errors in my question. – cmii Jul 08 '15 at 20:39
  • this stzpopupview is nothing more than you could achieve with a normal modally presented view controller – longbow Jul 08 '15 at 20:44
  • Swift stuff is still by far more error prone than Obj-C libs. – brainray Sep 07 '15 at 14:42
1

I had the same issue. I changed all my imports from #import "RESideMenu.h" to #import <RESideMenu/RESideMenu.h> for example.

jamesthakid
  • 1,265
  • 10
  • 11