Firebase Class FIRAAppEnvironmentUtil is implemented in both when using Cocoapods - ios

I'm trying to use Firebase inside a dynamic framework (Cocoa Touch Framework). I've added Firebase to the Podfile like so:
platform :ios, '9.0'
use_frameworks!
workspace 'Test.xcworkspace'
target 'Test' do
project 'Test.xcodeproj'
end
target 'TestFramework' do
project 'TestFramework/TestFramework.xcodeproj'
# Pods for TestFramework
pod 'Firebase/Database'
pod 'Firebase/Auth'
end
And I've set a target dependency in the build phase of my Test target. All according to: https://github.com/benasher44/CocoaPodsLibExample
However when I reference my TestFramework from my Test target during app startup I get this message (for all the Firebase classes) in the console:
objc[34978]: Class FIRAAppEnvironmentUtil is implemented in both
/Users/peterwarbo/Library/Developer/Xcode/DerivedData/Test-goxvmnklbfyswhdniydzbvzudcez/Build/Products/Debug-iphonesimulator/TestFramework.framework/TestFramework
(0x1085858c8) and
/Users/peterwarbo/Library/Developer/CoreSimulator/Devices/43080C45-C9E9-4237-A255-5029CC4D5797/data/Containers/Bundle/Application/FCFDC439-8564-40A8-9B34-935FE222193E/Test.app/Test
(0x104342938). One of the two will be used. Which one is undefined.
And the app crashes. I've read that this might have something to do with that Firebase is a static library. I need to solve this so I can use my use Firebase from my different targets. Specifically what I'm trying to achieve is to be able to do Firebase operations from a keyboard extension, so both my host app and my extension should be able to to perform Firebase operations.
I've been trying to solve this for more than a week now and I haven't come up with any working solutions :(
I'm using Xcode 8.2.1, Cocoapods 1.2.0

Related

Transaction Manager not showing storekit 2 transactions in Xcode

I am trying to test in-app purchase localy using configuration.storekit file.
I'm able to do perform the fetch, buy, restore, etc on the simulator, but the same is not getting displayed on the Transaction Manager [(with Xcode selected) Debug->Storekit->Manage Transactions...]
Also, I am not able to fetch the products using product IDs in the testcases using StoreKitTest framework
I have use pod lib create to make a cocoapod of MyFramework which is having all the In-App purchase related code/logic. Have a target for testcases (MyFramework-Unit-Tests), have tried linking the StoreKit Configuration File with both the MyFramework and MyFramework-Unit-Tests targets, and without linking too
I have created a file IAPSubscriptions.storekit, and have tried specifying target to it - MyFramework, MyFramework-Unit-Tests
Has anyone faced these issues, and how shall I resolve these?
For reference:
Modularisation followed by me is wrt: https://github.com/kudoleh/iOS-Modular-Architecture
My podfile has:
def MyFramework_pod
pod 'MyFramework', :path => 'DevPods/MyFramework', :testspecs => ['Tests']
end
abstract_target 'MyFramework' do
project 'DevPods/MyFramework/Example/MyFramework.xcodeproj'
target 'MyFramework_Example' do
platform :ios, '15.0'
MyFramework_pod
end
end
My podspec has:
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = 'MyFramework/Tests/**/*'
end
I resolved the issue by adding the StoreKit.framework as a dependency to the app project.

Unable to build React Native project on iOS: No component found for view with name "ARTShape"

I receive the following error when I try building a React Native app on iOS:
No component found for view with name "ARTShape"
I don't have any such problems on Android. I've tried the solution here but it's not working: in Xcode, after making those changes and pressing CMD+B, I am receiving the following error under the category Lexical or Preprocessor Issue:
'React/UIView+React.h': file not found
Use POD linking ART library like this:
1) Add ART to pod file
pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'
2) run pod update to ios directory.

How to add Firebase to Today Extension iOS

