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
Related
I am looking to integrate Firebase Analytics SDK into my apps, to be able to link with Google Ads so we can track ad campaign and attribution. Since our apps target kids space, we are not allowed to use any IDFA capabilities by Apple, so using anything like AdSupport.framework or ATT (App Tracking Transparency) it will risk app rejection. So, that leaves SKAdNework. According to Firebase Notes (https://firebase.google.com/support/release-notes/ios#version_6290_-_july_28_2020), SKAdNetwork will register for AdNetwork attribution automatically called on first open by default, and by setting the following key GOOGLE_ANALYTICS_REGISTRATION_WITH_AD_NETWORK_ENABLED YES in our Info.plist file, should opt in to this default behaviour. However, I have no way to verify this on device (i.e. I see no console message on the device, nor can't find this call in the code [SKAdNetwork registerAppForAdNetworkAttribution])
Is there anything else I am missing? Do I need to add SKAdNetwork Identifiers to my plist file, like this (https://developers.google.com/admob/ios/ios14#skadnetwork)?
Bellow is a sample copy of my pod file:
target 'UnityFramework' do
pod 'Firebase/AnalyticsWithoutAdIdSupport', '8.6.0'
pod 'Firebase/DynamicLinks', '8.6.0'
pod 'Firebase/InAppMessaging'
pod 'Firebase/Messaging', '8.6.0'
pod 'Firebase/RemoteConfig', '8.6.0'
end
Is it possible to access the shared keychain in WatchOS 4+?
I've set the exact same Keychain Sharing > Keychain Group of the iOS app (which syncs perfectly with a MacOS app), but all it finds is an empty object.
I'm using this library (https://github.com/kishikawakatsumi/KeychainAccess) which works really well on iOS and MacOS, but not on WatchOS.
I shared the Target Membership of the classes involved to the Watch Extension (and I think it works, otherwise it would throw an error that was able to get the method or so), added the pod to watchOS like this
use_modular_headers!
def shared_pods
pod 'KeychainAccess'
end
target 'Watch Extension' do
platform :watchos, '4.0'
shared_pods
end
My question is: am I missing some configurations? It looks like it is able to access the local keychain, but cannot sync with the shared one.
Thanks
I was attempting to do the same thing, and it's a great pod to use to make the keychain easy to work with. However the part that needs to work is the iCloud Synchronizing for it move the data like you are thinking.
According to the current Apple Docs, in the notes under the Storing Data Securely in the Keychain
NOTE
The kSecAttrSynchronizable key is not available in watchOS.
Without that, the WatchOS can not get the keychain data you have stored over on the iOS side. So you're doing the pods right, and it's a good pod, but WatchOS doesn't want us doing that.
TLDR; - You can't do it at this time.
Can we use sinch api to create an instant message app in swift? I tried to import sinch framework in a swift app but after importing I could not import the sinch class into my application. Help please.
Use CocoaPod to install your framework, might be easier.
how to install Pod
in your podfile
target 'YourApp' do
pod 'SinchRTC ', '~> 3.1.0'
end
open the YourApp.xcworkspace with xcode.
Now, In your file you will just have to import something like
import Sinch
and it might be good.
CocoaPod is really usefull for dependencies. it help you to install / uninstall framework very easily. it's also very nice when you work in team.
Note : change YourApp by your target name
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
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.