Can anyone help with this problem:
I have an iOS framework A (written in Swift) and be built to A.framwork.
I have an application B, which uses framework A. There is a Unit test target BTests. Now I want to generate code coverage when run BTests, which call some function in framework A. I haven't found any method to support that: the generated Coverage.profdata never contains coverage information for framework A.
Step to reproduce: as the description above.
Create an Xcode project that builds framework A (can be dynamic or static).
Create another Xcode project, which has application B, and test target BTests.
B includes A
Turn on gather code coverage.
Run unit test (BTests).
Check generated Coverage.profdata and see no coverage information for framework A.
Related
I am working on multi target ios project in objective C. Some swift classes are also there by Bridging-header. There is a Unit test target for main target as Host application. I have to do unit test for another particular target [Say, SecondaryTarget]. I have added the "Unit test target" by Edit Scheme > Test to enable unit test.
I am trying to import a existing class and do the unit test. But I am always getting reference issue [file not found] in test classes, while importing the classes.
I'm pretty sure you can't reuse the same test target against different apps. Instead, create a test target for each app. Share whatever test code you want across each test target.
I am developing an iOS framework. My question is how do I test it in a dummy app. Ideally in the same project window
Technically you have to split into two scenarios.
Your framework contains functionality only.
In that case I suggest to add a unit test target and test your framework by writing unit tests.
Your framework contains a ui component.
In that case I suggest to add an application target and name it ExampleApp or something like that. In that app you can implement a visual example.
Both scenarios are used in open source GitHub repositories.
I have a very simple framework project, MyFramework, that builds successfully. The framework defines a single, global function, myFunction.
The framework also defines 2 global variables: MyFrameworkVersionNumber and MyFrameworkVersionString (These 2 variables were created for me by Xcode)
I have a very simple application project, MyApplication. I am adding the framework to the application project by dragging and dropping the framework package (i.e. the MyFramework.framework in DerivedData that was produced by building the framework) onto the Xcode Navigator and then selecting the framework in the Embedded Binaries section of the project's General tab.
If I add code to MyApplication that references the variable MyFrameworkVersionNumber then I am able to successfully build and run MyApplication.
If I add code to MyApplication that references the function myFunction then I am not able to build MyApplication.
First Update
I suddenly remembered that Carthage does exactly what I am trying to do. So, I used Carthage to build MyFramework and Voila! - I can drag/drop the Carthage build of the framework into the application project and successfully use it. So now my inquiry has become: What does Carthage know that I do not?
Oh for heaven's sake! It turned out to be so simple. MyFramework was being built for a Generic iOS Device (arm64 architecture). MyApplication was being built for a simulator (x86_64 architecture). As soon as I matched those two up all was well. The reason that the Carthage build worked so well is that it produces a universal binary (i.e. one that contains both architectures).
I still do not understand why the MyFrameworkVersionNumber global variable was able to be accessed regardless of the architecture. But I am okay with deferring that little mystery as some arcane bit of information that will be revealed in the goodness of time (perhaps something such as that it is in a header that is structured the same for both architectures).
I need to test an iOS Framework. I do not wish to test the UI. Is there any way to test just the Framework which would be used in the main Project?
If you just plan to test logical stuff, you can create new Unittest target for framework by using XCTest.framework. It is available in Xcode 5 and above. There are also third-party unittest frameworks. Check this out http://www.raywenderlich.com/3716/unit-testing-tutorial-for-ios-xcode-4-quick-start-guide
I'm currently writing a unit test project using the version 4.6.1 (Windows Vista + Eclipse). My project is divided in 3 part:
A. Unit test application (type:CLDC application)
B. Application to be tested (type:CLDC application)
C. A library project (type: library,no .jar file imported)
The A project should reference the code present in B (and of course even in C). I would like to specify that I can run without problems the project B (referencing C). My problems start when I try to run the project A.
I performed the following operations:
changing the B project type from CLDC application to library
B references the project C
A references the project B
set all project as "Active for Blackberry"
Basically A sees the two other project as two nested libraries.
The code is built successfully,but the problem is that when a class of the C library is called by B during the execution, the following exception is thrown:
NoClassDefFoundError
No detail message
Any help would be really appreciated.
Many Thanks
A NoClassDefFoundError means that A cannot find C at runtime. The usual cause is that C failed to be deployed onto the target device (simulator or real device).
Solution 1:
For project A under Project->Properties->Java Build Path ensure C (your library project) is listed under 'Projects' and the corresponding checkbox checked on the 'Order and export' tab. This should ensure that the library is exported during the build and deployment process.
Solution 2:
In project A add a symbolic link (right click project->Build Path->Link Source) to the library C source. This will force the library's source code to be included when project A is built.