DYLD_INSERT_LIBRARIES and iPhone - iphone

I understand that Apple doesn't support using dynamic libraries in iPhone applications. But we are working on a in-house application and we have a unique requirement to use the dynamic libraries. Our requirement is to load a dynamic library as part of "iPhone" application start up. I read that DYLD_INSERT_LIBRARIES is meant for this purpose. So I edited the Info.plist and added below entry.
LSEnvironment
DYLD_INSERT_LIBRARIES
#executable_path/sample.dylib
But it does not seem to be working. Can you please let me know your thoughts ? Really appreciate your help in this regard.
Thanks
--Neo

I've found a way to successfully add LC_LOAD_DYLIB load command to a MachO binary using optool.
$ optool install -c load -p "#executable_path/<dylib_path>" -t <executable>
$ otool -L <executable>
When building optool, make sure that build setting OTHER_LDFLAGS includes -ObjC.
optool does not seem to be able to successfully add load commands for arm64 architectures, so you may want to remove arm64 from the binary
$ lipo <input_file> -remove arm64 -output <output_file>
Edit:
There is an open pull request with support for arm64.

I also working on the same problems for last few days. I also didn't succeed to do it the way you try. So I try to launch my app from another app using this link:
Dynamic Library injection
,unfortunately Apple Block running multiple tasks (even on iphone simulators) but you can try maybe you will have more luck. I know its not a answer you expect but maybe it will give you some way to think. Please share if you have some progress.

You "could" load a binary at runtime and you can manipulate xcode settings to make it compile dylibs for iOS. See this answer:
https://stackoverflow.com/a/10509453/784387

Happy to be corrected, but dylibs are not supported and will not work. You need to get the code for the libraries and compile them into a static lib for the arm6/7 architecture. Then you can easily include these libs. There are plenty of examples of static libs and XCode also provides targets for building them.

Related

pjsip iPhone missing libraries

I am working on pjsip for voice chat on iPhone. The steps I have completed from the instructions are:
changed config_site.h as given.
successfully ran
$ cd /path/to/your/pjsip/dir
$ ./configure-iphone
$ make dep && make clean && make
opened ipjsua.xcodeproj to build but some libraries are missing (highlighted in red). The project therefore does not build and I'm unable to proceed further.
How should I build project?
Delete the missing libraries, locate this libraries in your build directory and then add them again to your project.
I could sort out the problem,
it wasnt big problem actually.
my project is not configured to run on simulator,so here are so many linking errors(these red colored librarys required to support pjsip on simulator).
i set my target as my ipad instead of simulator and made build.
it just worked!

MonoTouch - System.Reflection.Emit.ModuleBuilder error

I am trying to test my app in IPhone (IOS 5) and I get the following error. It works in simulator without any issues.
I am referencing an external library (NewtonSoft.Json.Monotouch.dll) which seems to be using System.Reflection.Emit.ModuleBuilder. Is there a way to overcome this issue? Any help regarding this is much appreciated.
" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime.Serialization.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Web.Services.dll" -r "/Users/test/application/libraries/Newtonsoft.Json.MonoTouch.dll" -linksdkonly -sdk "5.0" Framework is: /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
Copied
/Users/test/application/bin/iPhone/Release/Unleashed.app
Could not link assemblies: Mono.Linker.ResolutionException: Can not resolve reference: System.Reflection.Emit.ModuleBuilder
Thanks
UPDATE:
Alright, I downloaded the latest NewtonSoft.Json source code from link, compiled the project and dropped the dll into my project. I still have the same issue. I did figure out the class that refers to System.Reflection.Emit. It is DynamicWrapper class in the Utilities folder.
I saw a similar issue posted in another blog link. The responded to the question suggests to set the Liner behavior to "Link all assemblies". Can anyone explain how to set this?
Newtonsoft.Json.MonoTouch.dll is known to work with MonoTouch. I've seen/compiled many application using it myself.
It's likely that you are either using an old or a mis-compiled version of assembly (e.g. missing defines). Difficult to say which without knowing it's origin. Try to track a newer version (or edit your question to include where it comes from).
Note: The fact that it works with the simulator is because a different mscorlib.dll is used to allow JITting (instead of AOTing) the managed code. This allows the simulator builds to be much faster than device builds.
Instead of compiling the Newtonsoft.Json.MonoTouch.dll, which did not work for me either, I downloaded the source code from github and added the project to my solution in MonoTouch and compiled the solution. Only then everything worked. (and of course as popou mentioned do not forget the MONOTOUCH;NET35;SILVERLIGHT options.)

