firebase quickstart ios sample - ios

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.

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:
git clone https://github.com/firebase/quickstart-ios.git
cd database
pod update
open DatabaseExample.xcworkspace and select the DatabaseExampleSwift target in the drop down (to the right of the "Build And Run" and "Stop" buttons)
go to https://console.firebase.google.com and register a new app with the bundle ID com.google.firebase.quickstart.DatabaseExample
Take the GoogleService-Info.plist file that is downloaded, and drag it into XCode.
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.
Hit the "Build And Run" button! You can run the sample on a simulator or on a real device if you have one provisioned.

Take a look here, they have own sample. You have to modify them for you.
https://www.raywenderlich.com/139322/firebase-tutorial-getting-started-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.
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:
Where to add Firebase Database Reference in iOS Obj-C
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 !!

Related

How do I remove Cocoapod pods from a Flutter project?

I have a Flutter app that runs fine on Android devices. It has a Firebase Firestore backend.
Now, I want to build it on an iOS simulator, and so I need to initialize the Firebase iOS app. (I had only initialized the Android version before.) So I tried following the steps on firebase.com for setting up the iOS Firebase app using Cocoapods... but I think I did something wrong! More specifically, I believe the steps I followed were for adding Firebase to a native iOS app (in Objective C or similar), but when using Flutter, I'm supposed to let the Flutter framework do most of this work, rather than adding pods manually! (Here's a specific instruction for adding Firebase to a Flutter iOS project)
But before doing it right, I want to remove the pods that Cocoapods installed for me. Only I don't know how! 😣 When I web-search, I'm told to delete the pods I don't want from the Podfile. Only there ARE no pods in my ios/Podfile! There's only a bit that says:
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
There's also an ios/Podfile.lock file, and THAT one has a list of all the pods... And then, there's an ios/Pods/Manifest.lock file, which also has such a list... So should I delete the unwanted pod names from one of these two files, instead?
Or otherwise, how do I uninstall my Cocoapods pods, when they are not listed in the ios/Podfile?
Turns out the correct way to install and remove pods from a Flutter project is just to edit the pubspec.yaml file in the root directory!
Cocoapods needs to be installed, but it will automatically read the pubspec.yaml file and do the work from there! 🙂 No need to run pod commands from terminal or otherwise.
I suppose you followed these steps? in this case, you don't need to remove pods.
For step 1, step 2, it should be fine.
For step 3, just remove the config file.
For step 4, if you added firebase with swift package manager, remove it from your packages.
I'm supposed to let the Flutter framework do most of this work, rather than adding pods manually!
How did you add pods manually? from your Podfile, I didn't see any new added pods.
Or otherwise, how do I uninstall my Cocoapods pods, when they are not listed in the ios/Podfile?
You don't need to do anything, in worst cases, just remove the Podfile and re-run the app to let flutter regenerate it.

After installed framework from pods, not able to import in class in Swift project

I have installed some framework by pod file in my Xcode project. I am using Xcode 9.2. Its installed successfully, but, while trying to import that third party framework to my main class, showing no such module found.
Even tried so many times complete clean and rebuild. But, still showing the error No such module found OR Cannot load underlying module for XLPagerTabStrip.
In framework search paths it's showing like below PFA.
If you face No such module found XLPagerTabStrip, then:
1) Click on your app name on side of a select simulator for a run and click on the manage scheme.
2) Try to find XLPagerTabStrip And checked it and close it.
3) Then click on the app name where you can see XLPagerTabStrip.
4) Then click on it then clean build project and again choose your app and then again clean and build.
where you have to click in the screenshot. you can find Demo
Couple of things you can follow :
Clean project + Remove derive data and build again.
Check the Pods project on Xcode and make sure your pod exists in the Pod folder under Pod project.
Add the Pod in Embedded Framework in project settings.
Edit your scheme :
Scheme menu > Manage Schemes > check Pods > Close
Select Pods from the scheme menu.
Build Pods.
Select your project from the same menu, then build/run it.
Reinstall Pod :
pod deintegrate
pod install
Make sure you are correctly setting the pod in Pod file. Refer to original Github page of the library for the correct format.
First clean your code
right after pod installation is complete, build it once. Don't import pod files till now.
After build is succeeded now you will be able to import pod files.
You can try going to
General -> Linked FrameWorks and Libraries
Click on plus button and search your installed pod(installed as framework, if UserFrameWork! is mentioned in podFile) and press Add.

iOS Admob Firebase SDKs with/without cocoapods

I was trying to add cocoapods for admob firebase in my iOS app. But pod intsall command took too much time. Now i want to add firebase admob directly without cocoapods.
I have downloaded whole SDK from https://dl.google.com/firebase/sdk/ios/3_5_2/Firebase.zip .
It shows several folder with like AdMob Analytics, AppIndexing, Auth,Crash, Database,DynamicLinks, Invites, Messaging, RemoteConfig, Storage.
For cocoapods, we see they import firebase in .h file and add [Firebase configure] method.
What for SDK? Do I need to use only AdMob folder here? do I need to use the whole SDK? How would it need to be implemented?
Finally, i figured it out. import firebase is not working anymore. Hope the documentation is not updated properly.
Anyone should directly integrate Firebase to your project. And the documentation is not updated still. There is a issue there. Follow 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.
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:
Where to add Firebase Database Reference in iOS Obj-C
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 !!

