I need convert M4A files to MP3 and i guess this link is the answer : ios - convert .m4a to .mp3 file programmatically.
I was searching , how use LAME on iOS? and i find this :
https://gist.github.com/Superbil/7689556.
Once i execute, "build_ios.sh" 4 files are generated:
libmp3lame-armv7.a
libmp3lame-armv7s.a
libmp3lame-i686.a
libmp3lame.a
I understand the first two, are the libs that i need , for use this code :
ios - convert .m4a to .mp3 file programmatically.
How i can add this statics libraries to XCode and import for use the code?
I'm using the version 5.1.
Thanks in advance.
When using a static library, you need 2 things:
The static library itself (.a)
Header files to access its public interface
In the list of libraries you've posted, it would seem libmp3lame.a is the one you require. The three listed above it are for individual architectures, whereas the last one is a 'fat library', which is a collection of the individual architecture libraries. You can confirm this by running lipo on the fat library:
lipo -info libmp3lame.a
In order to incorporate it within your application, you need to:
Add the .a and header files to your project (with the application
being the intended target)
Add the library to the "Link binary with libraries" build phase,
found under 'Build Phases' for your target, within the Project
settings
Import/include the header files where you wish to use LAME
Ideally, it's worth having 2 sets of fat libraries; one for the simulator, and the other for the device. You can then include the appropriate one for the respective build target. This ensures the size of the application is the lowest it can be, but it's fairly harmless to include the simulator library within an App Store binary (it doesn't cause side effects).
Your question doesn't mention header files, and I don't see any reference within the build script as part of the build artefacts. You may need to copy the ones you require from the source itself into the project.
Related
I have an iOS static library.
As a matter of fact, I have four variants of it:
Debug-iphoneos/libopende.a
Debug-iphonesimulator/libopende.a
Release-iphoneos/libopende.a
Release-iphonesimulator/libopende.a
I want to link my iOS app against this static library using Xcode.
To do so, I go to Build Phases, and in Link Binary With Libraries, I click the '+' to add one, using Add Other.
Now I have the problem of which variant I should be adding. So I just pick one of the .a files, and hope Xcode is smart enough to find the others?
Anyways, if I do this, the linking fails saying it can't find libopende.a file.
So, is it even possible to do what I want, without first building a 'Framework' instead of a set of static libraries?
Ok, so when linking against a static iOS library, you need to know that:
It does not matter which .a file you add in the Build Phases - Link Binary With Libraries panel. Any of the four .a files will do, it only takes the file name, not its path.
To actually differentiate between library variants for Debug/Release Device/Simulator, you need to specify the correct library paths in the Build Settings - Library Search Paths.
Thank you in advance. I have a static library, say libpics.a. I want to see its contents, such as the code of that library. My static library has one .h file and one .a file, i can see content of .h file, there is only one method, but i can't see the content of .a file. After some search i can just find that, .a file contains the coding part of or implementation of .h file's method. I am new to iOS development, the code in that .a file, i want to extract it, and use it.
I tried searching about how to open static library, but most of time i got search related to how to create static library and how to use it etc. But i just want to open static library file and just want to see the code in it's implementation file.
I read something about nm and ar tool, but i don't understand that where to apply that code.
something like this
nm -C libschnoeck.a | less
or
ar -t libsamplerate.a
after installing command line tool, i wrote
ar -x phpFramework.a
code in terminal as per suggestion by Владимир Водолазкий. i got below lines..
ar: phpFramework.a is a fat file (use libtool(1) or lipo(1) and ar(1) on it)
ar: phpFramework.a: Inappropriate file type or format
You cannot see source code inside static library, just due to there are NO source codes there. Static Library in IOS like in any other Unix-like system contains set of compiled procedures/functions/methods.
Just take a close look to the Xcode log when ordinary project is building. You can find that first, *.m files are compiled into *.o format - it is actually binary format (which is different when source file is compiled for use in Simulator or on native device). Then these *.o files are linked into application. (Please do not blame me for this simplistic explanation %-))
In fact static library is just a set of such precompiled *.o files. It is shipped by developer/owner to save your time on compilation or/and protect source code from modification. So you can only use it with the help of external calls, which are documented in .h files or you can extract separate modules (.o) from there and link it into your application "manually".
The code used to create the library is compiled into object files that are linked into the .a file. The .a file does not contain code and you can't get readable code from the .a file.
However to use the library you do not need the code, just include the library in your Xcode project as per the Xcode documentation and #import the headers into your code so that the compiler knows what is in the libraries.
During the link phase of your project the linker will look at the object code generated from your code and the find unresolved symbols which it will then look for in the library and only pull in the objects from the library that are needed. (One benefit of static over dynamic libraries)
nm will list the symbols that have been defined in the library and which your code can call.
I am testing an image capture library that sent over their code library as a regular header file and a file ending in a "*.a" extension. I am not familiar with using a file in this format and can't seem to find the right "magic" to search for.
What does this file extension stand for?
What if any extra steps are needed to get it integrated with my XCode project?
Maybe a bit more of theory can get you in the right track so you'll know how to search next time:
.a files are archives of object (.o) files. These object files are generally produced by an assembler, compiler, or other language translator; They contain machine code that is usually not directly executable, but are used by linker tools to generate an executable or yet another library by combining parts of these object files.
Another important thing you should know is that since these files contain machine code, they must have been compiled for the correct architecture you're targeting for (ex.: armv7, i386, etc). That can be the reason why sometimes you will be able build your project for one device but not to another if you don't have the right set of files for the targeted platform (e.g. iPhone simulator vs. actual iPhone).
It is also possible to have "universal binaries", which are files that in turn package together archives of object files (.a) for different architectures (e.g. using tools such as lipo), so that the same library file can be given to the linker for multiple architectures. Or, you may have a different linker configuration for each target (e.g. using conditional build settings in XCode). All of these files can be analyzed with certain tools (e.g. "file", "otool", "lipo -info", etc), and each has several parameters to play with. Debuggers will also check the symbols within these files for their own purposes.
When you drag the '.a' file to your project's directory within Xcode, you can notice that it will automatically add this file to the list of "Link Binary With Libraries" items under your target's "Build Phases".
Since the header files allows us to separate certain elements of a program's source code into reusable files, that commonly contain forward declarations of classes, subroutines, variables, and other identifiers that are needed for reference during the compilation step, it is common to have libraries provided as archives of compiled objects (.o) in ".a" files along with their respective headers. For instance, as soon as you include the headers files in your XCode project, the editor will provide auto-complete for these new functions.
Sometimes, you might also consider having the actual source code of the library instead of binaries inside your project as this * might * make debugging easier in case an unexpected behavior is happening inside that "library" package. Many times this is not an option though (when you have no access to the sources) when the binary distribution is made in purpose to hide implementation details (commercial libraries).
.a stands for archive. It is also known as a static library. I believe you should be able just to drag it and the header files into Xcode. Xcode should pick up the right thing to do from its extension.
Example, see appr. from 30 sec here
http://memention.com/ac3dreader/usage/quickstart.html
Another example from Google Analytics, under Setup
Drag GANTracker.h and libGoogleAnalytics.a from the SDK's Library directory into your new project.
https://developers.google.com/analytics/devguides/collection/ios/devguide
I'm trying to add the openjpeg library to my XCode 4 project so that I can compress images taken by the iPhone's camera to jpeg2000.
I built the static library (libopenjpeg.a) using Cmake on OS/X. (I'm guessing this may have been the first error, that it needs to be built by XCode so it's built for iPhone architecture and not OS X).
I have the library added in the Link Binary with Libraries of my target.
The project builds successfully but I can't seem to import any of the headers from the library into any of my Objective-C classes. I've tried manually adding the folder that contains the libopenjpeg header files to the User Header Search Path but that did not seem to do anything.
Any suggestions?
for the simplest solution
Import the head files to you project's source.
You can still build it on the command-line with CMake, you'd just have to modify the CMakeLists.txt file so the right flags are passed when compiling.
However as Gavin indicates, it may be simpler just to drag the header and source files from the library into your Xcode project, and forego the building of a static library.
First, please forgive and point out if I am to use some other protocol for referencing another thread/post.
There was a previous thread how to compile spatialite for iOS where the top answer partly described building spatialite as a static library for iOS. The answer included the text:
"Once you've drag n drop the .a (both are required to work in the simulator AND on the real hardware), you can initialize spatialite by just invoking spatialite_init(1)."
I am guessing this is translated to some version of the following?
Xcode 4
File->New->New Target->iOS->Framework & Library->Cocoa Touch Static Library
Name the library - libSpatialite_TedS
Drag the header files to libSpatialite_TedS -> Copy Headers (question here ... there is a spatialite.h file in the 'headers' directory of the 'spatialite2.3.1.zip' download. Then in the subdirectory 'spatialite' there is another spatialite.h that is not an identical file and is obviously needed. Do we just drag the header files from 'headers' directory, then drag the directory 'spatialite' as a directory into 'Copy Headers' area of our Xcode static library 'myNewLibrary'?)
Drag the '.a files' libSPATIALITE2.3.1_arm.a & libSPATIALITE2.3.1_x86.a
Shouldn't we have some '.m' files to go with these headers in the 'Compile Sources' field?
Now, without referencing the libSpatialite_TedS in my project, when I 'Command-B' to build, the project build succeeds. However, when I look for the compiled product in
/Users/Admin/Library/Developer/Xcode/DerivedData/MyProject-gutnkbwqqonzgxbcmfzzzkadqhid/Build/Products/Release-iphonesimulator
I see build's products, but they do not include libSpatialite_TedS.
Is this because the compiler is 'smart' and recognizes that none of the header/.a files are referenced in the project so it does not bother compiling them?
And, is this the correct way to go about achieving the objective of the original poster how to compile spatialite for iOS?
Many thanks,
Ted S
I was running into linker errors with the original poster too, but solved it by including libsqlite3.dylib, libstc++.dylib, and libiconv.dylib in the target.
Hope this helps!
Ted, I believe that the .a (static library) files and headers are meant to be used in a project right away, rather than in another static library as you've described. They are the result of a project's output. I think you can find the project that built them, here:
http://lionel.gueganton.free.fr/spatialite/
And a little more on static library files:
What is a .a (as libcrypto.a) file?
EDITED
Here's another link that you might find helpful. It s a summary of the Static Library build process in iOS:
http://www.icodeblog.com/2011/04/07/creating-static-libraries-for-ios/