how to use MacPorts libraries in an Xcode project using the Xcode GUI -- anyone?
Ken Cunningham
ken.cunningham.webuse at gmail.com
Sat Jan 30 20:43:39 UTC 2021
Thanks for taking the time to explain that.
I will try it out on a few Xcode versions.
We might do well to put this into a wki page or a short screen-capture video.
People seem highly likely to me to need to know how to do this soon if not already now, building things with Xcode using universal libraries arm64/Intel that MacPorts can provide.
If we get this working as smoothly as it hopefully will, we should link to it prominently from the very front page of MacPorts.org <http://macports.org/>.
Ken
> On Jan 29, 2021, at 1:17 PM, Andrew Udvare <audvare at gmail.com> wrote:
>
>
>
>> On 2021-01-29, at 12:40, Ken Cunningham <ken.cunningham.webuse at gmail.com> wrote:
>>
>> I was working on an Xcode project in the Xcode GUI the other day (Apple's ld64-530) and needed various parts that I know MacPorts supplies.
>>
>>
>> But it is not simple or intuitive to know how to add headers and libraries from MacPorts to an Xcode project, I found.
>>
>>
>> I did see how to add header search paths (that was not trivially easy to find, but could be found), but I had to add "/opt/local/include" which brought in everything from MacPorts, rather than just the bit I wanted. And then there are the libraries, and then the install_names will be all wrong.
>>
> You should have /opt/local/include as one of the header search paths if you intend to link with a dylib that is in /opt/local/lib. But then you must also have the correct rpath in the binary too.
>>
>> So, as I was working through this I thought -- in 20 years, this must have come up many times -- where is the wiki page on how to do this? And -- there must be many people out there who use Xcode all day long who know how to make this work smoothly much better than I do.
>>
>>
>> Does anyone have the recipe for happy use of MacPorts headers and libraries in an Xcode GUI project?
>
> You can add /opt/local/Library/Frameworks as one of the Framework search paths.
>
> Not required but you should have /opt/local/lib as a library lookup path.
>
> These last two are not required if you link only in the following way:
>
> When you go to the project settings, you can click on 'Build Phases' and then under 'Link Binary With Libraries', click the + button and add frameworks from /opt/local/Library/Frameworks and dylibs from /opt/local/lib. In the dialog, on the bottom left, choose Add Other then Add Files. Then hit Command+Shift+G and type /opt/local. Browse to find the library (dylib)/framework you want to add.
>
> The resulting binary should have commands similar to (otool -l):
>
> Load command 36
> cmd LC_RPATH
> cmdsize 48
> path /opt/local/Library/Frameworks (offset 12)
>
> For any directly linked framework:
>
> Load command 33
> cmd LC_LOAD_DYLIB
> cmdsize 64
> name @rpath/Commandant.framework/Commandant (offset 24)
> time stamp 2 Wed Dec 31 19:00:02 1969
> current version 1.0.0
> compatibility version 1.0.0
>
> And possibly:
>
> Load command 77
> cmd LC_RPATH
> cmdsize 32
> path /opt/local/lib (offset 12)
>
> I've patched many projects to use frameworks from MacPorts, most recently mas: https://github.com/Tatsh/ports/tree/master/sysutils/mas
>
> Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20210130/39cd2f47/attachment.htm>
More information about the macports-users
mailing list