I have created a Unit Test target AFTER my app was already created.
The problem i have is that the test will fail with compiler errors unless i manually add each .swift file and library to the testing target. Since my app is a rather large app with many files and library dependencies this seems rather difficult to do.
I have followed the advice on this post http://twobitlabs.com/2011/06/adding-ocunit-to-an-existing-ios-project-with-xcode-4/ which suggests that XCode can do this by setting the "Bundle Loader" and "Test host" settings in the testing target and setting "Symbols Hidden By Default" to NO in the app target, but that doesn't work.
What is the right way to solve this?
You can add #testable import YourModule and then all your classes should be available in your test case file.
You can read a little bit more here and some Apple docs.
Related
I'm experimenting with SPM and, so far, adding dependencies to my main app target seems to work pretty well. However, the same isn't true when I try to add the same dependencies to a test target. Even though exactly the same libraries are listed in the 'Link Binary with Libraries' section, the dependencies are not recognised and/or seem to be missing their own (internal) dependencies.
I'm aware SPM is still something that many major frameworks only support on an experimental basis and this may be something that's not yet mature enough for production code but as I can't find anything to point me in the right direction, I thought I'd see if anyone could point out what I'm doing wrong (if anything) before I head back to Carthage.
Screenshots illustrating the difference between SPMs dependencies being recognised on the app target vs test target below. In the first image you can see that the compiler has access to all the Realm modules in the app target....
...but in the test target, most things (including some key dependencies required by RealmSwift) are missing despite adding the same package url.
I'm trying compile the lastest WebRTC version for iPhone. I not need to compile the entire solution, I only need to compile the VAD module.
To do that, I have created a Xcode project and I have tried to compile the source necessary, but I have a problem with the *.s files and its assembler.
Like in the FFMPEG library, I know that I must "translate" the assembler code to an assembler code that the gcc for iPhone understand, but I don't know how I do this manually.
I have tried to create a configure file and set in it "as=gas-preprocessor.pl" (like in FFMPEG), but does not work.
Any idea? How do I run the gas-preprocessor.pl manually?
Thanks.
I'm just finishing it on iOS and has built standalone static libraries of NS/VAD/AECM and AGC, here's some tips for you, and hope you success:
1. Source File List
for standalone VAD build, you should make sure your project has all of these files(no .s file needed), and I'm not listed the header files here, you will get some header file can not be found errors, just fixing it and things will be done.)
webrtc_vad.c
vad_core.c
vad_filterbank.c
vad_gmm.c
vad_sp.c
real_fft.c
division_operations.c
complex_bit_reverse.c
cross_correlation.c
complex_fft.c
downsample_fast.c
vector_scaling_operations.c
get_scaling_square.c
energy.c
min_max_operations.c
spl_init.c
2. Adding a macro called WEBRTC_MAC
I'm not sure why the Xcode environment does not provide this macro, but it should be defined to ensure that WEBRTC_POSIX is enabled. To define this macro, adding it to a new header file or just define it in the webrtc-header-files.
3. Following these steps to build and setup a static library of WebRTC-VAD module on iOS
notice, do not use LLVM 2.0 to compile the VAD module(use GCC or LLVM GCC). cus' it can throw you lots of errors when compiling some webrtc variable declarations.
4. Using the libwebrtc_vad.a
if you got this far, things are easy to go, just include webrtc_vad.h and using the API provided by this module. and vad is working fine in my case.
hope i helped.
try to check this link https://groups.google.com/forum/?fromgroups=#!topic/discuss-webrtc/VJg-fk2-i_0 i believe you have to set inline assembly correctly. I am also onto this so let me know if you want to switch emails or something.
I have an existing iPhone application, and I just wanted to make a static library out of the code, so that I can use it by a separate test application (within the workspace). The application compiles fine, but when I try to compile the library version (which has the same code files) I get the following error:
Lexical or Preprocessor Issue - "MyClass.h" file not found
However, the application still runs, even through there is this error. In fact when I compile the application (which uses the static library) it initially says no errors, and then after a second or two the above mention error then appears.
I'm basically doing:
Create a new target in the project using the Coco Touch Static Library
Add the .m files in the targets "Compile Sources"
Adding the .h files in the targets "Copy Headers"
Adding the same set of libraries in the "Link binaries with libraries"
Go into the Profile and modified the Target to be RELEASE
Any suggestions? Am I missing a step here?
I'll have a stab at this :-) I think it might be that MyClass.h has been set to private. Thus it is not added to header directory when you create the static library. You should check to see if this is so by checking the output header directory. If the header file is missing, then it's pretty sure thats whats going on.
Secondly, why use a seperate app for testing and therefore require building a static library at all? I have several static libraries and apps which I unit test with GHUnit. I do it by simply adding a new app target and configuring it to run the GHUnit iOS app. I can then add the classes I want to test and any testing frameworks such as OCMock without having to create separate projects. Basically it sounds like your testing methodolody is perhaps more complex than necessary. :-)
So, the issue turned out to be I had "-ObjC" set in the "Other Link Flags" option, which I'd put there as at one stage trying to get things working I read this was required - Dereks advice to review the compilation log worked well here
I created an independent 'LogicTest' bundle as described in Apple's
latest and greatest instructions for iPhone projects.
I've successfully set up and debugged dependent test bundles on Mac
OS, just fine. However I have not worked with independent bundles nor
test bundles for iPhone before. The test bundle builds and executes
tests just fine, but I'd like to be able to step-through debug it
also. I feel like a custom executable pointing to otest is involved,
but I don't know the right arguments and environments variables to
pass to it.
Any help would be appreciated.
This is a repost from the xcode-users mailing list, but I got no response there.
I found this, but I haven't tried it yet:
http://www.grokkingcocoa.com/how_to_debug_iphone_unit_te.html
See also "Anyone succesful in debugging unit tests for iPhone?".
I've been trying to determine the cause of this error for days now. Tried doing simple projects by I could not get the unit tests to work? Does anyone know how to solve this problem?
Building target “ChildTests” of
project “Person” with configuration
“Debug” — (2 errors) Linking
/Users/me/Desktop/Person/build/Debug-iphonesimulator/ChildTests.octest/ChildTests(1
error) ".objc_class_name_Child",
referenced from:
literal-pointer#__OBJC#__cls_refs#Child
in ChildTests.o
symbol(s) not found
collect2: ld returned 1 exit status
...
Pardon me, I am new to iphone development.
The missing symbol is .objc_class_name_Child. I'm guessing you have a class called Child but its implementation file is not being built as part of your test target.
To fix the problem find the file (probably called Child.m) and make sure your test target is checked in the Targets tab of the file's File->Info.
Linker errors normally mean you've neglected to add a framework or static library to your project and/or neglected to add the header import for the library in question.
What unit test library/framework are you using?
If you're new to the platform, you may be causing yourself unnecessary confusion by trying to start out with unit tests. Unit testing can be very beneficial to delivering a stable final product, however, it doesn't seem to me to be a good place to start out. I would suggest you get your app working first and then add unit tests later once you're sure you're going to develop it to completion.