Static library not working in objective c. How to make it? - objective-c

ld: warning: ignoring file
/Users/srm-mac10/Downloads/ICodeBlogStaticLibrarySample/MathTest/Classes/iCodeBlogsMathLibrary/libICodeMathUtils.a,
missing required architecture i386 in file Undefined symbols for
architecture i386: "_OBJC_CLASS_$_MathFunctions", referenced from:
objc-class-ref in MathTestAppDelegate.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit
code 1 (use -v to see invocation)
Following error coming while i am trying to make a static library in objective C. Any idea ??
Please help me.

The iOS simulator runs natively on the system's CPU, which is an x86 architecture. Hence your code needs to be built for x86 (which is presumably working already) and any libraries you link to also need to be built for x86.
If this is a static library that someone else has supplied to you (perhaps you purchased it?) then you will need to request the x86 version as well and link against that.
If you are building the static library yourself, check the build settings for that project (I'm assuming it's a separate project) and make sure it's configured to be compilable for the simulator. Then explicitly build the library for the simulator.
(I've run into some weird issues with static libraries where Xcode 4.x fails to automatically build the correct library architecture, necessitating an explicit manual build.)

I think you have to set the flag "-all_load" in the "other linker flags" in your project build settings

Related

Compile framework with Xcode 9

When I compile framework with Xcode 8 and after that import in new project it successfully build and I am able to test it. But when I compile framework with Xcode 9 and after that add builded framework in new project I got:
Undefined symbols for architecture arm64:
"___llvm_profile_runtime", referenced from:
___llvm_profile_runtime_user in xxxxxxxxx(DMCService.o)
___llvm_profile_runtime_user in xxxxxxxx(APXUserInterfacePresentor.o)
___llvm_profile_runtime_user in xxxxxxxxx(APXDevice.o)
___llvm_profile_runtime_user in xxxxxxxxx(APXInboxService.o)
___llvm_profile_runtime_user in xxxxxxxxx(AppoxeeManager.o)
___llvm_profile_runtime_user in xxxxxxxxx(APXApplicationSession.o)
___llvm_profile_runtime_user in xxxxxxxxx(APXInbox.o)
...
(maybe you meant: ___llvm_profile_runtime_user)
ld: symbol(s) not found for architecture arm64
I check builded framework with -lipo -info architecture and it has arm64.
This is happening only if I build framework for real device, if I build it for simulator it works fine. So I can not figure out why it is not working?
Thanks in advance for help.
Likely your framework build configuration has the setting "Enable Code Coverage Support" (the underlying setting name is CLANG_ENABLE_CODE_COVERAGE) set to YES, while in the application you include the framework, the same setting is set to NO.
For why this causes the Undefined symbols error: enabling the setting causes calls to instrumentation functions to be injected into in the framework code. But when building the app, the library where these functions are defined is not linked. So the linker (ld) fails.
Try again, building the framework with Enable Code Coverage Support set to NO.
Also, to avoid these kind of configuration mis-match errors, you might want to build the app and framework at the same time instead of pre-building the framework separately. You can do this by including the framework project as a subproject of the app project, or creating a Xcode workspace that includes both the app project and the framework project.

Undefined symbols for architecture x86_64 for mac

I used podofo library for mac application development, while building demo app i am getting following errors.
The error messages seem to indicate that you are working with static libraries (.a libraires). So, when building your demo app, you need to link with all the librairies needed, including the ones needed by freetype and fontconfig. These are bz2, z, crypto (from the openssl distribution) and others...
If Podofo is built with cmake, you can look at the CMakeCache.txt file. It contains the path where each library Podofo depends on was found on your system.
The bz2 library is not listed in the CMakeCache.txt. It is there by default, so you may just add
-lbz2
to the "Other Linker Flags" in your Xcode project build settings.

Undefined symbols for architectures armv7: "_MGCopyAnswer", Can't Solve

So, I'm creating a jailbreak app and I'm trying to use libMobileGestalt.dylib in the app. I link the file correctly and add the header and call MGCopyAnswer. The problem is, I get this error:
Undefined symbols for architectures armv7: "_MGCopyAnswer", referenced from:
This error only occurs when the app is built with armv7 architecture. It doesn't occur when arm64 architecture is used. I know that this occurs due to the dylib being built with the arm64 architecture, but I really want it to work with the armv7 architecture so that the app would be compatible with a larger range of devices.
Is there a place from which I can obtain the armv7 architecture version of the dylib, or be able to build it again with that architecture included? Is there any solution to this that anyone knows? Thank you for helping in advance.
you have to import libMobileGestalt
under target
then Build Phases
and Link Binary With Libraries
then added new Binary
when you see search field
type " libMobileGestalt.dylib "
and then Add
I found out the solution. The reason I was getting an error was that I was linking that dylib to a static library I was creating, which isn't possible, so I had to also link this dylib to all the projects I created that use the static library (which in turn uses the dynamic library). Hope this makes sense :P And thank you all for trying to help :)

_objc_retain", referenced from:__ARCLite__load error in Xcode 4.4

I've recently upgraded to Xcode 4.4 and have been using it for some Mac App Store submissions. Two worked fine but the third gave this error:
Undefined symbols for architecture x86_64:
"_objc_retain", referenced from:
___ARCLite__load in libarclite_macosx.a(arclite.o)
(maybe you meant: _objc_retainedObject)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ARC is turned off so I don't know where this reference is coming from, or how to get rid of it. I've tried the usual clean/build cycle but to no avail.
Any thoughts?
I think you should use the SDK 10.6 on Xcode 4.4,right?
If so, please Change "Implicitly Link Objective-C Runtime Support" to "NO".
Is your base sdk lower than 5.0? I'm using Xcode4.5, and get the same error when i building with iOS 4.2.After I changed it to iOS5.0(or above), the error disappeared.
I'm sorry,you talked about Mac app.But i think the reason may be the same.
OK,i found an answer: Change "Implicitly Link Objective-C Runtime Support" to NO may work.
I had the same problem in Xcode 7.0.1 with iOS 7.0. The solution was to change the Deployment Target from 7.0 to 7.1.

iHasApp.a framework is not detected by compiler

How to add the framework iHasApp.a framework into my Application bundle framework or framework.I tried to add through bundle phases and add files, but still i am getting the following errors.
Undefined symbols for architecture i386:
_OBJC_CLASS_$_iHasApp, referenced from:
objc-class-ref in RootViewController.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
And I am not able to add this framework.
Author of iHasApp here. From your description, you are using the static library from http://amitay.us/ihasapp/index.php
As Armaan asked, are you trying to run it on the Simulator? As per the warning on the website, iHasApp was not compiled to run on the Simulator. The warning you are receiving indicates that symbols are not being found for the i386 architecture, namely the iOS Simulator.
You will only be able to compile that project on an actual device.
The following is not meant as an advertisement: iHasApp is now being maintained as a new, more comprehensive software as a service at https://www.iHasApp.com. It is currently in the late stages of beta. If you would like to participate, then sign up for an account and email me at daniel#ihasapp.com. This newer framework will run on the Simulator (although it is somewhat pointless).