Linking error with swift app calling to a objc static lib - objective-c

I have an objective c static lib and need to write a swift app using the lib. The swift project compiles fine but it is reporting a linking error when I try to run.
This is how connect the objective c and swift.
Drag and drop the include directory with public headers to supporting files
Then added the .a lib file in to the build phases
Then created the bridging header and included the public headers of the lib there
This is the linker error I am getting
But the lib is built for armv7 according to lipo -info
What am I missing here? Is this a xcode bug(I am using xcode 6.4)?

Swift doesn't support static library.
See if updated version of your library available with swift support, That is the only work around..

Related

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

c++ static library import to XCode Cocoa project

I'm very new at Objective-C programming, I have a MacOSX project, with a simple UI code. It has a login function.
I have a .a extension c++11 static library, with two public headers. One includes . I d like to import the library with the headers to my project. It makes the login to my server.
I made a c++ static library target to the code, and imported the needed files, set the c++ flags (stdlib=libstdc++ and -std=c++11) and added gcc49 to search paths. But I get file not found exception to #include in my c++ header.
Have somebody a good tutorial how to solve my problem?

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.

Using GLM .obj loader in an Objective-C program

I am trying to use GLM to load a .obj object in my Objective-C Program (Xcode 4.4 Mac Os X). I have added the glm folder to my project. i try to import it using #import "glm/glm.hpp", but the program doesn't build. some of the errors are the following: (this errors are produced in the GLM files)
namespace glm{ //Unknown type name 'namespace'
namespace detail
{ .....
It doesn't find the cstdlib, cmath, and other libraries.
This happens because my program is in Objective-c and the GLM doesn't work with this language?
Those are all symptoms of trying to compile a C++ application with a C compiler. Namespace is a C++ keyword, and cstdlib, cmath, etc. are C++ names for standard C headers. You'll have to migrate your project to Objective-C++ to be able to use GLM.
Any files that uses the GLM library will require that file extensions to be renamed to .mm as it uses Objective-C++. Also, as it is only a file, and not a framework, you only need to put #import "glm.hpp"

How to compile specific files in objective-c++ and the rest of the project in objective-c

I'm currently busy on a project where I need to use an external accessory to read Mifare 1k tags.
The accessory was provided with an SDK, written in (Objective ?)C++ and I followed the instructions provided to set XCode to "Compile sources as: Objective-C++" and added "-Obj-C++" in "Other linkers flags.
The SDK compiles fine then, but trouble is I am already using several libraries in the project (such as ASIHTTPRequest, JSONKit, ...) and I get compilation problems because of those new settings in those libraries. If I switch back to the previous settings, I get compilation problems in the reader's SDK
The question is: is there a way to compile only the class from the SDK as C++ and the rest of the project as objective-c ?
Edit: the SDK files consists only of .h (and a linked library)
thanks for your help,
Mike
Select the file you want to compile as Objective C++ from the file navigator, and then select the File Type in the file inspector view. This is in Xcode 4, but there is a similar mechanism in Xcode 3.
Try renaming the files where you are including the library headers to myClass.h for interface and myClass.mm for implementation files. This forces the files to be compiled as objective-c++.
I have resolved this problem:
You should set "According to file type" to "Complile Sources As",
Set "-ObjC++" to the "Other Linker Flags"
The last,you should modify the files's suffix to .mm that reference
the library method
well, in Build phases tab, there is a section Compile sources. For file you want to use Objective-C++ compiler add flag: -xobjective-c++
tested in Xcode 12.5