How to build a C library for iOS by Xcode 6? - ios

I trying to build C library for iOS like the following picture.
I have build the liblib.a , but it compile error after I use liblib.a
The error log is like the following when I use liblib.a
file was built for archive which is not the architecture being linked (armv7): /Users/apk/Desktop/libTest/liblib.a
Undefined symbols for architecture armv7:
It seems the liblib.a not support for armv7, but I didn't find the armv7 and the arm64 in Build Setting -> Architectures.
How do I build the library of C code for armv7 and use in Objective-C ?
---------------------EDIT---------------------
After I change the setting like the following picture.
It has the .a file. But when I try to use this library , it also show
file was built for archive which is not the architecture being linked (armv7): /Users/apk/Desktop/libTest/liblib.a
Undefined symbols for architecture armv7:
Did I missing something ?
---------------------EDIT2---------------------
I build the .a by following step.
1.Create new project.
2.Setting
3.
4.
5.put the C file and the .h file into project.
Press the build button
Thanks in advance.

You Want Creating library for ios see below picture for Architectures setting
Try this

The Base SDK is set to "Latest OS X" not "Latest iOS".

Related

Missing 64-bit Support and Lipo Error!! can't open input file in Xcode 6.3

I downloaded Xcode 6.3 and while Submitting App to the App Store,I'm getting following error's.
In My Build Setting Architecture, If I'm using Build Active Architectures Only to YES
Then I m getting this Error -
lipo Error!! can't open input file.
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo: can't open input file: /Users/XYZ/Library/Developer/Xcode/DerivedData/MyAPP-hjbmqpnmsoruqxbwlayqkjsojccv/Build/Intermediates/MyAPP.build/Debug-iphoneos/MyAPP.build/Objects-normal/armv7s/MyAPP.
If I'm setting Valid Architecture to armv7
I am getting following error while submitting app to AppStore-
You are likely using a library that does not support 64 bit. If this is what's causing the problem, you can fix it by updating the library.
The check for this, look at your compiler errors, to see if any point to a third-party library that you're using. They would look something like this:
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_THIRD_PARTY_CLASS_NAME", referenced from:
objc-class-ref in YOUR_CALLING_CLASS.o
Don't change the setting for Build Active Architecture Only. This should be set to NO for the App Store build, unless you are certain that you only want to build for a device with the exact same architecture as listed in your project settings.

Xcode - unidentified symbols for architecture archs in libpjmedia-codec-arm-apple-darwin9.a(opencore.o)

I really having a hard time to figure out the problem.
i'm using PJSIP and also opencore-amr.
successfully compiled opencore-amr to arm64 (lipo -info told me)
successfully integrate opencore-amr (arm64) with PJSIP
(arm64),configure it, make dep, make clean and make without any
error.
when i try to compile it with XCode. it says
Undefined symbols for architecture arm64:
"_Decoder_Interface_Decode", referenced from:
_amr_codec_decode in libpjmedia-codec-arm-apple-darwin9.a(opencore_amr.o)
I did ar-t libpjmedia-codec-arm-apple-darwin9.a and the opencore.o inside the library is arm64.
I really have no clue to solve this.
please help me, thanks
FYI : I've tried open core with pjsip for android, and no issue at all.
This is the linker error, you probably forgot to link some library. Go to Project settings -> Build phases -> Link Binary with Libraries section and review it. Try to google which framework contains the classes mentioned in error log and then add it to frameworks list.

Xcode error: file was built for archive which is not the architecture being linked (x86_64)

I have a iOS Xcode project that builds and runs fine in Simulator and device. However, I have a new feature that requires using a static library (built for ARM architecture only) - which means that it builds & runs fine on device but for simulator I get this error -
ld: warning: ignoring file libXYZ.a, file was built for archive which is not the architecture being linked (x86_64): libXYZ.a
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_XYXClass", referenced from: objc-class-ref in MyAppClass.o
I understand the issue but I still want to be able to build & run the app in Simulator (perhaps by excluding or disabling the new feature in Simulator which requires the static library).
I have tried the following project settings so that the app can build for Simulator as well -
Setting 'Architectures' to $(ARCHS_STANDARD_INCLUDING_64_BIT)
Setting 'Build Active Architectures only' to NO
Nothing has worked. Any thoughts how I can build for Simulator? Thanks!
The easiest solution is probably just build the static archive with intel slices (against the iOS Simulator SDK) in addition to the arm ones such that it is 4-way fat (i386+x86_64/iOS Simualtor and armv7/arm64/iOS).
If that is not possible, please explain why that is not possible for you and file a radar at http://bugreport.apple.com, so we can address whatever problem is preventing you from building your static archive.
If you want to proceed without using the static archive in the iOS Simulator build, you will need to avoid using the XYXClass in the simulator. You can do this by doing something like:
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR
// Do sim-specific fallbacks
#else
// Do stuff with XYXClass
#endif
Note that the "warning: ignoring file libXYZ.a ..." message is not fatal. It's just a warning that you can ignore. The fatal part is your use of the XYXClass which doesn't have an implementation in x86_64.

Cordova 3.5 iOS - Xcode Apple Mach-O Linker error for CDVCamera

I'm encountering an error during the build phase of my cordova (3.5) project:
Undefined symbols for architecture i386:
"_CGImageDestinationAddImageFromSource", referenced from:
-[CDVCamera imagePickerControllerReturnImageResult] in CDVCamera.o
... and 15 more of those
A lot of posts noted, that i have to add the CDVCamera.m file into the compile sources section.
Without the entry i don't get the error... obviously my app won't be able to use the camera in that case.
I tried different versions of the plugin, but nothing changed.
Is there something i may have forgotten?
I have had the same issue and I have managed to fix it from xcode:
Select Target
In Build Phases > Link Binary With Libraries you should add ImageIO.framework and CoreGraphics.framework
An image with my settings: http://screencast.com/t/rsxZrUkyslAY
Following DotNetWise's advice I also had to add the Location framework to get it to work.

Undefined symbols for architecture armv7 - route-me library, ad hoc only

I have read through all of the other questions related to this topic, and can not find my answer. My project is using route-me. It builds just fine for the simulator, and for a connected iPad. The archive for ad hoc will not build. I had successfully produced an ad hoc archive - and installed it - prior to implementing route-me. My error is:
Undefined symbols for architecture armv7:
"_ApplicationVersion", referenced from:
-[RMWebTileImage startLoading:] in libMapView.a(RMWebTileImage.o)
"_ApplicationNameFromBundle", referenced from:
-[RMWebTileImage startLoading:] in libMapView.a(RMWebTileImage.o)
ld: symbol(s) not found for architecture armv7
My library is properly linked - it builds for simulator and iPad error free. I do have
[RMMapView class];
in the view controller that is displaying the map. Prior to having that line, my app would crash if installed from the archive with iTunes - although it would not crash if installed from Xcode. Now the archive will not build at all. (But I still believe the above line has put me on the right path).
I have tried every solution that might apply that I have been able to find here. If I remove the references to RMWebTileImage.h and RMWebTileImage.m - I get the same errors, except then it makes sense. But when I add the references back in, I still get the error, as if the files were not even referenced.
Any help would be appreciated.
It looks like the static library of route-me does not have the armv7 symbols. Check the build settings of the library and make sure the architectures build settings are set to build for armv6 and armv7.
You also always can use lipo -info on your static library to see all the included architectures.
If you are linking the Debug configuration, this is mostly set to build for active architectures only. Make sure the projects build settings are identical to the route-me project settings.

Resources