Landscape UIWebview on a Portrait only iOS app

In a portrait only app if you want to play any videos loaded from a uiwebvew in landscape all you need to do is set the supported Interface Orientations in the app summary to allow for landscape.

Apparently thats it.  I spent 4 hrs trying to figure out a way to force a rotation after the video stopped playing but I didnt need to. The video being loaded will rotate just fine.

No extra code.

 

 

Updating an Xcode project

Ran into a fun error today.  I am working on updating a iOS app for a client.  I have a project file from the old developer and while the project builds and runs fine its quite messy. Lots of unused classes and assets.  Its also an old project and rather than go and clean everything up I decided I was going to start with a new clean slate and import only the stuff I needed.

So I created a new project and set the bundle identifier to exactly the same as before. Also kept the display name identical.  It compiled fine. But when I ran it on my phone it installed the app but would crash immediately.   I would also see this error pop up.

“Could not change executable permissions on the application.”

Never seen that before and had no idea what it was.  Did some digging and thought it was just the naming of the app. Or the signing cert was wrong.  I made sure it was all the same except one thing… The .xcodeproj file was named different.  I didn’t think that would cause any issues.  But that was it.

The reason I named it different was the old project was named something generic. With a space. And it wasn’t in the bundleID. The bundle identifier was set manually.  So I named the project something new and tried setting the bundle identifier the same way.

So not only does the display name and Bundle identifier need to be the same. The project file needs to be the same also.

 

Version 2 of my Pool Calculator released

Major update to my first App.

I learned a ton with this version. Core data, iAds, UITableViewControllers, UIWebView, segues, al kinds of stuff.

What went right – 

I was able to figure out core data enough to get it to work. I used most of what was taught in the iTunes U corse from Stanford.  I am not looking forward to a new update though. I have no idea how core data works if you modify any of the tables. I guess I will figure it out soon. I don’t want to risk anyone losing all the readings they have.

I was able to add in iAds and Admob. It first checks with iAd then used Admob if iAd doesn’t fill. I ended up using a class from @theonlylars.

So far its working great for the ads. The only issue I see that I will need to fix is it sticks to the same position in the TableView. So it can potentially cover up one of the rows.  I will have to work on that next update.

What went wrong 

I added in a one time upgrade to a pro version. This allows you to add more than one location. I figured the average user would not need more than one. So they get the app for free. If they want to remove the ads then they can upgrade if they want.

This was my first time working with In App Purchase. I thought I had it all working correctly. It updated fine in the sandbox and I had all the screenshots and info ready.  What I didnt do is add the check box in my app submission saying it used IAP. So I submitted my app without it. I didnt notice until after the app was approved!  Apparently if you try to buy something that isnt there it will crash the app.

So I had to resubmit a build to add that in. Oh well. This will give me about a week to see what ad stats are without the upgrade.

I also think the design is seriously lacking. I think the next major thing I work on is the design. I really need some work on that.

I already have a huge list to do for the next update.

 

If you have a pool would you use this? What features would you like to see included?

 

Unit Testing. I just don’t get it.

I have tried and tried. I still don’t understand the use of unit tests.  I have seen a number of examples and tutorials about testing in AS3 and even more using iOS.

In every example its very simple tests so maybe I am just not seeing examples used in more complex code.

In almost every example its shown to test very basic values.   Every time I am thinking to my self  “No shit”.   Of course  “AssertTrue (5+5==10) * “.  If it didnt then we have a bigger issue with the computer.

Or things like   –   name = “bob”.   AssertTrue (name isEqualTo “frank”) *

I must be missing something. It seems like writing so much code to build mock objects and run these tests just to see “Tests Pass” pop up is a waste of time.

I am constantly checking to make sure the app or site works as I am building it. Is that the wrong way?  Do programmers sit and write 100s of lines of code and then publish and test? That just seems silly to me.

Maybe if you are working on a huge project with many team members it might be useful to know that someone else’s code works. And maybe thats where I am missing it. I have not worked on super large multi team programmer jobs. Everything I have done is either solo or with a few team members.  Some projects have been large but I always was testing along the way to make sure each method call was returning what I expected.

I am open to the idea of Unit tests. Like I said before I have tried many times to see where it would help out. I just have never seen or heard of any tutorials saying that its not worth it for small projects to do tests to make sure 1 + 1 == 2;

 

* yes I know these are not valid or even correct wording of the tests. I am using the idea of what it is to show an example.

Exception breakpoint in Xcode

One of the things that I have been getting hung up on in Xcode is the debugger. It always seems like a bunch of gibberish when an error is thrown.

I have been watching the iTunes-U videos on iOS from Stanford and just watched the video on debugging.  The instructor gave one tip, among others, that turned a light on for me.

Exception breakpoints.  Now I can catch any errors when they occur rather than at the end of the stack. Amazing.

Here is how you can add this sweet little nugget of wisdom.

First open the debug panel on the left.

Then down at the bottom click the plus sign

Now add a new Exception breakpoint.

Then set it to break on all exceptions. 

Now when any error pops up you will be taken to where that error happened rather than main.  That always drove me nuts.