iOS 8 Swift-based Framework that imports Firebase

4,011 views
Skip to first unread message

Gurjot Tur

unread,
Aug 6, 2014, 2:11:30 PM8/6/14
to fireba...@googlegroups.com
Hello all,

I am trying to build an iOS 8 Swift-based framework, and learned that bridging headers don't apply to iOS 8 frameworks, unlike apps. I am following Apple instructions for importing external frameworks into my own framework, and run into "No such module 'Firebase'". 

The instructions state this: "When you import an external framework, make sure the Defines Module build setting for the framework you’re importing is set to Yes." Does anyone know is Firebase.framework is itself marked as such? Or has been more successful with this import? If so, I'd love to learn about how you did it.

Many thanks!

-Gurjot

Jacob Wenger

unread,
Aug 6, 2014, 2:17:26 PM8/6/14
to fireba...@googlegroups.com
Hey Gurjot,

We have full instructions for getting started with using Firebase in Swift on our iOS quickstart. Check that out!

Jacob

Gurjot Tur

unread,
Aug 6, 2014, 4:38:31 PM8/6/14
to fireba...@googlegroups.com
Hi Jacob,

I went through those instructions twice, once each in Xcode Beta 4 and Beta 5, until I realized at those apply only to *apps* that want to import Firebase, not *frameworks.* Firebase instructions on your link are based on bridging headers, which Apple says, "The process described in this section applies to non-framework targets". I am building a framework.

One of the first things you'll notice when building a Swift framework and then creating a Temp Objective-C file is that the bridging header pop-up does not show up. So I had to manually create one, which of course didn't work.

Thanks.

-Gurjot

Katherine Fang

unread,
Aug 12, 2014, 6:06:37 PM8/12/14
to fireba...@googlegroups.com
Hi Gurjot,

Yeah, last I checked this wasn't really possible. :(  I'm super excited about Xcode finally supporting building Frameworks, but anyway... I suspect that given time, Apple may release a version of Xcode 6 that handles this (although it's hard to say).  I haven't seen any workarounds for now, but if you do figure this out, please let me know!  I'd be interested to find out how.

-- Kat

Gurjot Tur

unread,
Aug 18, 2014, 5:23:18 PM8/18/14
to fireba...@googlegroups.com
Thank you for your reply, Kat!

I posted this on stackoverflow, and no response there yet. The only thing I can think of is to write a new Objective-C framework that imports Firebase, and then enable Defines Modules in the new framework, and then importing it into Swift framework. It seems very kludgy, but could get me moving forward.

I too am hoping Apple enables this feature by default, and in the interim the framework providers could step in and enable this themselves. :)

Gurjot Tur

unread,
Aug 20, 2014, 4:33:08 PM8/20/14
to fireba...@googlegroups.com
The proposal didn't work. Here's what I tried:

In Xcode 6 Beta 5, I created a new Objective-C framework - SwiftFirebase. In it, I 
  1. imported Firebase framework, and the other five frameworks
  2. set the -ObjC flag
  3. copied references of all the .h files in Firebase Headers folder into the new framework - SwiftFirebase.
  4. made those references from Project to Public
  5. imported <Firebase/Firebase.h> into the SwiftFirebase umbrella header
  6. ensured that Defines Modules was enabled. It was, by default.
  7. Build for Running.
Created a new Swift-based Framework: TestFramework to test the above SwiftFirebase, where I
  1. Added SwiftFirebase from Debug-iphonesimulator into the new library
  2. Created a new swift class
  3. Imported SwiftFirebase
  4. Added an init method, where I put in the sample swift code from Firebase quick-start.
  5. Build for Running
  6. Got an error compiling: "Firebase/Firebase.h not found"
My guess is that copying references of header files from a Firebase into another Objective-C framework and making them public is not an effective way of manipulating files. :)

Hate to wait for Apple's fix. Anything else I could try? Did I miss something in the above steps that you could think of? Many thanks!

Joe Ferrucci

unread,
Oct 24, 2015, 8:11:25 PM10/24/15
to Firebase Google Group
I'm on Xcode 7 and getting the same error, "No such module, Firebase". I wrote some valid Firebase code just to see if it compiled but no luck, can't find the Firebase class. 

Joe Ferrucci

unread,
Oct 24, 2015, 8:11:25 PM10/24/15
to Firebase Google Group
I was able to get it to work. I was getting all the errors when I tried to use Firebase: I couldn't import FIrebase, I couldn't use Firebase code, it would complain about not being found. So finally I just left my code there, clicked Build (or Build & Run), and it worked. Xcode is super buggy, especially when it comes to Swift. 

If something isn't working, just Build & Run. 

This happened to me before. Spent about an hour troubleshooting, kept getting an error. Finally I just ran the Build, and it worked. 

Brandon Calabro

unread,
Nov 10, 2015, 1:00:12 PM11/10/15
to Firebase Google Group
I figured out why this was happening.  So to re-define the issue.  You're using SWIFT with XCode to create an iOS app and you're trying to get Firebase to be imported to use the firebase framework.

The issue you're getting is "No such module 'Firebase'".

The reason why is, when you're editing the Podfile following the instructions here:
https://www.firebase.com/docs/ios/quickstart.html (#3 in the CocoaPods setup)

You forgot to uncomment the line (at the very top):

# Uncomment this line if you're using Swift

use_frameworks!


Now, you can add the 

import 'Firebase'

command to your project classes.  Everything -should- compile and build properly now assuming you followed the instructions carefully.  If you modified that Podfile with your XCode project, then close XCode down.  Open up your terminal, run the pod install command.  Then use the Open <your project>.xcworkspace command to re-open your project.  It will work now.


Good luck.

Joe Ferrucci

unread,
Dec 9, 2015, 2:42:15 PM12/9/15
to Firebase Google Group
I'm sure that you will get the error if you don't have the use_frameworks! line enabled in your Podfile, but,
I had the use_frameworks! tag enabled in my Podfile and I was still getting the error.

I think its Xcode and the Swift compiler/analyzer that has the bugs. It happens daily where a simple Build will fix the problem.

Just to reiterate, use_frameworks! is definitely necessary, but that's not the only possible source of the error.

Amanda Y

unread,
Feb 6, 2016, 10:39:19 AM2/6/16
to Firebase Google Group

I am new to Xcode (started 3 days ago) and I had the same problem. For me I solved it by uncommenting the use_framework! line and then put the "pod 'Firebase', '>= 2.5.0'" line before the line that says "target YOUR_PROJECT do". Then suddenly it all worked. Don't really understand why it worked but hopefully that helps a little bit!

-Amanda

On Wednesday, August 6, 2014 at 11:11:30 AM UTC-7, Gurjot Tur wrote:

Frank van Puffelen

unread,
Feb 6, 2016, 11:25:39 AM2/6/16
to Firebase Google Group
Great to hear that you found the solution Amanda. This is indeed one of the most common problems for people getting started with Xcode.

   Frank

Eduardo Prado

unread,
Feb 11, 2016, 7:52:31 PM2/11/16
to Firebase Google Group
OMG Amanda thanks!! that did the trick i just had to move that line up 

 use_frameworks!

pod 'Firebase', '>= 2.5.0'

target 'MyAppName' do


end


target 'PitzTests' do


end


target 'PitzUITests' do


end

Reply all
Reply to author
Forward
0 new messages