GHUnit testing against an application that uses a library - objective-c

I'm trying to build some GHUnit tests based on an iOS application I have which uses ProtocolBuffers, accessed as a library. I've run into lots of linker problems which I've slowly killed off by adding the source files from the application to the "Compile Sources" build phase, but now that I've added everything relevant in the application, I have found that I can't seem to link against ProtocolBuffers.
I have read GH-Unit for unit testing Objective-C code, why am I getting linking errors? wherein the poster seems to have fixed his situation based on the README update at the bottom. Since I have a hybrid - I am linking GHUnit against both an application and a library, I started with the assumption that I should add the ProtocolBuffers output as a dependency in addition to adding all the application source files to my "Compile Sources" build phase.
This hasn't worked. I continue to get linker errors which clearly show that the linker isn't finding symbols from the ProtocolBuffers library. I can't add the ProtocolBuffers source files because they're not in this project, and even adding #import "ProtocolBuffers.h" to my tests.pch file doesn't work.
I'm now stumped. Any suggestions? GHUnit looks great but, as it seems to always be with Xcode/ObjC testing tools, getting to "Hello World" is more trouble that I would expect.

Related

Can't run xctest on macOS app - couldn’t be loaded because it is damaged or missing necessary resources

Please do help me on this scenario. I saw several post related to this, but could not able to resolve the issue with my mac App without pods.
Project is several years old, developed in macOS(Objective C). Now I am trying with XCTest for unit testing. Using Xcode 7.3.1, I am not able to run tests classes.
This project is to create frame work. Project is working fine, only issue is with the testing. We are not supposed to do Pods or some other alternatives.
Console window shows below points:
xctest[35530:345970] The bundle “BaseLibTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle. xctest[35530:345970]dlopen_preflight(/Users/12345678/Documents/Modify/Cocoa/Projects/BaseLib/build/Debug/BaseLibTests.xctest/Contents/MacOS/BaseLibTests): Library not loaded: #executable_path/../Frameworks/FreeTDS.framework/Versions/A/FreeTDS
Referenced from: /Users/12345678/Documents/Modify/Cocoa/Projects/BaseLib/build/Debug/BaseLib.framework/Versions/Current/BaseLib
Reason: no suitable image found. Did find:
/Library/Frameworks/FreeTDS.framework/Versions/A/FreeTDS: no matching architecture in universal wrapper)
Program ended with exit code: 82
#Anand For the 3rd Point: Please check the build settings.
Please make sure its either set to Standard Architectures (64-bit Intel) (x86_64) - $(ARCHS_STANDARD) or set to represent proper architectures.
To debug this more, could you please copy paste the exact error you are facing and share the build env variables?

Xcode: how to build a static library project correctly?

This question will be easy for Xcode pros but for a MonoTouch developer it seems to be impossible to resolve. :-)
I'm using Xcode 4.5 and I want to target iOS 5.1 and above and iOS Simulator 5.1 and above.
I have a a library project here and it is coming with a prebuilt binary named "DemoLib" (no extension and it is 11MB in size). The library is a fat lib for Simulator and iOS 5.1+.
I can use that library without any problem.
However if I try to build the library myself, I end up with a "DemoLib.a" file (notice the extension and the size of 30MB). How can I get the same build result? What is a .a file compared to the file without extension?
I tried to build the project "for running", and "for archiving" in Xcode. Both results in the same 30MB .a file.
I was expecting some dropdown in Xcode where one could select "DEBUG" or "RELEASE" build and the latter one would create the smaller lib.
Of course I could never tell without seeing the framework's project file. Having said that, there is an excellent guide to creating and compiling iOS frameworks here: https://github.com/jverkoey/iOS-Framework
Using the above guide, you should be able to recreate your framework's project from scratch, add the files you have to it, and properly compile it.
Hope this helps! :)
Did it come with a Makefile? Create a new target, set the build settings of the target to what's in the Makefile, then set your project to depend on that new target.
A file with the .a is a static library, which means it depends on nothing external and all the code it needs is compiled inside it. I think no extension generally implies dynamic library, which means it'll depend on some dependencies being present on your system to link against. Maybe that's why the .a is so much bigger. I think Xcode will build static by default because iOS does not allow the use of dynamic libraries.
The dropdown for what to build is in your scheme. Command+shift+< to view your scheme. Within the scheme you can edit which environment each method of building will use.