Correct configuration to build libsrtp for the iphone?

I'm trying to build libsrtp so that I can use it on the iPhone (I intend to use it with libav's implementation of RTP).
My configuration:
./configure
--build='arm-apple-darwin9'
The warning I get when I attempt to call srtp_init():
file was built for unsupported file
format which is not the architecture
being linked (armv7)
Followed by the error:
"_srtp_init", referenced from:
+[Manager initialize:] in Manager.o
Symbol(s) not found
Does anyone know the proper configuration for building the library correctly?
The problem is it's not being built for ARM (or not for the right ARM; you need to look at which compiler is bing invoked with which options, and compare it to one you know is working). Did you do rebuild configure with autoconf? See the GNU build system wiki page for a starting point on how to reconfigure the build for other systems/processors.
FYI, if you find a bug in the configure.in or other parts of libsrtp, please let me know - I'm an author on it with checkin privs.
For general guidelines on cross compiling libraries for iOS I recommend this article:
http://tinsuke.wordpress.com/2011/02/17/how-to-cross-compiling-libraries-for-ios-armv6armv7i386/
The same guy also wrote an updated version for iOS 5. This one is specific to the tesseract library, but the general principles are the same:
http://tinsuke.wordpress.com/2011/11/01/how-to-compile-and-use-tesseract-3-01-on-ios-sdk-5/.
Using these as a guide I've had some success compiling a few libraries. Key things to note are that you have to disable compiling shared binaries. Also I recommend using clang rather than gcc.

How to compile third party c library in Xcode?

i tried to do a sip client for iphone.
I tried to use oSip or eXosip2 , i download their package ,and compile it using "./configure""make""make install "
I get some *.a library, and i include there headers.
When i compile it , their is warning , this *.a library formate doesn't support !
It's really annoying, what should i do to make it work ?
Should i include their code ,and compile in xcode ,tried to build a static library ?
somebody tell me ,how to deal with some C librarys.
I see some topics talk about how to make a library in xcode . The problem is , if it is C library , it was already done, no need to build in xcode ,it's already their ,just make to build it . Whatif the *.a library doesn't support ,what should i do ??
PS: I was already doing the static library ,not dynamically. It's not a chooice between dynamically and static . It's all about x86_64 PC LIB is not suitable for i386 iphone.
You can't dynamically link on the iPhone; it has to be static linking.
Should i include their code ,and compile in xcode ,tried to build a static library ?
Yes, I think so.
Maybe have a look at this previous question: How do I add a third party Framework to iPhone project?
In order to compile for iOS, you should create an xcode project. It will be much easier to use, maintain and debug.
You can download here my osip/exosip/c-ares xcode project.
The above also requires c-ares which is an important dependancy for eXosip2.
PS: minor update may be required to compile git version. Just add/remove new/old files.

XCode linker error : library not found for -lAdMobDevice

I am trying to build lite version of my iPhone application using AdMob. I followed the guidelines here http://www.iphonedevsdk.com/forum/iphone-sdk-development/11358-creating-lite-version-app.html and created two different targets. In the lite version I added a macro called LITEVERSION which I am checking using #ifdef and doing the appropriate things.
But when I build the lite version of the app, I get a linker error
ld: library not found for -lAdMobDevice
collect2: ld returned 1 exit status
However I am able to build the full version without any issues and also noticed that build is working fine (for the fullversion) even if I remove the #ifdef macros. This suggests that the libAdMobSimulator.a library is linking properly for the full version however it fails on the lite version.
Any pointers would be greatly appreciated!
Cheers
Jugs
When I had this problem, the cause was that I'd added the library into Xcode by dragging it in like a regular source file.
The fix was to remove it, and then add it properly using the "Add->Existing Frameworks..." dialogue.
I got similar error as I was using CocoaPods libraries
library not found for -lPods-MyApp
I got the error because I opened xcode project instead of workspace.
I was using CocoaPods, and ran pod install, and that fixed it.
I figured out what he problem was. I just removed all frameworks and libraries and added them back in for both the targets and it worked!
Cheers
I cause this because of a libray libMobClickLibrary.a which is used in youmeng sdk missed. I fix the issued after copy libMobClickLibrary.a to the project floder.
I had the same problem with Google Analytics library. My problem was that I forgot to add the path to the Library Search Paths in my target's build settings. (Target -> Build Settings -> Library Search Paths)