Description
[REQUIRED] Step 1: Describe your environment
- Xcode version: Xcode 12
- Firebase SDK version: 6.33.0
- Firebase Component: Remote Config
- Component version: 4.9.0
- Installation method: CocoaPods
- Platform: tvOS
[REQUIRED] Step 2: Describe the problem
tvOS is a more controlled ecosystem than iOS. In particular local storage use is limited, some locations not being writable in comparison to iOS.
The local Firebase Remote Config database, in particular, is currently stored within the Application Support folder. This location is sadly not writable on tvOS, resulting in the I-RCN000019 error being logged to the console. This of course means that the local Firebase Remote Config database cannot be created and that configuration updates will not be persisted correctly.
Note that this behavior is only observed on a physical Apple TV device. The simulator, while in general quite accurately mirroring the behavior of a physical device, namely does not prevent write attempts to these locations.
Steps to reproduce:
I attached a very simple example to this issue. It only initializes the FirebaseApp
and a RemoteConfig
in its application delegate, which suffices to see the problem:
- Unzip the attached zip file.
- Run
pod install
from the project root to integrate Firebase. - Open the sample project with Xcode 12.
- Add a
GoogleService-Info.plist
file to the project. There is no need for the configuration to be a perfect match, as Firebase will still attempt to create the local remote config database. - Edit your target and set an app id as well as a development team.
- Run the example on an Apple TV device (the project targets tvOS 14).
You will notice a message similar to the one below logged to the console:
FirebaseExample[563:42589] 6.33.0 - [Firebase/RemoteConfig][I-RCN000019] Failed to create subdirectory for database file: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “RemoteConfig” in the folder “Google”." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/5CBFFB1D-2F67-436E-BE10-8E75F8C1F830/Library/Application Support/Google/RemoteConfig, NSUnderlyingError=0x28320ccc0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}.
Relevant Code:
A basic setup of Firebase with remote config suffices to show the issue:
import Firebase
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var remoteConfig: RemoteConfig?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
remoteConfig = RemoteConfig.remoteConfig()
return true
}
}
Possible solutions:
To solve this issue Library/Caches
could be used instead. This would of course introduce a difference in behavior since:
Library/Application Support
is backed up and never purged.Library/Caches
is not backed up and might be purged if space needs to be made available.
As far as I could see the Firebase database is some kind of cache which can be rebuilt even if cleaned. This is why I think Library/Caches
could be considered a viable option for tvOS, probably for iOS as well.
Impact for other Firebase components:
This issue only discusses problems with Firebase Remote Config on tvOS devices. Though I haven't checked it is likely that some other Firebase components might attempt to write files in similarly forbidden locations on tvOS.
These components should probably considered separately depending on their requirements so that a suitable location can be applied for each.
Thanks in advance for having a look at this issue!