upon upgrading to Xcode 15, my widget extension is causing this error:
ld: Undefined symbols: _main, referenced from: <initial-undefines> clang: error: linker command failed with exit code 1 (use -v to see invocation)
When pressing the error, nothing happens. It doesn’t show me which symbols are undefined.
How should I fix this?
try adding -ld_classic to the linker options,but it don’t work
2
Answers
this is apple DTS engineer answerd me
Your project isn’t linking because it has the Mach-O Type build setting overridden to a blank value. When looking at your app’s build settings, select the item at the project level, rather than at the target level, and search for Mach-O. You’ll see a green highlight on this setting, showing that it is set, which happens to be a blank value. Select the Mach-O row and press the delete key, and the green highlight will disappear, as the setting will be unset. Your share extension was inheriting this blank value, so the complier did not emit a main function, because it didn’t know the final build product needed to have an executable main function.
In my case it was missing
@main
annotation onAppDelegate
which is entry point for the app.So the resulting code was: