Showing posts with label iPhone iPad App. Show all posts
Showing posts with label iPhone iPad App. Show all posts

Friday, February 25, 2011

How to run app on iPhone/iPad with provisioning file

Source: http://www.evontech.com/login/topic/833.html


A Provisioning Profile is a collection of digital entities that uniquely ties developers and devices to an authorized iPhone Development Team and enables a device to be used for testing. A Development Provisioning Profile must be installed on each device on which you wish to run your application code. Each Development Provisioning Profile will contain a set of iPhone Development Certificates, Unique Device Identifiers and an App ID.

Devices specified within the provisioning profile can be used for testing only by those individuals whose iPhone Development Certificates are included in the profile. A single device can contain multiple provisioning profiles.
Creating a Development Provisioning Profile
Installing a Development Provisioning Profile
All Team Agents, Admins and Members can download a Development Provisioning Profile from the ‘Provisioning’ section of the Portal after it has been created. Only those developers whose Apple device IDs and iPhone Development Certificates are included in the provisioning profile will be able to install and test their application on their device.
  1. In the ‘Provisioning’ section of the Program Portal, click the download button next to the desired provisioning profile..
  2. Drag the downloaded file onto the Xcode application icon in the dock or into the ‘Organizer’ window within Xcode. This will automatically copy the .mobileprovision file to the proper directory. Alternatively, you can drag the .mobileprovision file onto the iTunes icon in the dock or copy the file to ‘~/Library/MobileDevice/Provisioning Profiles’. If the directory does not exist you will need to create it. Click on the ‘+’ button in the Provisioning section of the Organizer window to install your .mobileprovision file.
  3. Now that you have an approved iPhone Development Certificate, an assigned Apple device and a properly installed Development Provisioning Profile, Xcode can now build your application and install it on your development device. If you have a single iPhone Development Certificate and iPhone Development Provisioning Profile, you don’t need to change any settings in Xcode to start running your applications. To compile and install your code:
  4. Launch Xcode and open your project.
  5. 1n the Project Window, select ‘Device - iPhone OS’ from the ‘Device | Debug’ drop down menu in the upper-left hand corner.
  6.  Highlight the project Target and select the ‘Info’ icon from the top menu bar.
  7. In the Target Info window, navigate to the ‘Build’ pane. Click the ‘Any iPhone OS Device’ pop-up menu below the ‘Code Signing Identity’ field and select the iPhone Development Certificate/Provisioning Profile pair you wish to sign and install your code with. Your iPhone Development certificate will be in bold with the Provisioning Profile associated with it in grey above. In the example below, ‘iPhone Developer: Team Leader’ is the Development Certificate and ‘My First Development Provisioning Profile’ is the .mobileprovision file paired with it.
  8. Note: If the private key for your iPhone Development certificate is missing, or if your iPhone Development certificate is not included in a provisioning profile, you will be unable to select the iPhone Development Certificate/Provisioning Profile pair and you will see the following. Re-installing the private key or downloading a provisioning profile with your iPhone Development certificate included in it will correct this.
  9. In the Properties Pane of the Target Info window, enter the Bundle Identifier portion of your App ID. If you have used an explicit App ID you must enter the Bundle Identifier portion of the App ID in the Identifier field. For example enter com.domainname.applicationname if your App ID is A1B2C3D4E5.com.domainname.applicationname. If you have used a wildcard asterisk character in your App ID, replace the asterisk with whatever string you choose.
  10. Here are example App IDs and what should be input into the Identifier field in Xcode.
    • Example App ID: A1B2C3D4E5.com..domainname.applicationname
      Identifier to enter in Xcode: com.domainname.applicationname
    • Example App ID: A1B2C3D4E5.com.domainname.*
      Identifier to enter in Xcode: com.domainname.<name_of_
      application_or_suite>
    • Example App ID: A1B2C3D4E5.*
      Identifier to enter in Xcode: <full_reverse_dns_university_
      and_application_or_suite_name>
  11. Click ‘Build and Go’ to install the application on your Apple device.

Thursday, February 3, 2011

Xcode — Rename Project and Application, Change Copyright and Version Number

fter reading the first 6 chapters in Aarons book, I couldn’t wait any longer and had to start writing my own program. I will share a first taste of it here soon. One key problem I soon faced was how to manage multiple versions, i.e., how to save old versions of my program when making major changes. Xcode has no rename functionality, and since an Xcode project comprises many files, the answer is not straightforward. A related problem is that I first started to call my Cocoa Application project by appending the version number. The problem with that is that the Cocoa application by default has the same name and that was awkward. For instance, my current project, a fractal generator, is called “FracGen 0p3″, but I wanted the application to be called only “FracGen” and have the version number appear when selecting the “About” menu item.
To rename an Xcode 2.5 project, do the following:
  1. Close the project in Xcode
  2. Duplicate the project directory in the Finder by pressing Command-D.
  3. Rename the folder
  4. Open the folder and rename the “.xcodeproject” file
  5. Delete the “Build” sub folder, if there is one
  6. Open the renamed .xcodeproject file
  7. On the left in the “Groups&Files” list, expand the “Targets” group, double click on the target that still has your old project filename. Rename it under the “General”-tab in the window that opens.
  8. Select “Clean all targets” from the “Build” menu, keep the boxes checked, and click “Clean”.
  9. Build and run your project.