I need to be able to use Firebase in my Today View Extension, however I cannot seem to import the Firebase module. I think it's because I need a new target in my cocoa pods file, but I'm not sure on how to do this.
Thanks.
You have to treat the today extension as its own separate app(somewhat)
in your firebase project dashboard, you need to hit the "Add another app" button.
select iOS and then enter the BUNDLE ID of your TODAY EXTENSION
Complete the wizard and download the generated GoogleService-Info.plist file
Add the plist file to your Today Extension's root folder
go to your xcode project, and manually add FirebaseCore.framework and FirebaseDatabase.framework to your Today Extension
finally inside your today today viewcontroller call FirebaseApp.configure()
import FirebaseDatabase
import FirebaseCore
override func viewDidLoad() {
super.viewDidLoad()
FirebaseApp.configure()
}
Or without adding an extra app at the Firebase console, just re-use your main project's GoogleService-Info.plist with a minor modification (see below). The Firebase app singleton would have to be configured either way in both apps on startup.
To synchronize an extension and the containing app see App Extension Programming Guide: Handling Common Scenarios or this reddit comment. This Stackoverflow thread specifically describes this scenario.
Steps:
Copy the containing app's GoogleService-Info.plist into your extension in Xcode
Drag the copied GoogleService-Info.plist into Xcode into your share extension and
Change the BUNDLE_ID to the name of your share extension's target
Add new target to your Podfile
Install dependencies (pod install)
Configure the Firebase application object in your extension
Step 1. Copy the containing app's GoogleService-Info.plist into your extension in Xcode
Step 2. Drag the copied GoogleService-Info.plist into Xcode into your share extension and
Step 3. Change the BUNDLE_ID to the name of your share extension's target
For us the main (i.e., containing app) is Access News and the share extension is Access-News-Uploader.
Step 4. Add new target to your Podfile
# ...
target 'name-of-your-extension' do
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Auth'
# etc.
end
Entire Podfile of our project.
Step 5. Install dependencies (pod install)
Step 6. Configure the Firebase application object in your extension
/* 1. Import Firebase */
/**********************/
import Firebase
/**********************/
class WhereverInYourExtension: WhateverController {
// ...
override func viewDidLoad() {
super.viewDidLoad()
/* 2. Configure Firebase */
/*************************/
if FirebaseApp.app() == nil {
FirebaseApp.configure()
}
/*************************/
// ...
}
Pod issue fixes
1) Still unable to import Firebase!
Make sure that pods are installed for all targets in your project. To achieve this use inherit! or abstract_target in your Podfile.
The simplest example using abstract_target from the official documentation:
abstract_target 'Networking' do
pod 'AlamoFire'
target 'Networking App 1'
target 'Networking App 2'
end
For inherit!, see this SO question and answer.
2) How do I achieve this on my existing app without messing things up?
Remove Podfile, Podfile.lock and YourProject.xcworkspace
Issue pod init and it will list your existing targets one by one.
Edit the Podfile by either grouping under abstract_target or using inherit!
Issue pod install
A new YourProject.xcworkspace file will be generated, and if you open the your project using this, under General > Linked Frameworks and Libraries it will show that Firebase is added and can be imported from project files.
(See this SO thread for a concrete example where this clean-up method needed to be used.)
3) firebase 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
This is what worked for me:
wiped everything clean by cloning our project repo fresh from Github,
deleted
~/Library/Developer/Xcode/DerivedData
./Pods/
Podfile
Podfile.lock
Issue pod init on the console
Recreate Podfile (basically copy-paste)
Issue pod update on the console
(Probably won't work next time.)
To my knowledge widgets are not allowed to use certain api's such as firebase. Widgets are supposed to show data provided by the main application via UserDefaults e.g.
TodayViewExtensions (or widgets) may only be very light codewise.

Integrating Parse in App extension

I’m trying to implement parse functionality in a app extension. The main app uses Parse to push and retrieve data. The problem is I can't install the parse SDK to my app extension. Is this even possible? I've been on google for about three hours and I’m starting to think not. I've tried to init another pod file and I’ve tried the the abstract_target function. No matter what I do, I can't seem to import it. Has anyone achieved this before? Im using swift 2.0 if that helps.
If there is another way to carry out the following, please let me know:
(This happens in the share popup view)
1.Grab user input text
2.Push it to the parse backend
in order to use Parse ios SDK in your app extension you are require to do the following:
enable local data store (local data store is where your data is being saved locally on your device)
Enable app groups and keychain sharing in both of your targets (your main app and your extension) this allows you to share the data and the session between your app and your extension.
When i did it. I follow this guide which explain how to integrate apple watch and app extension with parse IOS SDK.
If you are using CocoaPods in your project please make sure that you load the Parse pod also to your extension..
so let's assume that the only pod that you have in your Podfile is pod 'Parse' you Podfile should look like the following
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
def my_pods
pod 'Parse'
end
# Change the MainAppTargetName to your main app target
target 'MainAppTargetName' do
my_pods
end
# change MyExtensionTargetName to your extension target name
target 'MyExtensionTargetName' do
my_pods
end

Error setting up Firebase in Xcode

I have tried to set up Firebase to work on Xcode using both the quick setup instructions and the manual alternate instructions on Firebase website.
When I used CocoaPods and followed the instructions on the quick setup page, I was able to import Firebase, but I was not able to reference Firebase inside the class. I got the error: Cannot call value of non-function type 'module' xcode
When I tried to set it up manually, I was not able to import or reference Fire base and I got the error: No such module 'Firebase'
I had the same issue when updating my project to the new version of Firebase. A TON of changes were announced at Google I/O and thus there is a good amount of updating to be done.
It sounds like you might be using the old version of Firebase with the new SDK. You should do everything with Firebase 3.0. Hence var rootRef = Firebase(url:"https://<YOUR-FIREBASE-APP>.firebaseio.com") will now be var rootRef = FIRDatabase.database().reference().
Take a look at the setup guide at: https://firebase.google.com/docs/ios/setup#prerequisites (be sure you aren't looking at the legacy docs!). If you want to convert code from the old version of Firebase to 3.0, check out the Upgrading tutorial: https://firebase.google.com/support/guides/firebase-ios#get_a_database_reference_numbered
You should try to manually edit your podfile to something like:
use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Auth'
I use these directives to get it working with Xcode 7.3.

Resources