Using iOS Static Libraries without adding .a Files - objective-c

We can use iOS Static Libraries without adding header files into the project.
But i want to use the Static Libraries without adding .a files into the project

Finally, I found the solution
Path of the static library should be added in ->target->build settings-> Other Linker Flags
eg.)
/Source/iPhoneApp/libs/Connection/build/Debug-iphonesimulator/libConnection.a /Source/iPhoneApp/libs/SocialNetwork/build/Debug-iphonesimulator/libSocialNetwork.a

If you built the library, you can use dependencies to add the library project to your app project without the hassle of configuring stuff.
To do so, just drag the .xcodeproj file from your library to the app project, go to the app target properties, and add a dependency on that library, just as you'd add a public framework such as MapKit.

Related

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).

Unable to access swift file from static library to application target

I have workspace contains subprojects and one of the subprojects generates static lib which contains both ObjC and swift which is linked to main application project. I am unable to access a swift class from a static library in ObjC file in application target.
How can I access a swift class from the static library in ObjC file in application target?
I figure it out.
The issue was module-swift.h of subproject static library is generated in derivedData intermediate DerviedSource folder which is not known to main application target.
The issue resolved :)
I think, it is not possible. Xcode doesn't support Swift static libraries. You can read about it here: https://forums.developer.apple.com/thread/73900

Qt5 mingw - How to add required dlls to run an app standalone?

I made an application with Qt5(mingw). To run this application out of qtcreator, I have to put some dlls like Qt5Widgets.dll, Qt5Core.dll, ... beside the executable file. I tried to add these libraries to project, but "Add Library" option doesn't accept dll! I can only add static library(*.lib).
I just want to add required dlls to my project and make a *.exe file in output, without any dependency and no any dll around the executable file.
You want to build your application with static linkage. For static linkage you need to compile your Qt with -static option.
How to build static Qt:
For linux: http://doc.qt.io/qt-5/linux-deployment.html
For Windows: I used this guide https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW
Note: even with static linkage I provide msvcr110.dll and msvcr120.dll with my app, so I have .exe + 2 dlls. But maybe I do some things wrong, but at least I have 3 files instead of tons of it.

Xcode: automatic link static library dependency to Project

I've workspace with two project: static lib and cocoa application. Static library link some system frameworks(libcrypto.dylib) and include dynamic lib's .h files(openssl/bn.h openssl/rsa.h). My static library compiles successfully.
Cocoa application uses this static library and at compile time gives an error: "undefined symbols, symbols not found" (bn, new rsa etc).
But when I include libcrypto.dylib also into cocoa application project then there is no error.
Question: Xcode can do this automatically, by taking dependency from the static link library?
Thanks.
The answer is unfortunately no. It is common practice to include each single static library in the project that requires the code. That is just the way it is done.
There is an interesting article on how to handle multiple static libraries in an XCode project.

Making a reference in xcode 4.2

How can I make a reference to another project in xcode 4.2?
I trying to put Protocol Buffers working in Objective-C but I can't do this:
Open your existing project and a reference to the ProtocolBuffers project found in .
Add a reference to /Classes/ProtocolBuffers.h in your project and add the following line to your pch file: #import "ProtocolBuffers.h"
Get Info on your build target
Add ProtocolBuffers as a Direct Dependency of your build target.
Add libProtocolBuffers.a as a Linked Library of your build target. You may have to do this by dragging and dropping the library from the referenced ProtocolBuffers project to your target's Link Binary With Libraries section.
I solved the problem. For making the reference just add to the main project the xcodeproj file of the another project. And then add as Direct Dependency and Linked Library.