clang: error: linker command failed with exit code 1 (use -v to see invocation)

Just updated to the latest XCode. Big mistake. Why must Apple ruin my project everytime they update Xcode? I might give up on Swift development if I can't get this fixed easily.


The error I get is: clang: error: linker command failed with exit code 1 (use -v to see invocation)



How should I go about fixing it? Already tried build clean and restarted XCode a bunch.

Again, it sounds like this file is being compiled as Swift 2 syntax, not Swift 3. The fact that the action is ".DeleteSelf" instead of ".deleteSelf" is evidence for this, along with the missing DispatchQueue definition.


You're going to have to diagnose and solve this actual problem. The syntax error is merely a symptom of the more fundamental problem.

Still struggling on the dispatch.async error but maybe this warning has something to do with it:


"warning: target specifies SWIFT_VERSION = '2.3', but it is overridden by TOOLCHAINS = 'com.apple.dt.toolchain.XcodeDefault'"


Anyone know how to get rid of that warning?

How do I convert this one to Swift 3?


lazy var applicationDocumentsDirectory: NSURL = {

let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)

return urls[urls.count-1] as NSURL

}()

Go to the target build settings (Command-1, select the project entry, select the appropriate target from the target list, choose the Build Settings tab in the editor) and enter "swift_version" in the filter/search field at the top right.


In a current Swift 3 project of mine, the project level setting is "Unspecified" and the target level setting is "Unsupported version: 3.0". I suspect you'll find that your target has "2.3" setting.

You don't say what the error is, but you should be using "URL" instead of "NSURL" in both places.

I get the error "Use of undefined type" for:


lazy var applicationDocumentsDirectory: URL = {


I get the error "Expected member name following '.'" for:


let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)


I have import Foundation at the top of the code so it's not that.


Is there a guide anywhere for what I should be coverting this code to. Right now I'm converting the AppDelegate.swift code.


Also, the line self.saveContext() gives me the error Value of type 'AppDelegate' has no member 'saveContext' even though I can clearly type and select self.saveContext()


func applicationWillTerminate(_ application: UIApplication) {

self.saveContext()

}

If this file is being compiled for the same target that's been having the SWIFT_VERSION problem, then you must solve that problem first. If your target is properly recognized as Swift 3, there ought to be a fix-it error that will convert the code for you. If not, you can just consult the class reference documentation.


>> Is there a guide anywhere for what I should be coverting this code to.


Yes, of course. For [NS]FileManager and [NS]URL:


developer.apple.com/reference/foundation/filemanager

developer.apple.com/reference/foundation/url


Note that you search developer.apple.com for the class names with or without the NS prefix. Both versions of the class reference documents show the same thing for Swift, provided you choose the correct language at the top right corner of the page.

clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
 
Q