How can I use Farseer with a MonoTouch/ExEn application?

I'm trying to build a game for iOS with XNA and Farseer Physics 3.3, using ExEn and MonoTouch. In theory this should work fine, but I'm having trouble getting Farseer to work on the iPhone.
I compiled Farseer for MonoTouch/ExEn, and it works great in the iPhone Simulator. But as soon as I switch to the actual iPhone, my project no longer compiles. The problem appears to be happening with the MonoDevelop linker. The compiler bombs out with the message "mtouch exited with code 1", and I get the following linker error output: http://pastebin.com/y62ykJP2. If I disable linking in the project options, the application compiles and deploys to the iPhone, but then crashes.
If I comment out all of the code that instantiates objects defined by Farseer, I don't get any linker errors, and the program deploys and runs just fine. So the problem is clearly with my build of Farseer for MonoTouch.
Unfortunately, I have no idea where to go from here. Where should I start looking with a linker error like this? Or, even better: Has anyone successfully compiled Farseer 3.3 and used it with MonoTouch and ExEn?
You're trying to use an assembly compiled for .NET 4.0 in MonoTouch. This will not work (the linker exception you get is because the assembly references a method that does not exist in MonoTouch).
The solution is to compile all assemblies you reference using MonoTouch. Look around to see if anybody already has created a MonoTouch project for Farseer, otherwise you'll have to create one yourself.

PhoneGap template-based app failing to compile AdWhirl sources

Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I cant find it now :( - PhoneGap is a static framework).
The app works ok on its own.
Now trying to add in AdWhirl. AdWhirl comes as source files - no library of its own, although there are libraries for the specific ad services you use.
I have added the folders to the project, but it does not seem to compile the AdWhirl sources - if amend/break the AdWhirl code, I get no compile errors.
Where I have included/imported the AdWhirl headers into my app, I had to tweak the related imports in AdWhirl files to find their dependancies - seems to be related to issue above.
I can get it compiling with that hack - but then fails to link - missing AdWhirlView, which also seems to be due to first issue - not being compiled, so not available to link.
Under build phases/compile sources, I have just 2 items: main.m and AppDelegate.m - do I need to add the AdWhirl code into here?
Here is a sample project with just the AdWhirl stuff, no PhoneGap, but still has the issue :(
Thanks in advance for any tips/pointers.
Just wanted to post the answer here that I gave on Twitter. Seems like the issue is that Xcode is unhappy with folder references. Try reimporting the AdWhirl files into your project, but tell Xcode to add groups for folders, rather than folder references. (Incidentally, if anyone knows why Xcode is choking on the folder references, I'd love to hear about it.)
Then, you'll start getting errors about ARC and missing files pertaining to the Google Ads framework. So, you'll have to add the Google Ads files to quell the errors; then, you'll want to make sure ARC is disabled in your project. If you want to use ARC, then your best bet is to repackage AdWhirl as a static library that builds without ARC, and have that as a dependency in your workspace.

Linking libcsoap to iPhone project in Xcode

I have an iPhone project that I want to use libcsoap in to make service calls. I'm having trouble linking a pure c library to xCode though. I've tried everything short of manually rebuilding the project as an Xcode project.
I built it via command line (./configure; make; make install). Then linked the output (libcsoap.a) and connected to the headers. This gave me a linker error saying that libcsoap.a was built for archiving and couldn't be used.
I tried creating a project out of just the makefile but that failed to build.
Can anybody explain to me what I should do to link these?
Thanks in advance,
George