Now about the second problem:
  1. In Xcode, on the left in the “Groups&Files” list, expand the “Resources” group, and click on “Info.plist”. In the editor on the right you’ll see a lot of entries of this plist file.
  2. Go down to the “CFBundleVersion”-entry and enter your version number, e.g., “0.3″
  3. Next, on the left select “InfoPlist.strings”. In the editor on the right, you’ll see an entry for “NSHumanReadableCopyright”. Enter your information between the quotes, e.g., “(c) Toby Junker, 2008″
  4. Finally, double-click your target (the one you renamed above), select the “Build”-tab in the window that opens, and scroll down until you find “Product Name”. This will have the original name of your “Xcode Project” (before you renamed it). Choose a name w/o version number, e.g., “FracGen”. You will not have to change this again.
These steps sound rather daunting, but are actually very quick to do. I have not yet switched to Leopard, so I don’t know if they work in Xcode 3.0, of if Xcode 3.0 finally has a rename function. The steps given to rename a project have to be executed every time you want to create a new version of your project. The application name and copyright info has to be changed only once. if you want the version to show up correctly in the application’s “About” box, you’ll have to change the plist as explained above.

Source: http://drjunker.org/2008/04/10/xcode-rename-project-and-application-change-copyright-and-version-number/

Friday, November 12, 2010

Tutorial: Drawing a Grid in a iPhone UITableView – Tabular Cell Data




UITableView is probably the most used view on the iPhone. It’s flexible and the UI is ideally suited to use on the iPhone. There are lots of examples on how to add multiple items to a UITableViewCell. However, I needed to present some data in a more traditional spreadsheet style grid. The results worked well and enabled me to pack a lot of information on the screen that was very hard to follow without the vertical grid. I’ll show a very simplified version here you can use to add vertical lines to your UITableView.
First we need to create a subclass of UITableViewCell. This is so we can override drawrect and draw our lines and to add an array to hold a list of positions where we’ll draw the lines.

@interface MyTableCell : UITableViewCell {
 NSMutableArray *columns;
}
- (void)addColumn:(CGFloat)position;
@end
 
In this simplified example we’ll leave the positioning of the actual text in the cells in the UITableViewController and place it manually (full source code is attached at the end). We’re just providing a mechanism for drawing vertical lines to make a grid. Column locations are added by calling addColumn:
- (void)addColumn:(CGFloat)position {
 [columns addObject:[NSNumber numberWithFloat:position]];
}
Now lets override drawRect. In it we grab the current graphics context and set the line color and width. Then we iterate over our columns array drawing a line from the top of the cell row to the bottom at each position stored in the array.
 
 
 
 
 - (void)drawRect:(CGRect)rect {
 CGContextRef ctx = UIGraphicsGetCurrentContext();
 // Use the same color and width as the default cell separator for now
 CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0);
 CGContextSetLineWidth(ctx, 0.25);

 for (int i = 0; i &lt; [columns count]; i++) {
  CGFloat f = [((NSNumber*) [columns objectAtIndex:i]) floatValue];
  CGContextMoveToPoint(ctx, f, 0);
  CGContextAddLineToPoint(ctx, f, self.bounds.size.height);
 }

 CGContextStrokePath(ctx);

 [super drawRect:rect];
}
 
To add columns to the view just call
[cell addColumn:50];
when you’re building each cell.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

 NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row];

 MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];

 if (cell == nil) {
  cell = [[[MyTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];

  UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 30.0,
                 tableView.rowHeight)] autorelease];
  [cell addColumn:50];
  label.tag = LABEL_TAG;
  label.font = [UIFont systemFontOfSize:12.0];
  label.text = [NSString stringWithFormat:@"%d", indexPath.row];
  label.textAlignment = UITextAlignmentRight;
  label.textColor = [UIColor blueColor];
  label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
  UIViewAutoresizingFlexibleHeight;
  [cell.contentView addSubview:label]; 

  label =  [[[UILabel alloc] initWithFrame:CGRectMake(60.0, 0, 30.0,
               tableView.rowHeight)] autorelease];
  [cell addColumn:120];
  label.tag = VALUE_TAG;
  label.font = [UIFont systemFontOfSize:12.0];
  // add some silly value
  label.text = [NSString stringWithFormat:@"%d", indexPath.row * 4];
  label.textAlignment = UITextAlignmentRight;
  label.textColor = [UIColor blueColor];
  label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin |
  UIViewAutoresizingFlexibleHeight;
  [cell.contentView addSubview:label];
 }

 return cell;
}
That’s it. Being a bit dense I beat my head on my desk a few days before it become obvious how blindingly simple it really was. A lot was just learning ObjectiveC and how UIKit works in general. I’m now working on a GridTableView library that will add a good bit of functionality and ease of use. I’ll post it here.
Here’s the source code.