Can't get Xcode to bundle libsteam_api.dylib with a build
Asked Answered
B

2

2

I've put libsteam_api.dylib in the project folder. I've dragged it into the 'frameworks' folder in the project, and added it to the target. It shows up in the list of linked libraries

When I build and run, I get a "Library not loaded" error, and libsteam_api.dylib is nowhere to be found in the application bundle.

If I then manually copy the library into the MacOS folder of the bundle alongside the executable, it runs fine, but I don't want to have to keep doing that for every build

How do I get Xcode to include the library alongside the executable?

Baldhead answered 18/9, 2018 at 11:18 Comment(0)
S
2

Add a Copy Files build phase to your target, copying the dylib into the Frameworks folder of the app package.

Scarberry answered 19/9, 2018 at 17:9 Comment(2)
Thanks :) As I discovered you'll also need to send install_name_tool up your newly-minted executable's anus to reconfigure where it looks for those libraries.Baldhead
@Peeling, depending on what the dylib already has as its install name, you may not need to change it, it may suffice to set the "Runpath search Paths" build setting in the app to something like @loader_path/../Frameworks.Scarberry
D
1

Just banged my head against this as well. There are two pieces to the solution.

1) In your project target's General settings, add the dylib to the list of "Frameworks, Libraries, and Embedded Content", then set its option to "Embed & Sign".

embed & sign

2) Then, under Build Phases (where it should now appear in the "Embed Libraries" section), set its destination to "Executables". (Steam's dylib wants to live alongside the executable, not in the Frameworks directory.)

enter image description here

Dumdum answered 8/12, 2019 at 21:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.