Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined symbols Swift.UnsafeMutableBufferPointer

After downloading Xcode 8 and migrating to Swift 3 I'm not longer able to archive the project. At the same time the project builds without any issues.

Error that I get:

Undefined symbols for architecture armv7:
"Swift.UnsafeMutableBufferPointer.(subscript.materializeForSet : (Swift.Int) -> A).(closure #1)", referenced from: function signature specialization of generic specialization with Swift.UnsafeMutableBufferPointer : Swift.MutableCollection in Swift and Swift.UnsafeMutableBufferPointer : Swift.RandomAccessCollection in Swift> of Swift._siftDown (inout A, index : A.Index, subRange : Swift.Range, by : inout (A.Iterator.Element, A.Iterator.Element) -> Swift.Bool) -> () in OrderCoordinator.o function signature specialization of generic specialization with Swift.UnsafeMutableBufferPointer : Swift.MutableCollection in Swift and Swift.UnsafeMutableBufferPointer : Swift.RandomAccessCollection in Swift> of Swift._heapSort (inout A, subRange : Swift.Range, by : inout (A.Iterator.Element, A.Iterator.Element) -> Swift.Bool) -> () in OrderCoordinator.o function signature specialization of generic specialization with Swift.UnsafeMutableBufferPointer : Swift.MutableCollection in Swift and Swift.UnsafeMutableBufferPointer : Swift.RandomAccessCollection in Swift> of Swift._partition (inout A, subRange : Swift.Range, by : inout (A.Iterator.Element, A.Iterator.Element) -> Swift.Bool) -> A.Index in OrderCoordinator.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was able to get rid of error by commenting array sorting code in following function:

func didFinishWithResults(_ results: [PhotoProcessorResult]) {
    guard let album = albumService.currentAlbum else { return }
    //let sortedResults = results.sorted(by: { $0.fileIndex < $1.fileIndex })
    let updateItems = zip(sortedResults, album.assetItems).map { (photoProcessorResult, assetItem) -> UpdateItem in
        UpdateItem(path: photoProcessorResult.filePath, position: photoProcessorResult.fileIndex, isCover: assetItem.isCover)
    }
    albumService.updateAlbumWithItems(updateItems) { (success, errorDescription) in
        if success {
            self.handleAlbumUpdate()
        } else {
            self.showFailureAlert(errorDescription) {
                self.startProcessingAlbum(self.albumService.currentAlbum)
            }
        }
    }
}

While I resolved issue by sorting data using NSArray, I don't like this solution.

Will be grateful for any suggestions.

like image 819
Ostap Horbach Avatar asked Oct 20 '16 10:10

Ostap Horbach


3 Answers

Since it compiles i don't think there is anything wrong with your code. The fact that it says "Undefined symbols for architecture armv7" and is failing to archive tells me that something is going on with your project, but unfortunately there are many ways to cause this problem. arm7 is iphone 5 so your project is probably setup correctly only for arm64. Try the solutions mentioned here: Undefined symbols for architecture armv7

like image 90
Josh Homann Avatar answered Nov 18 '22 01:11

Josh Homann


If here is problem only for the this line:

let sortedResults = results.sorted(by: { $0.fileIndex < $1.fileIndex })

You can change to it:

let sortedResults = results.sorted { (first, second) -> Bool in
    return first.fileIndex < second.fileIndex
}

Did it solve your problem?

like image 27
Ramis Avatar answered Nov 18 '22 00:11

Ramis


Issue disappeared after updating to XCode 8.1. Thanks everyone :)

like image 1
Ostap Horbach Avatar answered Nov 18 '22 00:11

Ostap Horbach