我正在尝试使用 cocoapods 安装 Firebase,因此我可以向用户设备发送推送通知。但是,每次我一步一步按照说明进行操作时,都会收到此错误消息,提示“未找到框架 FBLPromises”。任何人有任何想法如何解决?我在网上查的所有东西都不起作用。
此应用程序的目的是确保用户在NSTextField中输入了某个文本.如果该文本不在该字段中,则不应允许它们离开该字段.
给定一个带有子类文本字段的macOS应用程序,一个按钮和另一个通用的NSTextField.单击该按钮时,将显示一个"附加"到字段的NSPopover,该字段由名为myPopoverVC的NSViewController控制.
例如,用户在顶部字段中输入3,然后单击显示弹出窗口的"显示弹出窗口"按钮并提供提示:"1 + 1等于什么".
请注意,此popover有一个标记为1st resp的字段,因此当弹出窗口显示时,该字段将成为第一个响应者.此时不会输入任何内容 - 这只是针对这个问题.
用户可以单击"关闭"按钮,关闭弹出窗口.此时,如果用户点击或标记离开字段中的"3",应该会发生什么,应用程序不应允许该移动 - 可能会发出蜂鸣声或其他消息.但是当弹出窗口关闭并且用户按Tab键时会发生什么
即使其中带有"3"的字段有一个焦点环,它应该在该窗口中再次指示第一个响应者,但是由于未调用textShouldEndEditing函数,用户可以单击或标记它.在这种情况下,我点击了弹出窗口中的关闭按钮,'3'字段有一个聚焦环,我点击了tab,然后进入下一个字段.
这是子文本字段中的函数,在文本输入字段后可以正常工作.在这种情况下,如果用户键入3然后点击Tab,则光标停留在该字段中.
override func textShouldEndEditing(_ textObject: NSText) -> Bool {
if self.aboutToShowPopover == true {
return true
}
if let editor = self.currentEditor() { //or use the textObject
let s = editor.string
if s == "2" {
return true
}
return false
}
Run Code Online (Sandbox Code Playgroud)
showPopover按钮代码将aboutToShowPopover标志设置为true,这将允许子类显示弹出窗口.(当弹出窗口关闭时设置为false)
所以问题是当popover关闭如何将firstResponder状态返回到原始文本字段时?它似乎具有第一响应者状态,并且它认为它具有该状态,尽管未调用textShouldEndEditing.如果你在字段中键入另一个字符,那么一切都按预期工作.就好像窗口的字段编辑器和其中包含"3"的字段一样,因此字段编辑器不会将调用传递给该字段.
该按钮调用一个包含以下内容的函数:
let contentSize = myPopoverVC.view.frame
theTextField.aboutToShowPopover = true
parentVC.present(myPopoverVC, asPopoverRelativeTo: contentSize, of: theTextField, preferredEdge: NSRectEdge.maxY, behavior: NSPopover.Behavior.applicationDefined)
NSApplication.shared.activate(ignoringOtherApps: true) …Run Code Online (Sandbox Code Playgroud) 我开始了一个空白的Xcode项目,我所做的就是通过Cocoapods添加Firebase框架并在Appdelegate和viewcontroller中导入.当我将FIRApp.configure()添加到didFinishLoadingWithOptions时,我得到了这个错误.如果我删除该行但仍导入框架,则运行时没有错误.这发生在一个空白项目中,故事板中没有任何内容,也没有viewcontroller.swift.
在控制台中它说libc ++ abi.dylib:以NSException类型的未捕获异常终止(11db)
Xcode 8.2,swift 3
import UIKit
import Firebase
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone …Run Code Online (Sandbox Code Playgroud) 我正在使用swift和firebase处理iOS应用程序.我试图让用户使用单独的按钮更改他的电子邮件和密码以及存储在firebase中的其余信息在同一个视图控制器中.
以下是仪表板中一个用户的示例:
{
"Users" : {
"08e5443c-cdde-4fda-8733-8c4fce75dd34" : {
"BusinessName" : "looliCake",
"Category" : "Cooking",
"City" : "Riyadh",
"ContactMe" : "05551233210",
"Details" : "many flaiver choose",
"Email" : "loolicack@gmail.com",
"PhoneNumber" : "05551233210",
"Provider" : "123",
"ShortDescription" : "best pop cake ever . ",
"Website1" : "www.looliCack.com",
"Website2" : "https://www.instagram.com/loolicack/"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是代码:
let mainpass = NSUserDefaults.standardUserDefaults().objectForKey("password") as? String
let mainEmail = NSUserDefaults.standardUserDefaults().objectForKey("Email") as? String
@IBAction func EditEmail(sender: AnyObject) {
if EmailAddressTF.text==""
{
let alert = UIAlertController(title: "Oops!", message:"Make sure …Run Code Online (Sandbox Code Playgroud) 我试图在Swift 2中从Realm查询迭代结果.存储了两个PersonClass对象.
查询的结果var有效并包含两个PersonClass对象,但在迭代结果时,name属性为空字符串.
class PersonClass: Object {
var name = ""
}
let realm = try! Realm()
@IBAction func button0Action(sender: AnyObject) {
let results = realm.objects(PersonClass)
print(results) //prints two PersonClass object with the name property populated
for person in results {
let name = person.name
print(name) //prints and empty string
}
}
Run Code Online (Sandbox Code Playgroud) 我目前正在将项目的依赖管理器从 Carthage 切换到 Swift Package Manager,
例如,在使用 Carthage 构建时,我们有领域依赖关系,它曾经是一个动态框架,
但是在SPM中,当我尝试添加领域时,它默认提供领域静态框架,并且我找不到切换到动态框架的方法,
由于我们的项目中有一些相互依赖的子模块,因此尝试链接静态库会出现duplicate symbols错误。
如果我可以像迦太基那样直接下载领域作为动态框架,我会更容易,
有谁知道该怎么做?
预先感谢您的帮助:)
我们有一个最近更新到Firebase 5,Swift 4的现有项目,我们的身份验证错误处理似乎不起作用.
我在SO上找到了几个答案,但那些似乎不再适用:
假设用户正在登录并输入有效的电子邮件和无效密码,这些密码将传递给以下代码进行身份验证
Auth.auth().signIn(withEmail: user, password: pw, completion: { (auth, error) in
if error != nil {
let errDesc = error?.localizedDescription
print(errDesc!) //prints 'The password is invalid'
let err = error!
let errCode = AuthErrorCode(rawValue: err._code)
switch errCode {
case .wrongPassword: //Enum case 'wrongPassword' not found in type 'AuthErrorCode?'
print("wrong password")
default:
print("unknown error")
}
} else {
print("succesfully authd")
}
})
Run Code Online (Sandbox Code Playgroud)
以前,我们可以使用FIRAuthErrorCode来比较可能的错误,例如FIRAuthErrorCodeInvalidEmail,FIRAuthErrorCodeWrongPassword等,但上面发布的代码将无法编译,因为此行上的错误
case .wrongPassword: Enum case 'wrongPassword' not found in type 'AuthErrorCode?'
Run Code Online (Sandbox Code Playgroud)
奇怪的是,如果我通过打字使用自动填充
case AuthErrorCode.wr …Run Code Online (Sandbox Code Playgroud) 我们是一个使用Firebase创建和登录用户的应用程序。之前登录可以正常工作,但是最近,当我们尝试使用电子邮件和密码登录时,它开始提示“内部错误”(如下图所示)
我检查以确保在Firebase上启用了登录方法(电子邮件和密码)
FIRAuth.auth()?.signIn(withEmail: signInEmail.text!, password: signInPassword.text!, completion: { (user, error) in
if(error == nil) {
print("SUCCESS: User authenticated with firebase")
if let user = user {
KeychainWrapper.standard.set(user.uid, forKey: KEY_UID)
print("SUCCESS: Data saved to keychain")
}
} else {
print(error?.localizedDescription)
print("Debug Description")
print(error.debugDescription)
}
}
Run Code Online (Sandbox Code Playgroud)
这是出现的调试说明
Optional(Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={error_name=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x2835ccbd0 {Error Domain=FIRAuthInternalErrorDomain …Run Code Online (Sandbox Code Playgroud) 它在我的控制台中打印 CHANGED 但没有任何变化,用户电子邮件保持不变。占位符文本恢复为原始电子邮件,我的 Firebase 数据库用于该特定用户的电子邮件也未更改。我想让用户可以选择更改他们个人资料的任何部分,包括电子邮件、密码、位置和他们在首次注册时存储的其他值。为了做到这一点,我是否必须将他们注销并让他们重新登录?这似乎是一种糟糕的用户体验。
class SettingsViewController: UIViewController {
@IBOutlet weak var email: UITextField!
@IBOutlet weak var password: UITextField!
@IBOutlet weak var location: UITextField!
@IBOutlet weak var updateEmail: UIButton!
@IBOutlet weak var updateLocation: UIButton!
@IBAction func updateEmailAction(_ sender: Any) {
let currentUser = Auth.auth().currentUser
currentUser?.updateEmail(to: email.text!) { error in
if let error = error {
print(error)
} else {
print("CHANGED")
}
}
}
var dataBaseRef: DatabaseReference! {
return Database.database().reference()
}
override func viewDidLoad() {
super.viewDidLoad()
let userRef = dataBaseRef.child("users/\(Auth.auth().currentUser!.uid)")
userRef.observe(.value, …Run Code Online (Sandbox Code Playgroud) 有没有办法创建自定义 Swift 对象,将 Firebase 文档 ID 分配给对象参数?
代码取自此处:https ://firebase.google.com/docs/firestore/query-data/get-data#custom_objects
public struct City: Codable {
let id: String // here I'd like to fill in the Document ID
let name: String?
let state: String?
let country: String?
let isCapital: Bool?
let population: Int64?
enum CodingKeys: String, CodingKey {
case id = //Document ID
case name
case state
case country
case isCapital
case population
}
}
Run Code Online (Sandbox Code Playgroud)
获取 Firebase 文档并创建对象。代码也取自上面的 Goolge Firebase 链接。
fun getObject(){
let db = Firestore.firestore()
let docRef = …Run Code Online (Sandbox Code Playgroud)