简体   繁体   中英

Use libxlsxwriter without CocoaPods in a macOS project

My project (Objective C, macOS, Xcode 11) does not use CocoaPods and I'd like to keep it that way.

I want to use libxlsxwriter to export data in Excel format. I cloned libxlsxwriter from GitHub and built it. Now I have libxlsxwriter.a and lbixlsxwriter.dylib .

What I tried so far: I followed the instructions on this site (thanks for the link) to include the dylib. In the "General" settings lbixlsxwriter.dylib is shown as "Embed & Sign", in "Build Phases" it is listed under "Link Binary With Libraries" and it has its own "Copy Files" section. Running from Xcode gives me

dyld: Library not loaded: /usr/lib/libxlsxwriter.dylib
  Referenced from: /Users/XXX/Library/Developer/Xcode/DerivedData/XXXefxsacdsioejobcumpvsbklqguri/Build/Products/Debug/XXX.app/Contents/MacOS/XXX
  Reason: image not found

What do I have to add to my project: The include folder with all the header files and both of these libs? How do I have to adjust the General settings and Build Phases?

If you have static library and only one loader, eg. main executable, (so you don't need to share it between your components), then you don't need dynamic library at all.

Just add your libxlsxwriter.a into Target > General > Frameworks and Libraries section, and it will be linked in into your executable and just work.

If you really need shared dynamic library then you need to use rpath + LD_RUNPATH_SEARCH_PATHS combination. ( Let me know if you need more details on this ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM