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)
The error Undefined symbols for architecture arm64: "_OBJC_CLASS_$_SKAdImpression" during the iOS build usually happens if XCode or CocoaPods version is lower than required. To fix it update XCode to 12.5 or higher and CocoaPods to 1.10. 0 or higher.
Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_xxx", referenced from: objc-class-ref in yyy.o. This generally means, you are calling "xxx" (it may be a framework or class) from the class "yyy". The compiler can not locate the "xxx" so this error occurs.
You need to pass the values to the function Calculate. Variables x, y, z and function are not accessible outside the class and also u need a return type to the function so that you can get the output from the function Calculate.
A symbol remains undefined when a symbol reference in a relocatable object is never matched to a symbol definition. Similarly, if a shared object is used to create a dynamic executable and leaves an unresolved symbol definition, an undefined symbol error results.
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.
See image below:
Create an Empty Swift file using Xcode, such as named test.swift, and try to run again
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With