UITests Storyboard Issue - ios

I have a new proyect and I want to implement UITests, but I have the following problem when I initialize the controller...
Error
My viewController identifier is MainView, my storyboard target membership marked... This sounds simple but I donĀ“t find any solution...
Call
Thank you very much

OK...I think the problem is that the tutorial you mention (http://www.raywenderlich.com/101306/unit-testing-tutorial-mocking-objects) is meant for standard iOS unit tests, not for iOS UI tests. I am guessing that the two types of tests are set up very differently and items that work in one will not work in another...To follow this tutorial (watch out for the fact that it looks to use slightly older Swift syntax), look for the folder in your app called ApplicationNameTests, not ApplicationNameUITests and write your tests there.

Related

tabbed application instead or single view application in xcode?

I have created a project in Xcode using UIStoryboard for the whole design.
It has an UINavigationController and a bunch of UIViewControllers and I initially used the template Single View Application for my project..
Now midways of developing I have made an important adjustment, I added an UITabBarControllerto the project. It works fine.
Would it be better now to create a new project, with the Tabbed Application template?
It is just a template, right? So probably not necessary to change? Or is it adding some Apple magic to my (now tabbed) project, which I am missing out on?
No there is no need to create a new project.
As you have pointed out it is just a template.
I'm never using any of the templates anymore, just an empty app and I start from there.
If you're not having any trouble you can just go ahead with your project.
As rckoenes said, it's always better to start from a blank project and then insert libraries and code to make sure you'll not have strange errors

How to turn a project with xib into a pure code one?

I tried to turn a xib project which is downloaded from iOS Developer Library of Apple, into a pure code one for further use, but it didn't work.
I wonder what should I pay attention to when I do this kind of conversion, and I wonder it will help me improve my skill of iOS developing.
Converting the Xib file into pure code part is not a very big task, you just need to be carefully replace the items created via Interface builder by your code part. You can follow this sequence while converting such projects :-
1) Display the elements made via IB with your code.
2) Make sure the delegates and datasources to be connected via code if they were connected via IB.
3) Check for the IBActions, if any to be replaced.
4) Lastly, if you are not using ARC or the Project that is being converted not using ARC then the dealloc part or viewDidUnload method, where we generally make the objects nil and release.
Hope it helps you :)
There are some tool available. For example, http://kosmaczewski.net/projects/nib2objc/

Merge two iOS Project into one for universal build

I have different project set up for iPhone and iPAD and most of the file names in these two projects are same. Now i would like to merge these two into one and create a Universal build. Is there any tutorial or a better way to handle this without reworking on the complete code.
Please help. Thanks.
I already did that before. At that time, we did not have the choice to rename all the files and classes of one project. Objective-c does not have namespace, unfortunately.
Don't know how big is your project, but with rename/replace or re-factoring tool, you would be able to that without any (to much) pain.
If you use StoryBoard, then you can choose your project and when you choose Universal, you can set two different StoryBoards for iPhone and for iPad.
So you will have an application which initialize it according to iOS device.
And if you have same class names, I suggest you to change one of those with one character difference (eg. ViewController and PViewController (P for phone..)) and refactor all related class according to it.
Good luck!

Understand Apple's DateCell program

From here: http://developer.apple.com/library/ios/#samplecode/datecell/listings/MyTableViewController_m.html
The program runs. But I need to modify it so it will fit within my program. I can't get it to work even though I have copied verbatim. The issue is that as I click on start date, nothing happens. So as I am debugging, I'm noticing that my datePicker (in my program) is always nil. So I'm trying to figure out how apple does it, and they never initialize the datePicker. But it always has a non-nil value.
Where is apple allocing and initializing datePicker?
Also, I'm trying not to use storyboards, which Apple's program uses. (Though when I import the storyboard it doesn't help.)
First of all there's a button "Download source code". It contains working project.
Version 1.2, 2013-01-04: Upgraded for iOS 6.0, now using Automatic
Reference Counting (ARC) and storyboards, updated to adopt current
best practices for Objective-C.
This "about" info tells us you have to use deployment target 6.0 as the project uses storyboards with autolayouts, and you have to set "Automatic Reference Counting" to YES in your project properties.
All other guesses can be made only if you give us an error that you get.
P.S: I have downloaded the project and it works fine.

How to Test an iOS Library Which Is Using UIKit

I would like to create a library for iOS applications which uses UIKit. Furthermore I would like to create unit tests for this library. Unfortunately my tests do not work because of UIKit ([UIFont systemFontOfSize:12.0] to be precise).
According to Apple's Unit Testing Guide there are two types of test cases: logic tests and application tests. Application tests seem to be the correct type for tests involving UIKit related stuff but I did not find out about how to set up application tests for libraries. Has anybody ever had the same problem and was able to solve it?
Thanks a lot!
I found a solution to this. You must add a new target to your project that is simply an empty application. Then use that application as your test host following the instructions for doing this with a regular application like here:
Why does instantiating a UIFont in an iphone unit test cause a crash?

Resources