I am trying to add an Apple Watch companion app to my iPhone app. I have no experience with Apple Watch at all, so I followed the Apple instructions as described on https://developer.apple.com/tutorials/swiftui/creating-a-watchos-app I followed that instruction to the letter, and did not add anything to it, and now have two targets in the project: the original iPhone target, and the Apple Watch target.
When I try to build the Watch app, I get the following linker error:
error: Build input file cannot be found: '/usr/lib/libobjc.A.dylib'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
The linker command has the following argument on it:
-weak_library /usr/lib/libobjc.A.dylib
The "Link binary with libraries" option of the "Build Phases" of the Apple Watch target does not have any libraries specified.
Does anybody know what the libobjc library is, and what it is used for? Where is this linker flag configured? How can I make this work?
EDIT: The -weak_library /usr/lib/libobjc.A.dylib
is configured in the Project Build Settings, "Other Linker Flags". It seems to be a basic necessity that was already there before I added the Watch target. When I remove it, I get "Undefined symbol: _main" errors. So it seems to be something fundamental that is required. The question is now why it is not found by the linker.
If it matters, the iPhone app has always been Objective-C, but I'd like to start with Swift for the Apple Watch app, so have chosen to create that as a Swift app.