What is the best way to distribute a Nimble package that would use Objective-C on Mac OS X and C/C++ on Linux/Windows? Is there anything special that needs to be done?
Also, if a Nimble package uses a particular backend like Objective-C, do users of the that project need to compile their code with the same backend?
when blocks allow for different code based on backends, Nim versions, command line options and so on. The fatal pragma section of the Nim manual gives an example that shows how to error when the user doesn't use the objc command to compile. If you want to just warn, you can also do that. An example for your use case, you put this at the top of your nimble package module:
when defined(macos) or defined(macosx):
when not defined(objc):
{.warn: "this package is supposed to work with objc on macosx".}
elif not defined(c) or not defined(cpp):
{.warn: "this package is supposed to work with c/c++ on linux/windows".}
The browsers module in the standard library is a short example of how to write OS-specific code.