Showing posts with label iPhone Related. Show all posts
Showing posts with label iPhone Related. Show all posts

Wednesday, August 12, 2009

iPhone Code Sign Error : Provisioning Profile Can't be Found!

Code sign error : Provisioning profile 'ABCD-12345-XYZ' can't be found.
If you have encountered an error that reads as above, you probably went through some frustrating time as I did. This error is a different class of error than the one I have previously posted about.

If you get an error message that reads as below, check out my previous post.
Error: Can’t run ‘XYZ’ on the device ‘Developer iPhone’ The device doesn’t have provisioning profile the application was signed with. Add the provisioning profile to this advice via the Organizer, or check the ‘Code Signing Identity’ build setting.

Now back to the main issue. How do you solve a code sign error that says provisioning profile can't be found?

After numerous tries of doing virtually everything, the simplest solution is to follow the steps below.
  1. Open up the Terminal
  2. CD into your iPhone project directory
  3. CD into YourApp.xcodeproj
  4. Edit the file project.pbxproj by using a text editor (I use vi)
  5. Search for the string PROVISIONING_PROFILE
  6. Surround the line containing PROVISIONING_PROFILE, with /* */ (comment block). You can simply erase the line, but I prefer to put it in comments.
  7. Do this for all lines containing PROVISIONING_PROFILE
  8. Save file.
This should have done it! Open your Xcode project -> build and go. And remember to take a break!


-도시

Wednesday, July 22, 2009

Zipping & Unzipping Files in iPhone

How would you zip / unzip files in your iPhone app? Well, some nice person has already implemented an objective-c class to zip and unzip. It is called "ziparchive" and you can download it from here:

http://code.google.com/p/ziparchive/


Simple to use: just call addFileToZip or UnzipFileTo.
To add this to your xcode project, import all the files then delete the files minizip.c , miniunz.c and iowin32.c & iowin32.h. Also add libz.1.2.3.dylib to frameworks. Also the top level .m file's import statements have the path included like "../..". Remove those.

Then you should be good to go.

Keep in mind though -- it can only unzip a zip format. And not all zip formats are the same.
What works for me is this --
I create a zip file using the unix command zip. This zip file can be unzipped using the ziparchive.
If you use gzip for instance, you cannot unzip it using ziparchive.


Usage of zip command in unix (on mac, open up terminal) --
zip filename_of_zip inputfile1 inputfile2 ... (or use * to say all files in directory)

alternatively,

zip -r filename directory (zips up all files inside the directory. The directory itself is not included in the zip.)

and to unzip, simply "unzip filename.zip"




-도시

Saturday, July 18, 2009

Deploying iPhone Apps on Multiple Devices

I assume you already know how to run your developed iPhone app (either in debug or release mode) on a device (iphone or ipod touch). Suppose you got a new device and want to run the app on the new device -- now what? Well, you go through the steps involved in getting a new provisioning profile and think everything should work OK. But I have gotten error messages that reads as below and have spent a lot of time trying to figure out what was wrong. The error message shows when I didn't install the provisioning profile properly and try to run the app on the device:
Error: Can’t run ‘XYZ’ on the device ‘Developer iPhone’ The device doesn’t have provisioning profile the application was signed with. Add the provisioning profile to this advice via the Organizer, or check the ‘Code Signing Identity’ build setting.

A simple google search revealed that several people have faced the same problem. But the solution was never well documented so I am providing detailed steps on what to do when you get a new device to use in your development. (or what to do when you get the same error message)


Steps to follow when you want to deploy app onto a new device:

1. Open xcode -> organizer, copy the device identifier

2. Log into iPhone developer program portal
Go to devices and add device

3. Go to provisioning
Edit the provisioning profile
Select new device under devices and submit to get a new provisioning profile

4. Download the new provisioning profile

5. Double-click the downloaded provisioning profile to install it on local machine
Most people miss this step.

6. Drag provisioning profile to organizer window for corresponding device

7. Now in xcode, highlight the top-most item (project name) and click on info button.
In the Build tab -> Code signing identity -> select the new provisioning profile


8. Now clean project by going Build -> Clean all targets
(optional step is to select Xcode -> Empty Caches)

9. Once you have verified everything is working fine, go to
~/Library/MobileDevice/Provisioning and delete the old provisioning profile. A provisioning profile filename ends with .mobileprovision.



-도시

Converting QTVR into Movie Clip

QTVR stands for QuickTime VirtualReality which is a file playable by QuickTime where you can drag and move your mouse to see the panoramic view of an image. These QTVR files are in mov format, which makes it look like a movie file but it really isn't.

I don't want the QTVR file which requires a user to drag the mouse to view the entire image. So I have searched for a way to convert the QTVR panoramas into a real playable movie clip. There are several tools out there that can do this but most are not free. The only FREE QTVR converter I have found is the QTVR recorder.

You use this tool to open a QTVR file and manually drag the mouse to interact with the panoramic image and the tool simply records it into a movie file. The problem? Well, this software doesn't run well on my Mac OS 10.5.7

By "not running well" I mean the screen just blanks out so I can't see the controls. Below is the startup screen you get when you run QTVR recorder. Everything is greyed out initially. You can see the "START" button only because I managed to click around and find its location. (When you click at the right coordinates of the start button's location, the button appears on screen.)

I have managed to use this software to successfully convert a QTVR into a MOV file so I will post the instructions to help anybody else wishing to do the same.

STEP 1: Look at the image below, notice where the START button is located, and find the button in your machine running QTVR recorder.

STEP 2: Once you have clicked START, you will see the following screen. Click open to choose the QTVR file.

Now, click on "SAVE TO ..." to specify where to save the output movie file.

STEP 3: Now the screen will be greyed out (or blanked out or blacked out) so click around using the following image as a guide to reveal the "GO" button.

