我曾经习惯brew install openssl下载并安装openssl v1.0.2f,然而,它回来说:
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to …Run Code Online (Sandbox Code Playgroud) 我已使用以下代码全局安装了 npm 模块 aws-amplify/cli:
npm install -g @aws-amplify/cli
Run Code Online (Sandbox Code Playgroud)
这有效,但是当尝试使用 amplify cli 初始化我的环境时,它给了我以下错误:
/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/queue-microtask/index.js:1
ReferenceError: globalThis is not defined
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/queue-microtask/index.js:5:25)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/run-parallel/index.js:4:24)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/@nodelib/fs.scandir/out/providers/async.js:5:13)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/@nodelib/fs.scandir/out/index.js:4:15)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/@nodelib/fs.walk/out/readers/async.js:4:19)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/@nodelib/fs.walk/out/providers/async.js:3:17)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.<anonymous> (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/@nodelib/fs.walk/out/index.js:4:17)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Object.Module._extensions..js …Run Code Online (Sandbox Code Playgroud) 我UIViewController在我的故事板中添加了一个容器视图,该视图由单独的UIViewController. 这个容器视图需要有一个与之关联的高度,以便正确地布置项目。然而,这个容器视图的高度是动态的,因为它包含一个UITextView项目。之前,当我不使用容器视图时,自动布局会为我计算项目的高度。现在我已将所有内容移至容器视图,这似乎是不可能的。我是否必须手动计算容器视图的高度并将其应用于约束,或者有没有办法让自动布局处理它?
我的iOS应用程序的firestore缓存似乎与Firestore不同步.结果我不得不禁用持久性.无论如何重置缓存?有没有办法确保它不断同步?我所做的只是从数据库中删除文件!
在我从请求返回之前,我需要等待完成的一些异步方法.我正在使用Promises,但我一直收到错误:
Each then() should return a value or throw // promise/always-return
Run Code Online (Sandbox Code Playgroud)
这为什么开心呢?这是我的代码:
router.get('/account', function(req, res) {
var id = req.user.uid
var myProfile = {}
var profilePromise = new Promise(function(resolve, reject) {
var userRef = firebase.db.collection('users').doc(id)
userRef.get()
.then(doc => { // Error occurs on this line
if (doc.exists) {
var profile = doc.data()
profile.id = doc.id
myProfile = profile
resolve()
} else {
reject(Error("Profile doesn't exist"))
}
})
.catch(error => {
reject(error)
})
})
// More promises further on, which I …Run Code Online (Sandbox Code Playgroud) 我有一个主要使用 UIKit 构建的应用程序,但我刚刚添加了我的第一个 SwiftUI 视图,但它没有构建。我的 Xcode 项目中有两种不同的方案:MyApp和MyApp_Staging。我正在该MyApp_Staging方案中工作,想看看我的 SwiftUI 预览是什么样子。但是,它不会构建并给出错误:
no such module 'MyApp'
----------------------------------------
CompileDylibError: Failed to build ImagePickerView.swift
Compiling failed: no such module 'MyApp'
/Users/Me/Library/Developer/Xcode/DerivedData/MyApp-czotsuriazmotwgvkpfocaqlgfpz/Build/Intermediates.noindex/Previews/MyApp (Staging)/Intermediates.noindex/MyApp.build/Debug (Staging)-iphonesimulator/MyApp.build/Objects-normal/x86_64/ImagePickerView.2.preview-thunk.swift:1:55: error: no such module 'MyApp'
@_private(sourceFile: "ImagePickerView.swift") import MyApp
Run Code Online (Sandbox Code Playgroud)
我知道这些方案设置正确,因为该应用程序通常可以正常工作。
在我的产品模块名称中,它正确列出了多个值:针对不同构建类型的 MyApp 和 MyApp_staging。从技术上讲,该值设置为$(PRODUCT_NAME:c99extidentifier),但这填写了正确的名称。
是什么导致了这个问题?
我正在尝试在使用循环的函数中使用async和。烦人的是我无法让它工作。应该发生的是它需要一个 event 数组,遍历它们,添加一些额外的数据,然后将它们推送到数组中。然后从原始函数返回该数组。这是我的代码:awaitforEachdocseventsevents
async function getEvents() {
...
var events = []
await addExtrasToDocsForUser(docs, currentUserId, events)
return events
}
var addExtrasToDocsForUser = (docs, currentUserId, events) => {
return docs.forEach(async (eventDoc) => {
const event = await addExtrasToDocForUser(eventDoc, currentUserId)
events.push(event)
})
}
Run Code Online (Sandbox Code Playgroud)
实际发生的是该getEvents()函数events在forEach循环完成之前作为一个空数组返回。我该如何解决?
我的视图控制器中有一个强引用模型,该模型具有listenToQueue“侦听”我的 Firebase 数据库以进行实时更新的功能。每当发生更新时,它都会将一个对象传回我的视图控制器,然后它会调用一个函数。这是我的代码:
eventModel.listenToQueue { [weak self] queuer in
self?.queuerDidChange(queuer: queuer)
}
Run Code Online (Sandbox Code Playgroud)
这有效。但是,最初我的代码是这样的:
eventModel.listenToQueue(updateHandler: queuerDidChange)
Run Code Online (Sandbox Code Playgroud)
这导致模型和视图控制器之间的保留循环。但是,该代码看起来更清晰,所以我想知道是否有办法queuerDidChange通过对 self 的弱引用来传递函数?我已经试过了,但保留周期仍然存在:
weak var weakSelf = self
eventModel.listenToQueue(updateHandler: weakSelf?.queuerDidChange)
Run Code Online (Sandbox Code Playgroud)
是否可以做我想做的事,还是我应该坚持我拥有的代码?
如何将子视图控制器的视图添加到自定义UITableViewCell?我可以在里面添加这样的视图cellForRowAtIndexPath:
self.addChildViewController(controlsViewController)
cell!.cellView.addSubview(controlsViewController.view)
controlsViewController.didMoveToParentViewController(self)
Run Code Online (Sandbox Code Playgroud)
但是当单元格消失时,我需要删除这个子视图控制器.我真的不确定该怎么做.有没有更好的方法来解决这个问题?
我有一个如下所示的函数:
public final class MyClass {
static let shared = MyClass()
public func doSomething(dictionary: [String: Any]? = nil) async -> UIViewController {
return await UIViewController()
}
}
Run Code Online (Sandbox Code Playgroud)
我在 a 中这样称呼它UIViewController:
final class MyViewController: UIViewController {
@IBAction private func tapButton() {
Task {
let vc = await MyClass.shared.doSomething()
}
}
}
Run Code Online (Sandbox Code Playgroud)
但这给了我一个警告:
不可发送类型“[String:Any]?” 在调用非隔离实例方法“doSomething(dictionary:)”时退出主参与者隔离上下文无法跨越参与者边界
请注意,您必须Strict Concurrency Checking在“构建设置”中将其设置为Complete或Targeted使其显示在 Xcode 中。
我知道 a 内的函数UIViewController与 MainActor 是隔离的,我希望tapButton()如此。但是我该怎么做才能避免这个警告呢?
ios ×5
swift ×4
javascript ×2
async-await ×1
firebase ×1
homebrew ×1
macos ×1
node.js ×1
npm ×1
openssl ×1
swiftui ×1
uitableview ×1