Reputation: 32093
I created a brand new project in Xcode 11 (an iOS single-view project with SwiftUI) and enable Mac as a target device. Without doing anything else, I try to build, and I get this error:
ld: warning: directory not found for option '-L/Applications/Xcode'
ld: warning: directory not found for option '-L11.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac'
ld: warning: directory not found for option '-L/Applications/Xcode'
ld: warning: directory not found for option '-L11.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/uikitformac'
ld: warning: Could not find or use auto-linked library 'swiftUIKit'
Undefined symbols for architecture x86_64:
"__swift_FORCE_LOAD_$_swiftUIKit", referenced from:
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in AppDelegate.o
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in SceneDelegate.o
__swift_FORCE_LOAD_$_swiftUIKit_$_MyProject in ContentView.o
(maybe you meant: __swift_FORCE_LOAD_$_swiftUIKit_$_MyProject)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Upvotes: 35
Views: 41865
Reputation: 45
Remove
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"
from "Library Search Paths” of Build Settings
Upvotes: 0
Reputation: 101
I had to reinstall Xcode completely, because of missing swift folder in "$(TOOLCHAIN_DIR)/usr/lib"
Upvotes: 1
Reputation: 6921
I had this error when I accidentally imported XCTest
to the app target. Didn't notice it till I checked git diff. If you run into this issue make sure you didn't export inappropriate stuff too
Upvotes: 2
Reputation: 1765
Update: This works for XCode Version 13.0 (13A233), too.
For XCode Version 12.0.1 (12A7300),
I just added libswiftWebKit.tbd to
Link Binary with Libraries (from project, Build Phases)
and the build was successful.
Upvotes: 129
Reputation: 1687
For me, I used to encounter link error with swift library with Xcode 12, I resolved it by add "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)" and "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)" into the "Library Search Paths" of "Build Settings"
Upvotes: 3
Reputation: 91
Go to Xcode, in the project name, right click and click on “New file…” Select Swift File and click on Next Select the project target and Finish In the next screen select “Create bridging Header” - Make sure to bridge.
Keep the swift file there for future in order to run the simulator.
Upvotes: 9
Reputation: 2104
Create an Empty Swift file using Xcode, such as named test.swift, and try to run again
Upvotes: 9
Reputation: 32093
As hinted by the warnings saying directory not found
, it seems Xcode doesn't like having a space in its bundle's file name.
I renamed it from Xcode 11.0-Beta.2.app
to Xcode-11.0-Beta.2.app
and now it builds just fine.
Upvotes: 2