I am creating a statistical calculator app. It has various functions.
I am creating the functions in a cocoapod framework.
How can we test or debug a library framework while we develop it? That means every time without copying it to the demo/test project.
In your framework project, in Xcode add a target for testing. Press File > New > Target... > iOS Unit Testing Bundle.
This will create a test target for you. You can run this target at any time. Also, a swift file with a subclass of XCTestCase. This class has all functions necessary for testing, such as setUp(), testExample() or testPerformanceExample(). You can read how to use this in the XCTest framework reference.
Related
I'm testing creating framework.
So, I made the test framework first.
And in another project, I imported the framework but I can't access the MyClass I made.
What's the problem? I don't know weather if can't access the class or framework doesn't have the class I made.
I'm struggling with this problem about two days.
Help me please.
Got the issue.PFB the explanation.
You have built the framework against 'Generic iOS device'.
You are trying to use against simulator which requires x86_64 architecture.
This is the reason which your iOS framework classes are not getting recognized in your view controller. Since your framework is built only for iOS devices.
Solution to your Question:
Change your build target device to 'Generic iOS device' and just build it and you can't run.
Generic Solution:
Try the tutorials for building universal framework where you will add 'Run Script phase' to create binary slices for all architectures(32-bit, 64-bit devices and simulators).
Output:
I have created a iOS framework and want to use that framework in one of my application.
My question is about the UnitTesting of the framework.
I have read about the inbuilt xcode unittest framework, but not sure how to get started on testing the framework.
Or do I have to import the framework in one of my apps and then perform the testing of the framework via
Regards,
Nirav
Add a new target to your project, select Others -> Cocoa Touch Unit Testing Bundle, give it a name.
Add to the new target the Compile Sources and the Link Binary. And in your test class write the tests you need.
I have a bunch of code in an iOS project (named "MyLibs") I re-use across different apps. I drag the MyLibs project into the workspace of whatever app I'm creating. I don't use unit tests per se, but I have buttons than run through all the tests very easily in the iPhone app.
I'm learning Cocoa and would like to divide up my library into libs I can use on both projects. I was thinking it would be MyCommonLibs (or MyFoundationLibs), MyIOSLibs and MyCocoaLibs.
However, when creating a new project, I must choose between an iOS app or a Cocoa app. It looks as though the iOS Framework and Library -> Cocoa Touch Static Library is appropriate because it links against the Foundation framework. On the other hand, I'd prefer to use an application template if there is no major drawbacks to it.
I need to be able to use MyCommonLibs in both app types, as some of them are useful to both, such as NSArray categories, etc.
Which template should I use for the MyCommonLibs and must I use a Library, Framework (in the Mac OS templates) or can I just use a normal application template (as I've been doing thus far)?
Create an iOS Framework & Library project. Let's call it TestLib.
Add a new target (File > New > Target) of type MAC OS X Framework & Library.
This way, you can compile both an iOS library and a MAC OS X library from the same project.
You can choose which files are included in each target. So if you want to make a class available for both iOS and MAC OS X, you add it to both, and if you want to make it available for only one platform, you can add it to only one lib.
As you can see in the screenshots below, SharedClass is available in both libs, iOSOnlyClass is available for iOS only and MACOnlyClass is available for MAC OS X only.
You can also add targets for unit tests in the same project.
To organize your code, you can put the shared classes in a group, and the classes of each target in a separate group.
I have my drupal xml-rpc service setup, and now I want to retrieve content for my iphone app.
I'm attempting to use https://github.com/eczarny/xmlrpc, however I dont know where to begin. How do I add the project to my own project for use? I've added a static library before; is it the same process? Just drag the proj file to my project and add the xml-rpc library?
Any tips would be appreciated.
Try dragging the project file for xmlrpc framework into the code list in XCode for starters. Next make the framework target in the xmlrpc framework a build dependency. Finally add the xmlrpc.framework to your linked frameworks. Exactly how you do this depends on whether you are using XCode 3 or 4
What is the best way to reuse code within projects?
Let's say I implemented a UI Element and I want it to be used in both my iphone and ipad application without having to copy the code over and have 2 copies of it.
Just create a project, which includes all your shared code in XCode and reference this project in your iPhone and iPad application project. Plain and simple.
For me I would make a static library project which contains the shared code (UI Element in your example) in Xcode.
Then when I need to use the library in the iPhone or iPad app project, then I can just reference the static library project by drag and drop the project to the Project Navigator and configure the correct dependency, library used and header search path. In this way you always have a single source of library source code for easier maintenance and modification.
Certainly you can actually compile the static library into binary and link it to your project, but it just not too flexible when you find bugs in your static library and need to switch to another project to correct the bug, and then do the compile and copy of the binary library file.
I have just wrote an article (link below) on how to link up the static library project to an iOS project on Xcode 4.3.2. This maybe useful for you to solve the header not found problem you encountered. Hope this help.
http://vicidi.wordpress.com/2012/04/11/linking-an-ios-static-library-project-in-another-project-in-xcode-4-3-2/