Integarte/Install cocoapods to existing xcode project, objective-c or swift

I was looking for integrating cocoapods to my existing xcode projects.
I found these few post but they are based on issue instead my problem.
not able to acess installed pods framework
How to add cocoapods to existing workspace not project (this one is for work-space not project)
Making a CocoaPod from an existing Xcode project (this one is more on integrating swift with objective c project)
So I spending quality time i did for my project.
I am sharing step by step integration in my answer post.
please feel free to suggest and improvement.
happy to learn and share
Install CocoaPods on System
Step.1 Open Terminal and enter the following command:
sudo gem install cocoapods
Create Podfile for Project
Step.2 now you need to close Xcode.
Open Terminal at project's root folder
Step.3 Next, enter below command to create podfile:
pod init
Edit podfile
Note: Make sure we will edit podfile with Xcode not TextEdit etc.
Step.4 Type this command to open the Podfile using Xcode for editing:
open -a Xcode Podfile
Step.5 update pode file as shown below screenshot, save and close.
Install lib/framework
Now we have added our required lib/framework pod command
pod 'SwiftForms'
let's go for install
Step.5 Enter the following command in Terminal and hit Enter
pod install
Result screen
Thats it!! we have done.
Open Project with pods
Now go to the project folder,we can see that CocoaPods created a new project_name.xcworkspace file and a Pods folder.
open project_name.xcworkspace with xcode
your project structure should look like

How to install Quick and Nimble in Xcode 6.3

I've tried both cocoapods and git submodules but everytime I install the framework it wont build. Has anyone been able to install it. Both quick and nimble I use the code on the master branch. I also am using Swift 1.2 with xcode 6.3. It seems the framework is not getting compiled into the project. I realize sometimes when you link a framework to the workspace it goes red in the build phase area but would still work. But my quick and nimble framework references turn red randomly. I've set them in my test target only and tried to create a quick test in Objective-C and also tried swift but it just says build failed and then the framework link goes red. Has anyone been able to install it?
the formal install instructions should be here
UPDATE: I'M ABLE to install quick and nimble (on master branch) using cocoaPods but not git subModules. The project I'm using I've been instructed not to use Pods so I need to use git subModules. the IDE reports the following error and fails any test:
IDEBundleInjection.c: Error 3587 loading bundle '/Users/someUserID/Library/Developer/Xcode/DerivedData/myproduct-aadhzxcsaigkzsgjyneytqrocsjc/Build/Products/Debug-iphonesimulator/myproductTests.xctest': The bundle “myproductTests” couldn’t be loaded because it is damaged or missing necessary resources.
DevToolsBundleInjection environment:
XCInjectDiagnostics: (null)
edit Podfile
use_frameworks!
target 'YourAppNameTests' do
pod 'Quick'
pod 'Nimble'
end
run
pod install
Follow the steps to reliable setup of Quick and Nimble:
Prerequisites:
cocoapods installed in your machine (installation Guide)
1) create a new Xcode project
Xcode—> File —> New —> Project
2) Select Single View App (Normally most of the application use this) —>Next
Enter Product Name (App NAme) - (here we are using WeatherForecast)
enable check mark for Include Unit Tests
3 )Installation
Open terminal
Move to your working directory cd (path of your project folder)
Ex: enter in terminal
cd /Users/Documents/ WeatherForecast
4) Initialise pods with
Pod init
5) Open the newly created Podfile within your favourite text editor.
edit podfile with below contents
platform :ios, '9.0'
target WeatherForecast’ do
use_frameworks!
target 'WeatherForecastTests' do
inherit! :search_paths
pod 'Quick'
pod 'Nimble'
end
5) Save the podfile.Return to terminal and
enter pod install in terminal
6) This will install your new frameworks and create a pods project. It will also generate a workspace. You should now use the new workspace when working on your project. So if you’ve opened your project already close it and in open the WeatherForecasr.xcworkspace instead.
7) Setting up your test class
Within your tests target create a new group and file by:
Highlighting WeatherForecast Tests.
File —>New—> Group
Rename the new Group ModelTests
Highlight your new group
File —>New —> File
Select Swift file, Press Next
Name the new file CurrentSpecs . Press create
7) Within your new file replace the contents with the following
import Foundation
import Quick
import Nimble
#testable import WeatherForecast
class CurrentWeatherSpecs: QuickSpec {
}
After this you might face an error
“No such Module Quick”
“No such Module Nimble”
Below steps worked to Fix the error
Try the Following:
open Xcode schemes list
tick Nimble and Quick with “show” and close.
Select Nimble as a scheme and build (cmd + B)
Select Quick as a scheme and build(cmd+B)
Change scheme back to your app scheme and see if the error is gone and autocompletion works
This is what I have to do from time to time
Turns out if i add a single swift file to the test then all of a sudden the IDE can link the frameworks quick and nimble together. Very frustrating this was not in the README file.
solution: create a single swift file and add to your test target:
// Swift_Spec_doNotRemove.swift
import Quick
check here for further info.

Resources