-4

I am new to iOS and trying to run one of the quickstart sample of Firebase Database iOS samples provided on git hub.

The project contains swift folder and objective c folder. The objective c folder contains the storyboard and other info.plist files. But the swift folder contains only the .swift files, no storyboard or other files. How can I run the sample project for swift code.

The sample project also doesn't have an images.xcassets folder in it.

I am aware about the cocoa pods and Firebase setup for project.

Please try to run the sample provided by firebase on git and let me know how to solve the problem.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

2 Answers2

4

Swift and Objective-C are different targets of the same project for each of the samples - that means you switch between the two languages in XCode itself. To run them, you'll need XCode 8 and a recent install of Cocoapods. The steps are:

  1. git clone https://github.com/firebase/quickstart-ios.git
  2. cd database
  3. pod update
  4. open DatabaseExample.xcworkspace and select the DatabaseExampleSwift target in the drop down (to the right of the "Build And Run" and "Stop" buttons)
  5. go to https://console.firebase.google.com and register a new app with the bundle ID com.google.firebase.quickstart.DatabaseExample
  6. Take the GoogleService-Info.plist file that is downloaded, and drag it into XCode.
  7. Select the GoogleService-Info.plist and look at the the File Inspector in the right hand panel of XCode. Make sure under "Target Membership" the DatabaseExampleSwift checkbox is ticket.
  8. Hit the "Build And Run" button! You can run the sample on a simulator or on a real device if you have one provisioned.
Ian Barber
  • 19,765
  • 3
  • 58
  • 58
  • i have done and checked everything , what you have mentioned above , but i am getting this error . -- > Undefined symbols for architecture armv7: "_OBJC_CLASS_$_FIRMessaging", referenced from: objc-class-ref in AppDelegate.o ... do have any idea what to do ? – Moxarth Jun 30 '17 at 11:31
  • i may have pretty solved it . while installing in pod files , i have wrote that code under # Pods for testing instead # Pods for Project_Name . and i have checked it and figured it out . and now app is running . if i did not look for d pod installations , i could never had solved those errors . because those errors lead us to nowhere , and could not find out where the actual error was – Moxarth Jun 30 '17 at 12:12
3

Take a look here, they have own sample. You have to modify them for you.

  1. https://www.raywenderlich.com/139322/firebase-tutorial-getting-started-2
  2. https://www.appcoda.com/firebase/

Or

Better, don't go for it directly. I tried it for analytics. Better you directly integrate Firebase to your project. And the documentation is not updated still. There is a issue there. Follow my steps for analytics, add your database parameter from the video.

https://www.youtube.com/watch?v=joVi3thZOqc

https://www.youtube.com/watch?v=XIQsQ2injLo

Firebase and Admob for recommend to use cocoapods.

This contains 4 separate steps:

-Link with firebase

-Download GoogleService-Info.plist

– Update cocoapods

– init Firebase in app.

Link with Firebase: This is just creating a connection Firebase with Admob app. From the console top right menu, there is a button to connection with firebase.

Console link : https://console.firebase.google.com/?pli=1

Download plist file : It’s free and just takes a few minutes. When asked for a Bundle ID, enter the Bundle ID from the project you want to use for testing.

Once you have a GoogleService-Info.plist file, save it in the same directory as the rest of the XCODE project source.

Update cocoapods and install pod: Now go to project directory from command terminal.

Run this command, this will install cocoapods

     sudo gem install cocoapods

When cocoapods installation is complete, start adding to your projects with this command.

    pod init

This command will create pod file in projects directory. You can add the rest command from terminal but also can be done by opening the file directly. I have done it for admob my project.

   source ‘https://github.com/CocoaPods/Specs.git’

   # platform :ios, ‘7.0’
   pod 'Firebase', '>= 2.5.0'
   target 'projectname' do
   pod ‘Firebase/Core’
   pod ‘Firebase/AdMob’
   pod ‘Firebase/Database’
   end

Save the file and go to command line again. Now run any of this two command.

 pod install

OR

 pod install –verbose

Second one worked for me. I got some bad file issue with first command. This may take more than 2 hours for the first time. Got solution from this link : cocoapods - 'pod install' takes forever

When this complete, you will get some yellow line that firebase , admob and other necessary framework successfully added to your projects with cocopods.

  1. Init FireBase (Most important step *** ) :

Google changes their framework but did not updated their documentation because the way is not working currently.

You may get some issues still: Check you project settings -> Other Linker Option and set it $(inherited). And Don’t forget to set Build architecture YES

Now you have to import Firbase and work for configuring it.

    @import Firebase, this line is not working anymore. 

So you have, import this like :

 #import <Firebase/Firebase.h>

Now configure you Firebase in didFinishLaunchingWithOptions method using

[FIRApp configure];

This is for analytics. To init Database, follow this link:

  1. Where to add Firebase Database Reference in iOS Obj-C
  2. iOS : Objective-C : Firebase : Is it possible to read the cached data first for any reference?

CLEAN, BUILD AND RUN. Hope everything should works fine. You will see few line in your logs that Firebase has been started configuring projects. Happy Developing !!

Community
  • 1
  • 1
Jamshed Alam
  • 12,424
  • 5
  • 26
  • 49
  • i have done and checked everything , what you have mentioned above , but i am getting this error . -- > Undefined symbols for architecture armv7: "_OBJC_CLASS_$_FIRMessaging", referenced from: objc-class-ref in AppDelegate.o ... do have any idea what to do ? – Moxarth Jun 30 '17 at 11:23
  • @Moxarth , it may help you : https://stackoverflow.com/questions/37344676/undefined-symbols-for-architecture-armv7-objc-class-firapp – Jamshed Alam Jun 30 '17 at 11:39
  • i may have pretty solved it . while installing in pod files , i have wrote that code under # Pods for testing instead # Pods for Project_Name . and i have checked it and figured it out . and now app is running . if i did not look for d pod installations , i could never had solved those errors . because those errors lead us to nowhere , and could not find out where the actual error was . – Moxarth Jun 30 '17 at 12:10
  • thanks . your steps helped me to re-check my code procedure and i caught my mistake .@Jamshed – Moxarth Jun 30 '17 at 12:19