UTType always return nil when testing on M1 Mac simulator with x86 arch

(environment: macOS 11.4, Xcode 12.4, iOS simulator 14.4)

The below test does not passed when a project's architectures for "Any iOS Simulator SDK" contains X86_64 only. (Open a new project with architectures arm64 passes)

import UniformTypeIdentifiers

class UTTypeTests: XCTestCase {



    func testThatItConvertsFromMIMEType() {

        if #available(iOS 14.0, *) {

            guard let mp4Type = UTType(mimeType: "video/mp4") else {

                return XCTFail("Could not decode from MIME type.")

            }

            

            XCTAssertEqual(mp4Type, UTType.mpeg4Movie)

        } else {

        }

  }

}

similar issue happens on deprecated method UTTypeCopyPreferredTagWithClass

Replies

Hi yiu por,

This is happening in Xcode 13.2 as well for me. Did you find any solution for this? Not sure if this is in Apple radar already.

Thanks, Vinayak Srivastava

No, the issue is still here. But I rebuild the framework for arm64 simulator and it fixed the issue.

Opened ticket with Apple through Feedback Assistant today. Error message from running UTType..preferredMIMEType returns nil and error in LLDB says "File a bug" :). I'm not optimistic on resolution since it seems like Simulator under Rosetta is not supported at all sadly. Not everyone can easily rebuild for arm64 due to third party dependencies though.

it seems like Simulator under Rosetta is not supported at all sadly.

Oh, there’s no ambiguity here. Running Xcode or the simulator under Rosetta is most definitely not supported. Folks who do that inevitably run into weird problems.

Not everyone can easily rebuild for arm64 due to third party dependencies though.

Understood. But we’re now two years into the Apple silicon transition. If your third-party dependencies haven’t caught up with that, I think it’s time to re-evaluate those dependencies. If things proceed as they have in the past, at some point Rosetta will go away.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"