我有一个视图,其中显示我的消息列表。每当添加新消息时,我想滚动到底部。我正在尝试添加一个onChange事件,ForEach但这会破坏我的代码并出现一些奇怪的错误:
在“Array”上引用实例方法“onChange(of:perform:)”要求“Message”符合“Equatable”
有时
编译器无法在合理的时间内对该表达式进行类型检查;尝试将表达式分解为不同的子表达式
当我删除onChange一切都符合要求时。
这是Message模型:
struct Message: Identifiable {
var id = UUID()
var text: String
var createdAt: Date = Date()
var senderID: String
var seen: Bool
init(dictionary: [String: Any]) {
self.text = dictionary["text"] as? String ?? ""
self.senderID = dictionary["senderID"] as? String ?? ""
self.seen = dictionary["seen"] as? Bool ?? false
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里做错了什么?
'对于每个
struct MessagesView: View {
@ObservedObject var messagesViewModel: MessagesViewModel
var body: some View {
VStack { …Run Code Online (Sandbox Code Playgroud) 我使用的是 Xcode 12 beta 2。我已经将我的库打包在 Swift Packages 中。DataModel出现在错误消息中的是其中之一,我当前的包WeatherView依赖于。
build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
----------------------------------------
SchemeBuildError: Failed to build the scheme "WeatherView"
unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets of \'DataModel\' are being created for iOS Simulator")
Build system information:
error: unexpected service error: build aborted due to an internal error: planningFailed("multiple configured targets …Run Code Online (Sandbox Code Playgroud) 当您有一个多平台项目时,您如何测试代码的共享部分?我看到了针对 iOS 的测试和针对 macOS 的测试,但没有针对共享部分的测试。我想为我的应用程序的平台独立部分添加单元测试。
我刚刚安装了 iOS 14 beta 并将 Xcode 更新到最新的 Version 12 beta 3。
*Unable to locate DeviceSupport directory with suffix 'DeveloperDiskImage.dmg'. This probably means you don't have Xcode installed, you will need to launch the app manually and logging output will not be shown! Could not run build/ios/iphoneos/Runner.app on 00008020-001338A20E01002E. Try launching Xcode and selecting "Product > Run" to fix the problem: open ios/Runner.xcworkspace*当我从flutter运行应用程序时出现错误 。
我可以从 Xcode 运行该应用程序,但是一旦 USB 电缆断开,该应用程序将无法打开/应用程序崩溃。
请帮助我找出问题所在并解决
在执行 xcodebuild 时,编译器在声明 tableView 的第一行下方崩溃。
Run Code Online (Sandbox Code Playgroud)var tableView: UITableView? { get { var table: UIView? = superview while !(table is UITableView) && table != nil { table = table?.superview } return table as? UITableView } }
这是编译器崩溃的堆栈跟踪
2. Apple Swift version 5.3 (swiftlang-1200.0.28.1 clang-1200.0.30.1)
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { EarlyModulePasses, HighLevel+EarlyLoopOpt, MidModulePasses+StackPromote, MidLevel, ClosureSpecialize, LowLevel, LateLoopOpt, SIL Debug Info Generator } on SIL for TestApp.TestApp)
4. While running pass #835 SILFunctionTransform "SimplifyCFG" on SILFunction "@$s10TestApp31EditProfileAboutMeTableViewCellC05tableH0So07UITableH0CSgvg".
for getter for tableView …Run Code Online (Sandbox Code Playgroud) 我有一个使用 tableview 的搜索表单。今天更新 Xcode 12 后,UISwitch、UITextField、UISlider 在嵌套在 UITableViewCell 中时不再工作。是否有一个属性发生了变化,我需要设置它才能再次工作?
为了确保这不仅仅是我的项目,我创建了一个新项目并在其中放置了一个 UITextField,但它也不起作用。
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
let textField = UITextField(frame: CGRect(x: 5, y: 5, width: 400.0, height: 25.0))
textField.delegate = self
textField.backgroundColor = .blue
cell.addSubview(textField)
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print("this will get called even when selecting the UITextField")
}
func textFieldDidBeginEditing(_ textField: UITextField) {
print("this is never called")
}
Run Code Online (Sandbox Code Playgroud) 我将应用程序部署版本从 iOS 13 更改为 iOS 14,但在构建应用程序时遇到错误。
尽管所有这些包都是公开的,但它一直在谈论没有提供凭据。我还设置了 github 凭据并一直使用它们。
我尝试删除 github 帐户,更改 ssh -> http,但似乎没有任何帮助。
当我尝试使用 Swift 包管理器添加新的公共包时,会发生同样的问题
有什么建议么?
我正在使用 Xcode 12,并且尝试为导出和导入过程添加通用类型标识符图标。
所以我尝试了以下方法来创建图标。
iconutil -c icns icns.iconset但是当我单击第一个屏幕截图的加号按钮时,
它建议对话框中的三个文件,如第二个屏幕截图。
如果我选择其中之一,它将不会出现在 GUI 中,并且更改不会应用于项目。请帮助我解决这个问题,我非常感谢您的反馈。
有谁知道如何阻止 swiftUI 预览打开麦克风?我在工作时戴着蓝牙耳机,每次预览启动时都会启用麦克风。这会降低我的音频质量,因为耳机会在播放和输入之间分配带宽。
我的解决方法是进入声音设置,然后将我的默认输入切换到我的网络摄像头或 macbook 本身。每次启用时,xcode 中的预览都会打开麦克风,这太奇怪了。
上下文:我有一个 MBP 2019 Xcode 12.4 Catalina
谢谢!
xcode12 ×10
ios ×4
swiftui ×3
xcode ×3
swift ×2
swift5 ×2
flutter ×1
ios14 ×1
simulator ×1
uicontrol ×1
uitableview ×1
unit-testing ×1
xcodebuild ×1