error using cocoapods "use_frameworks!" SWIFT

18,359

Solution 1

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

Solution 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.

Solution 3

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

Share:
18,359

Related videos on Youtube

cmii
Author by

cmii

Updated on October 31, 2022

Comments

  • cmii
    cmii over 1 year

    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
    cmii almost 9 years
    Remove isam/ doesn't work. Indeed, I need the pod STZPopupView because I would like to custom the uialertcontroller : stackoverflow.com/questions/31254931/…
  • mosn
    mosn almost 9 years
    ok I was able to successfully build the project using your specification. only thing that I needed to change was to modify this #import <RESideMenu/RESideMenu.h> Also try removing target 'isam' do from your pod file and make sure to run all pod terminal commands inside the project directory
  • cmii
    cmii almost 9 years
    when you said "remove the target isam", you ask me to remove completely the line "target 'isam' do"/"end" in my podfile?
  • mosn
    mosn almost 9 years
    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)
  • cmii
    cmii almost 9 years
    what is your cocoa pods version?
  • cmii
    cmii almost 9 years
    I follow your instructions it doesn't work too :( I copy the exact errors in my question.
  • longbow
    longbow almost 9 years
    this stzpopupview is nothing more than you could achieve with a normal modally presented view controller
  • brainray
    brainray over 8 years
    Swift stuff is still by far more error prone than Obj-C libs.
  • Scott Fister
    Scott Fister almost 8 years
    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 <Framework/Framework.h>.