I can’t connect to my database. I followed all the steps and I even had to recreate it. Anyone had any similar issues or know how to resolve this?
2023-01-28 14:01:09.944917-0600 Socialcademy[18298:5617783] 10.5.0 - [FirebaseFirestore][I-FST000001] Write at posts/28617F89-5600-4E0B-9963-F52868E00FB9 failed: Missing or insufficient permissions.
[NewPostForm] Cannot create post: Error Domain=FIRFirestoreErrorDomain Code=7 "Missing or insufficient permissions." UserInfo={NSLocalizedDescription=Missing or insufficient permissions.}
These are the other error messages in the console above.
2023-01-28 14:00:55.393987-0600 Socialcademy[18298:5616856] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
2023-01-28 14:00:55.394271-0600 Socialcademy[18298:5616856] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
2023-01-28 14:00:55.397519-0600 Socialcademy[18298:5616856] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
2023-01-28 14:01:00.551653-0600 Socialcademy[18298:5616856] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)")
2023-01-28 14:01:09.941788-0600 Socialcademy[18298:5617783] 10.5.0 - [FirebaseFirestore][I-FST000001] WriteStream (132d74508) Stream error: 'Permission denied: Missing or insufficient permissions.'
I set up my Firebase database and brought in the right packages onto Xcode. Following all the steps, the Firebase was ready to go. When I ran my app, the error messages popped up, and the database was unresponsive to the action.
I initialized my Firebase:
import SwiftUI
import Firebase
#main
struct SocialcademyApp: App {
init() {
FirebaseApp.configure()
}
var body: some Scene {
WindowGroup {
PostsList()
}
}
}
And I tried to connect to my database:
import Foundation
import FirebaseFirestore
import FirebaseFirestoreSwift
struct PostsRepository {
static let postsReference = Firestore.firestore().collection("posts")
static func create(_ post: Post) async throws {
let document = postsReference.document(post.id.uuidString)
try await document.setData(from: post)
}
}
private extension DocumentReference {
func setData<T: Encodable>(from value: T) async throws {
return try await withCheckedThrowingContinuation { continuation in
try! setData(from: value) { error in
if let error = error {
continuation.resume(throwing: error)
return
}
continuation.resume()
}
}
}
}
Related
I'm reading about some good practices for developing iOS apps and looking at the possibility of monitoring logs of an iOS app installed from App Store using Console.app. So, I was testing here, but I noticed that print statements didn't show up in Console.app, only NSLog does. My question is: is there any way that is possible to see logs that are made with print commands within iOS apps installed on a device? With Frida, Console.app or any other means?
If there is no other method, does it mean that print commands are more secure than NSLog? This seems very counterintuitive to me 🤔
print statement in iOS apps are not logged to one the [persistent] logging systems on iOS, therefore you can not access the output of an app via print statements if they had occur in the past.
By default you can only seem the output of print commands in XCode output panel. However the print commands themselves are always included in the debug and release builds and are therefore executed. Just the output of the print statements is discarded if no XCode is connected to retrieve it.
I tested this by building the following SwiftUI test app (see the end of this answer), made sure the Archive profile is set to RELEASE and the archived the project, to build an IPA file.
The IPA file was then analyzed in IdaPro to see the actual ARM assembler code.
And in all tests using different options (e.g. "Rebuild from Bitcode" (de)activated) the code was always there.
Therefore if you attach Frida to an app you can e.g. hook the print method print(_:separator:terminator:) to retrieve all output that would otherwise be discarded.
struct ContentView: View {
#State var number : Int = 1
var body: some View {
VStack {
Button(" Print ") {
print("print test abcdefgh number %d", number)
}.padding()
Button(" os_log ") {
os_log("os_log test abcdefgh number %d", number)
}.padding()
Button("randomize") {
self.number = Int.random(in: 1...11111)
}.padding()
}
}
}
If, and only if, you want to use print and printf in your app to go to a file or whatever file descriptor:
import SwiftUI
import Darwin
import os.log
extension OSLog {
private static var subsystem = Bundle.main.bundleIdentifier!
static let `default` = OSLog(subsystem: subsystem, category: "default")
}
extension TestApp {
func subscribeFileToStderrAndStdoutIfNotAttachedToDebugger() {
if isatty(STDERR_FILENO) != 1 {
let documentsUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let logfileUrl = documentsUrl.appendingPathComponent("out.log")
logfileUrl.withUnsafeFileSystemRepresentation { path in
guard let path = path else {
return
}
print("redirect stdout and stderr to: \(String(cString: path))")
let file = fopen(path, "a")
assert(file != nil, String(cString: strerror(errno)))
let fd = fileno(file)
assert(fd >= 0, String(cString: strerror(errno)))
let result1 = dup2(fd, STDERR_FILENO)
assert(result1 >= 0, String(cString: strerror(errno)))
let result2 = dup2(fd, STDOUT_FILENO)
assert(result2 >= 0, String(cString: strerror(errno)))
}
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
subscribeFileToStderrAndStdoutIfNotAttachedToDebugger()
return true
}
}
Im getting the error in the title when I run my app. I am running Xcode Beta 10 Version 6. The full error is:
[NetworkInfo] Descriptors query returned error: Error Domain=NSCocoaErrorDomain Code=4099 “The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.” UserInfo={NSDebugDescription=The connection to service named com.apple.commcenter.coretelephony.xpc was invalidated.}
It gets thrown in my createTaskFromSnapshot() function, on the first line of the function.
My code:
func observeDatabase(_ tableToUpdate: UITableView) {
taskDatabase.observe(.childAdded) { (snapshot) in
self.handleChildAdded(snapshot: snapshot)
tableToUpdate.reloadData()
}
}
private func handleChildAdded(snapshot:
let addedTask = createTaskFromSnapshot(snapshot)
taskList.append(addedTask)
}
private func createTaskFromSnapshot(_ snapshot: DataSnapshot) -> Task {
let snapshotValue = snapshot.value as! Dictionary<String, String> // error is thrown here
let taskTitle = snapshotValue["taskTitle"]!
let newTask = Task(title: taskTitle)
return newTask
}
What does this error mean? and why am I getting it?
The message is probably unrelated to the crash/issue.
I've had this message bother me for a while now with no way of removing it.
Well I've found a way to hide this in your xcode console just run one of the following command in a terminal:
xcrun simctl spawn booted log config --mode "level:off" --subsystem com.apple.CoreTelephony
sudo log config --mode "level:off" --subsystem com.apple.CoreTelephony
you can always re-enable this at anytime by running the same command with a different level attribute`
Try this:
1- From Xcode menu open: Product > Scheme > Edit Scheme
2- On your Environment Variables set OS_ACTIVITY_MODE = disable
In my case this type of warning was generated in the case when CTTelephonyNetworkInfo() was used. As this error only generated on simulator I did like this:
#if targetEnvironment(simulator)
return []
#else
let networkInfo = CTTelephonyNetworkInfo()
return [networkInfo.subscriberCellularProvider]
#endif
I have been trying to get FireStore to work on Swift, but running into "FIRAuth getUID implementation wasn't set." and I cannot get to my data. I started with a Test app... completely new Firestore project. New iOS project in Swift. New Everything. I just want to read some data. THis is what I have so far...
xCode Version 9.3 (9E145)
FireStore rules
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
AppDeligate.swift
import UIKit
import Firebase
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
ViewController.swift
import UIKit
import Firebase
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let db = Firestore.firestore()
// this gives
// [Firebase/Core][I-COR000025] FIRAuth getUID implementation wasn't set.
// and I cant read data after ward.
}
NOTE: Add Firebase to your iOS APP.
Step 5...Run your app to verify installation
check_circle Congratulations, you've successfully added Firebase to your app!
So I know the app is connecting properly.
===========================
So I goto the FireStore docs at:
https://firebase.google.com/docs/firestore/quickstart
I add this code to ViewCOntroller.swift .
import UIKit
import Firebase
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let db = Firestore.firestore()
// this gives
// [Firebase/Core][I-COR000025] FIRAuth getUID implementation
wasn't set.
// and I cant read data after ward.
// Add a new document with a generated ID
var ref: DocumentReference? = nil
ref = db.collection("users").addDocument(data: [
"first": "Ada",
"last": "Lovelace",
"born": 1815
]) { err in
if let err = err {
print("Error adding document: \(err)")
} else {
print("Document added with ID: \(ref!.documentID)")
}
}
}
And I get this error...
2018-04-30 09:17:34.410768-0400 t5[32887:825090] 4.10.0 -
[Firebase/Core][I-COR000025] FIRAuth getUID implementation wasn't
set.
2018-04-30 09:17:34.625631-0400 t5[32887:825100] TIC Read Status
[1:0x0]: 1:57
2018-04-30 09:17:34.625748-0400 t5[32887:825100] TIC Read Status
[1:0x0]: 1:57
==============================================
Error adding document: Error Domain=FIRFirestoreErrorDomain Code=7
"Missing or insufficient permissions." UserInfo={io.grpc.HeadersKey={
"alt-svc" = "hq=\":443\"; ma=2592000; quic=51303433;
quic=51303432; quic=51303431; quic=51303339;
quic=51303335,quic=\":443\"; ma=2592000; v=\"43,42,41,39,35\"";
"content-disposition" = attachment;
date = "Mon, 30 Apr 2018 13:17:35 GMT";
}, NSLocalizedDescription=Missing or insufficient permissions.,
io.grpc.TrailersKey={
"content-disposition" = attachment;
}}
=========================================
My suspicion is that there is an Auth Issue, but I have my rules set to wide open. I followed instruction perfectly. I get the sence that I have to have some sort of Auth certificate.
That said, ultimately, all I want to do is read data from this site.
So, any thoughts out there what I am doing wrong?
==============================================
I added more Post data and Read Data . and still getting...
`===============================
=====btn READDATA =======
Error getting documents: Error Domain=FIRFirestoreErrorDomain Code=13 "An internal error occurred." UserInfo={NSLocalizedDescription=An internal error occurred.}
2018-04-30 12:01:00.004048-0400 t6[342:28839] Status bar could not find cached time string image. Rendering in-process.
=====btn POSTDATA =======
Error adding document: Error Domain=FIRFirestoreErrorDomain Code=7 "Missing or insufficient permissions." UserInfo={io.grpc.HeadersKey={
"alt-svc" = "hq=\":443\"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=\":443\"; ma=2592000; v=\"43,42,41,39,35\"";
"content-disposition" = attachment;
date = "Mon, 30 Apr 2018 16:01:01 GMT";
}, NSLocalizedDescription=Missing or insufficient permissions., io.grpc.TrailersKey={
"content-disposition" = attachment;
}}`
I resolved the issue. My Cocoa Pods needed updating. Actually I did a completely new install of Cocoapds, but I recommend doing a pod update if you have this issue. Simple as that.
yes it was a stupid mistake, but I would like to thank the poster that down gradded me.
I'm writing an integration app harness that will test the functionality of our SDK in the real world and I'm planning to do so using iOS Action App extensions as subprocesses to initiate the Action Extensions as test cases. I followed the article below to accomplish that
https://ianmcdowell.net/blog/nsextension/
And so I created one action extension so far, which is to test starting the library manager of the SDK. It works on the simulator but when tested on the device the test fails, because it requires the Location Services to run the SDK.
I could override that service, but Xcode will generate this logs that complains about not accessing the NSUserDefaults. This adds 30 seconds of testing so I rather avoid that
2017-12-07 10:38:55.907542-0500 LibraryManagerTestExtension[2619:13235133] [User Defaults] Couldn't read values in CFPrefsPlistSource<0x1017041d0> (Domain: com.apple.Accessibility, User: kCFPreferencesCurrentUser, ByHost: No, Container: kCFPreferencesNoContainer, Contents Need Refresh: Yes): accessing preferences outside an application's container requires user-preference-read or file-read-data sandbox access, detaching from cfprefsd
2017-12-07 10:39:25.932663-0500 LibraryManagerTestExtension[2619:13235133] failed to open connection to AppleKeyStore
2017-12-07 10:39:25.933117-0500 LibraryManagerTestExtension[2619:13235133] Unexpected AppleKeyStore error: -536870212
2017-12-07 10:39:25.933951-0500 LibraryManagerTestExtension[2619:13235133] MKBDeviceUnlockedSinceBoot: MKBDeviceUnlockedSinceBoot fails with error(-1) for handle(0) with AKS error(-536870212)
2017-12-07 10:39:25.934237-0500 LibraryManagerTestExtension[2619:13235133] Attempting to create a background session before first device unlock!
2017-12-07 10:39:25.938302-0500 LibraryManagerTestExtension[2619:13235250] An error occurred on the xpc connection: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.nsurlsessiond was invalidated." UserInfo={NSDebugDescription=The connection to service named com.apple.nsurlsessiond was invalidated.}
Here are my codes. Hope you can provide me some guidance on what things I'm missing and needed to be added to get the permissions.
import Foundation
import IntegrationExtension
import VSTB
public class LibraryManagerTestExtension : NSObject, NSExtensionRequestHandling {
var extensionContext : NSExtensionContext!
var libraryManager : QPLibraryManager!
public func beginRequest(with context: NSExtensionContext) {
print("Beginning request with context: %#", context.description);
extensionContext = context
guard let configContent = getConfigContent() else {
extensionContext.cancelRequest(withError: QPError(code: -1, description: "ConfigContent is empty"))
return
}
startLibraryManager(configContent)
}
func getConfigContent() -> [String: Any]? {
//Get the config path, which is the 1st first of the input items
let inputItems = extensionContext.inputItems
print("Input Items: \(inputItems)")
assert(inputItems.count == 1)
let inputItem = inputItems.first as? NSExtensionItem
assert(inputItem?.attachments?.count == 1)
return inputItem?.attachments?.first as? [String: Any]
}
fileprivate func startLibraryManager(_ contentConfig: [String: Any]) {
let foo = isOpenAccessGranted()
print("Access: \(foo)")
let configuration = QPLibraryConfiguration(dictionary: contentConfig)
//Disable location services by overriding it with custom values. This adds 30 seconds of testing though, which needs to be avoided
configuration?.setStartupLibraryConfigurationValue(0, for: .IOS_LOCATION_MANAGER_MODE)
let userLocation : [String : Any] = ["country" : "IN",
"territory" : "",
"city" : "Chennai",
"latitude" : 0,
"longitude" : 0]
configuration?.setRuntimeLibraryConfigurationValue(userLocation, for: .USER_LOCATION)
libraryManager = QPLibraryManager()
libraryManager.delegate = self
libraryManager.start(with: configuration)
}
}
extension LibraryManagerTestExtension : QPLibraryManagerDelegate {
public func libraryManager(_ libraryManager: QPLibraryManager!, didStartWith association: QPLibraryManagerAssociation!) {
//Handle Library Start
let item = NSExtensionItem()
extensionContext.completeRequest(returningItems: [item]) { (expired : Bool) in
print("Completed Request")
}
}
public func libraryManager(_ libraryManager: QPLibraryManager!, didFailToStartWith association: QPLibraryManagerAssociation!, error: QPError!) {
//Handle Library failed
extensionContext.cancelRequest(withError: error)
}
}
Here's the .plist file. Note that the action extension is a non-ui extensions that are manually triggered by the app. App groups are also enabled on both app and extension
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>RequestOpenAccess</key>
<true/>
<key>NSExtensionActivationRule</key>
<string>FALSEPREDICATE</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.app.non-ui-extension</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).LibraryManagerTestExtension</string>
</dict>
I am trying to enable encryption with realm using the latest official documentation:
https://realm.io/docs/swift/latest/#encryption
This is the code from the documentation:
import Foundation
import Realm
class TestRealm:NSObject {
func test() {
// Generate a random encryption key
let key = NSMutableData(length: 64)!
SecRandomCopyBytes(kSecRandomDefault, key.length,
UnsafeMutablePointer<UInt8>(key.mutableBytes))
// Open the encrypted Realm file
let config = Realm.Configuration(encryptionKey: key)
do {
let realm = try Realm(configuration: config)
// Use the Realm as normal
} catch let error as NSError {
// If the encryption key is wrong, `error` will say that it's an invalid database
fatalError("Error opening realm: \(error)")
}
}
}
I am receiving a compilation error on this line:
let config = Realm.Configuration(encryptionKey: key)
Module 'Realm has no member named 'Configuration'
I am using Realm 1.0.2
You need import RealmSwift, not import Realm. import Realm gives you the Objective-C API.