Currently it's not possible to link to a framework using pragam(lib) on Mac OS X.
Because almost all non posix system libraries are frameworks on Mac OS X it's more difficult to link to system libraries on Mac OS X. Therefore I suggest adding a new pragma only available on Mac OS X: pragma(framework). It will work just as pragma(lib) but pass "-framework Framework" to gcc instead of "-llibrary"
Comment #1 by doob — 2009-05-13T10:32:20Z
Created attachment 365
This patch implements the enhancement.
Comment #2 by doob — 2009-05-13T10:34:49Z
The above patch is against dmd v1.043.
Comment #3 by dmitry.olsh — 2018-05-16T08:32:36Z
Is that still a problem with your latest Objective-C support patches?
Comment #4 by doob — 2018-05-16T11:23:16Z
(In reply to Dmitry Olshansky from comment #3)
> Is that still a problem with your latest Objective-C support patches?
Nothing has changed. But I'm not sure if I think it's a problem anymore. I think this is better left for the build tool, same thing with "pragma(lib)". GDC doesn't implement "pragma(lib)" and would most likely not implement this either.
Comment #5 by destructionator — 2019-02-26T17:40:41Z
I'm gonna go ahead and disagree that this is useless; I still wish we had it, and it would be a trivial little addition. If it doesn't work in gdc, no big deal, they can still use their command line. But it is nice for things to just work and specify their own dependencies.
Comment #6 by dlang-bot — 2019-11-26T02:26:27Z
@benjones created dlang/dmd pull request #10615 "fix issue 2968 by adding a new pragma(framework) " fixing this issue:
- fix issue 2968 by adding a new pragma(framework) to add appropraite flags to the link command on macos
https://github.com/dlang/dmd/pull/10615
Comment #7 by ibuclaw — 2019-11-26T14:45:37Z
(In reply to Adam D. Ruppe from comment #5)
> I'm gonna go ahead and disagree that this is useless; I still wish we had
> it, and it would be a trivial little addition. If it doesn't work in gdc, no
> big deal, they can still use their command line. But it is nice for things
> to just work and specify their own dependencies.
Well, pragma(lib) only works if you are compiling the project, not importing it (i.e: Every pragma(lib) in core.sys.windows doesn't work with certain build configurations). pragma(framework) will suffer from the same limitation.
The build tools are better placed to manage this, assumedly because you already explicitly say what your dependencies are, and it can merge all library dependencies together in the final link command.
Comment #8 by destructionator — 2019-11-26T14:52:17Z
Indeed, and I can live with that. It is still nice to have it there.
Comment #9 by dlang-bot — 2019-11-26T18:24:24Z
@benjones created dlang/dlang.org pull request #2719 "fix issue 2968 by adding pragma(framework)" fixing this issue:
- fix issue 2968 by adding pragma(framework)
https://github.com/dlang/dlang.org/pull/2719
Comment #10 by destructionator — 2023-09-22T00:20:44Z
Still wishing this worked.
Comment #11 by robert.schadek — 2024-12-13T17:50:10Z