STEP 4: Now you will get a full screen of the QTVR file playing and the title bar should say something like "Press the space bar to start recording". Press the space bar, move around your mouse and it will record your movement. Press the space bar again to stop recording.

NOTE: When you are moving your mouse to record the panoramic image, the movie file records in faster speed so move your mouse slowly.

Once you have stopped recording, you come to this screen. Click DONE to finish. Now you have a MOV file that plays what you recorded without the need for user interaction.




-도시

Tuesday, July 14, 2009

UIViewControllers - What's happening to memory?

So I've been using UIViewControllers in my iphone apps and when I use the Instruments application's activity monitor, I noticed that iphone's memory kept increasing when I pushed a UIViewController then pop it to come back to the main screen.

Here's the problem I found.

if (detailViewController == nil) {
detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
}
[self.navigationController pushViewController:controller animated:YES];


The above is how I pushed a UIViewController. This is used by many examples in the iphone developer's portal website.
The examples are correct ONLY if you are planning to re-use that detailViewController sometime later.
The above method of pushing a view controller will not release the view controller and stay in the memory until the app is closed.

Now, if you need to have the detailViewController release its memory, you have to push the view controller in this way.

DetailViewController* detailViewController = [[DetailViewController alloc] init];
[self.navigationController pushViewController: detailViewController animated:YES];
[detailViewController release];

You should do it this way when you need to release memory of the pushed view controller and do not want that detailViewController occupying memory for the duration of your app.

How do you know when to re-use a view controller vs when not to?
Typically, if you are using the same visual elements and only changing the data with new data, you should re-use the view controller. (ie. not release the view controller)
Otherwise, if you are changing more than just data (such as the visual elements programmatically) then you should release the view controller and push a new view controller.


Here's a snapshot of the Instruments -> activity monitor showing my app using over 10MB of memory. There is only a limited amount of memory that's available for your app to use. So you have to closely monitor how much memory you app is using and whether all allocations are deallocated properly. On one app, I have seen its real memory usage go up to 57MB before crashing. On a different app, I've seen it go up until 35MB before crashing. Once the phone has not enough memory, the app simply crashes (effectively closing the app).

And if you are playing music while running an app and the app is increasingly using up memory, I noticed that the music player closes first to make available some more memory to the app.

-도시

Wednesday, July 8, 2009

Using the Same iPhone Developer Certificate ID Under Multiple Machines

If you are an iPhone Developer and want to use the same developer certificate under multiple machines, simple follow these steps.

0. export private key from keychain from your original/primary machine
1. download p12 file into the new machine and import to your keychain as a key
2. go to iPhone developer program portal, under certificated tab, download development certificate
3. still inside the program portal, under provisioning tab, download development provisioning profile
4. double click developer_identity.cer certificate (it opens up keychain)
5. Now open xcode -> window -> organizer then under the IPHONE DEVELOPMENT tab, select "Provisioning Profiles", and drag provisioning profile into that window
6. Once you have an iPhone project in Xcode, select the top level and click on info button.
7. Under the Build tab, in Code Signing Identity select the one that says "iPhone Developer: Firstname Lastname"
8. Right underneath, for "Any iPhone OS Device" select the same one.

*If you do not see an option of "iPhone Developer: Firstname Lastname" you have done something wrong and need to start over the steps.


Installing the new iPhone SDK 3.0


-도시

iPhone Navigation Bar Title - Changing Font

Setting the title of a navigation bar title is as simple as
self.title = @"My really looooong title";

But if the title is too long as above, the title gets truncated.

Changing the font of the title to a smaller size can make the full text to appear on the title bar.
To do so, you would have to create a custom UILabel.

This is what I did -- (should go under viewDidLoad)
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
[label setFont:[UIFont boldSystemFontOfSize:12.0]];
[label setText:@"My really looooong title";
[label setTextColor:[UIColor whiteColor]];
[self.navigationController.navigationBar.topItem setTitleView:label];
[label release];

Now, there is one important item to keep in mind.
If you are pushing viewcontrollers which are using custom UILabel for its title, you cannot have the page transition animations enabled.

[self.navigationController pushViewController:view2 animated:NO];

If you have "animated:YES", the animation causes the custom UILabel to disappear.


UPDATE:
I have upgraded to iPhone OS 3.0 and trying to do the above did not give me the results I wanted. It may still work for you, but for my purposes the title was disappearing. So, in version 3.0 you should use the following code to have custom titles working properly.

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
label.font = [UIFont boldSystemFontOfSize:14.0];
label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
self.navigationItem.titleView = label;
label.text = [dataItem objectForKey:@"title"];
[label release];




-도시

Tuesday, July 7, 2009

iPhone and MacBook Pro



All pictures you see here are taken with the iPhone's built-in camera (2 mega pixels).


-도시

Wednesday, July 1, 2009

Converting mov files to m4v files

Apple iPhones and iPod Touches can only play MPEG-4 encoded video files (m4v). Other formats are not supported so you need to convert movie files to m4v files. Simply follow these steps to convert mov to m4v.

  1. Open up Itunes.
  2. Select Library -> Movies, and File->Add to Library
  3. Select the movies you want to convert (you can do multiple files at a time. Use SHIFT for continuous selection or COMMAND for discontinuous selection when selecting)
  4. Now, select all the imported movies. I use do COMMAND-A to select all. To select one by one, hold down COMMAND and select.
  5. Go to Advanced -> Create iPod or iPhone Version
  6. Wait for the conversion to complete.
  7. Now you have m4v files that are playable on your Apple iPod Touch or iPhone or Google Android phone as well.

Note: When inside Itunes and you want to see where the actual movie file is located? Simply right-click on the movie and select Show in Finder (macs only. Windows version should have something similar).


-도시