Search code examples
iosswiftxcodedocumentation

Undefined symbols for architecture arm64: Undefined symbol : _UTTypeConformsTo on Xcode11 Swift 5


I am working on the ios project. I didn't have any problem at the moment. However, there is a problem with iOS 11.4 version of iPhone 6.

I've already built my project with the iOS 12.4 iPhone 6 device, and there's nothing wrong with it.

This is a problem when you connect a physical device. My error is as follows.

Undefined symbols for architecture arm64:
  "_UTTypeConformsTo", referenced from:
      myapp.Document.uti(_: Swift.String, conformsTo: Swift.String) -> Swift.Bool in Document.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbol : _UTTypeConformsTo

I have this function in the Document.swift file.

Document.swift

class Document: UIDocument {


    var fileData: Data?

    var filesText: Data?

    func uti(_ uti: String, conformsTo candidateParent: String) -> Bool {
        return UTTypeConformsTo(uti as CFString, candidateParent as CFString)
    }
...
    override func load(fromContents contents: Any, ofType typeName: String?) throws {
        if let fileType = typeName {
            if fileType == "public.png" || fileType == "public.jpeg" { // .jpg not recognized
                if let fileContents = contents as? Data {
                    fileData = fileContents
                }
            } else if !uti(typeName!, conformsTo: "public.data") {
                throw IXError.fileAcessFailed
            } else {
                if let fileContents = contents as? Data {
                    filesText = fileContents
                }
                print("File type unsupported.")
            }

        } // end if let fileType = typeName

    } // end func load

problematic environment:

  • Xcode: Version 11.0
  • Device : IPhone 6 and 11.4 ios version // get Error
  • Device : IPhone 6 and 12.4 ios version // This device operates normally.

The two devices are different.

There have been no problems so far, but problems occur when trying to build this device. What's the problem?

info

The error appears to occur when the developer info is set to 11.4. However, 11.4 devices must also be able to be built. What is the fundamental solution?

Please come up with many solutions.


Solution

  • I was able to resolve this issue by adding the CoreServices framework to the Libraries and Connections section of the Creation Steps tab of the Target Editor. It was a simple solution, but a difficult solution.

    enter image description here