0

I've tried this with Xcode 12.3 and 13.2.1. When initializing a NSAttributedString, for example,

let str2 = "This is <b>bold</b>."
let htmlData = str2.data(using: .utf8)!
let docType = NSAttributedString.DocumentType.html
let attributedString = try? NSAttributedString(
        data: htmlData,
        options: [.documentType: docType],
        documentAttributes: nil)

The following error is produced (I replaced the app name)

2022-02-08 08:22:58.660449-0500 <appname>[1086:40707] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600003aa28c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-02-08 08:22:58.693109-0500 <appname>[1086:40707]  AudioObjectSetPropertyData: no object with given ID 0
2022-02-08 08:22:58.693975-0500 <appname>[1086:40707] AudioSessionSimulatorClientManager.cpp:83    Failed to set processVolumeScalar on device. Error: 560947818

The only reference I found to this problem was

https://developer.apple.com/forums/thread/655813

It suggests upgrading Xcode solves the problem. I upgraded to 13.2.1 (latest release) but the problem remains. The output is not displaying so I assume the errors are causing that.

KevinRethwisch
  • 237
  • 2
  • 13
  • 1
    I would try adding `.characterEncoding: String.Encoding.utf8.rawValue` to `options`. However, it doesn't seem to me that the error is connected to the attributed string. Did you try a clean build? – Sulthan Feb 08 '22 at 14:00
  • 1
    Errors in console don't seem to be related to NSAttributedString. They are about Audio. – Larme Feb 08 '22 at 14:12
  • @Larme That's true, but when I comment the last line from above the error is not present. If you follow the link provided others have encountered the same problem. – KevinRethwisch Feb 08 '22 at 14:15
  • @Sulthan Thanks. I made a clean build but the problem remains. – KevinRethwisch Feb 08 '22 at 14:16
  • 1
    I'd ignore them. Xcode debugger can be really verbose sometimes... – Larme Feb 08 '22 at 14:16
  • @Larme I believe the errors prevent the output from displaying. – KevinRethwisch Feb 08 '22 at 14:18
  • I belive this might happen when the system is initializing some code related to HTML. Are you sure you are calling your code from the main thread? – Sulthan Feb 08 '22 at 16:43
  • Also see https://stackoverflow.com/questions/58360765/swift-5-1-error-plugin-addinstanceforfactory-no-factory-registered-for-id-c - check your added frameworks. – Sulthan Feb 08 '22 at 16:44
  • @Sulthan I have not created a new thread, although the nested views in use might create threads under the hood. I'm not using any frameworks. This is a practice app to learn UIKit. – KevinRethwisch Feb 08 '22 at 18:40
  • @KevinRethwisch You don't have to create a new thread. For example, when you are doing things from an API call callback (URLSession), then the code is not called from the main thread and you would have to manually insert `DispatchQueue.main.async { ... }` – Sulthan Feb 08 '22 at 19:17

0 Answers0