xcode interview questions
Top xcode frequently asked interview questions
I began an iPhone project the other day with a silly development code name, and now I want to change the name of the project since its nearly finished.
But I'm not sure how to do this with Xcode, trying the obvious of changing the application's name in the pinfo, causes the signing process to go wrong (I think...) and my app won't launch giving me a Launcher error.
I guess I could make a new project and copy paste everything over, but it seems so primitive, that I'm hoping for a more civilized solution.
Source: (StackOverflow)
How do I get the command line builds tools installed with Xcode 4.4 / Mac OS X v10.8 (Mountain Lion) or later?
Unlike Xcode 4.3 there is no installer (it's just a bundle).
It looks like all the command line tools are there (in the bundle, under Contents/Developer), but none of the appropriate environment variables set to use them.
Is there a script somewhere I can run that will setup my environment to support building from the command line?
Source: (StackOverflow)
I am using ARC successfully in my project. However, I have encountered a few files (e.g., in unit tests and mock objects) where the rules of ARC are a little more fragile right now. I recall hearing that there was a way to disable ARC on a per-file basis, though I have been unable to find this option.
Is this possible? How do I disable ARC on a per-file basis?
Source: (StackOverflow)
I can't find the good old "Add existing frameworks" option. How do I do this?
We're talking about Xcode 4 DP2 (in the context of iPhone development, as far as it matters...).
Source: (StackOverflow)
In Xcode 3, the line number of the current cursor location was displayed. I don't see this in Xcode 4. Is there a setting that will turn it on? Or a keypress that will give it to me?
Source: (StackOverflow)
When I select multiple lines of code and want to indent them as usual with TAB key, it just deletes them all. I come from Eclipse where I always did it that way. How's that done in Xcode? I hope not line by line ;)
Source: (StackOverflow)
I'm doing a presentation on debugging in Xcode and would like to get more information on using NSLog efficiently.
In particular, I have two questions:
- is there a way to easily NSLog the current method's name / line number?
- is there a way to "disable" all NSLogs easily before compiling for release code?
Source: (StackOverflow)
I have an app that I developed with XCode 3 and recently started editing with XCode 4. In the target summary I have the iOS application target form with fields: identifier, version, build, devices, and deployment target. The version field is blank and the build field is 3.4.0 (which matches the version of the app from when I was still editing with XCode 3).
My questions are:
What is the difference between the version and build fields?
Why was the version field blank after I upgraded to XCode 4?
Thanks.
Source: (StackOverflow)
I have many annotations in a mapview (with rightCalloutAccessory
buttons). The button will perform a segue from this mapview
to a tableview
. I want to pass the tableview
a different object (that holds data) depending on which callout button was clicked.
For example: (totally made up)
- annotation1 (Austin) -> pass data obj 1 (relevant to Austin)
- annotation2 (Dallas) -> pass data obj 2 (relevant to Dallas)
- annotation3 (Houston) -> pass data obj 3 and so on... (you get the
idea)
I am able to detect which callout button was clicked.
I'm using prepareForSegue
: to pass the data obj to the destination ViewController
. Since I cannot make this call take an extra argument for the data obj I require, what are some elegant ways to achieve the same effect (dynamic data obj)?
Any tip would be appreciated.
Source: (StackOverflow)
I'm pulling my hair out over this. I just downloaded the iPhone 3.0 SDK
, but now I can't get my provisioning profiles to work. Here is what I have tried:
- Delete all provisioning profiles
- Delete login keychain
- Create new "login" keychain, make it
default
- Create a new certificate signing request
- Create new developer and distribution
certificates in the Apple developer center
- Download and install them
- Download the WWDR certificate and install it
- Create a new provisioning profile and
double click it to install
All the certificates report as valid, but Xcode
still won't recognize them. What should I try next?
Edit:
I completely re-installed Mac OS X
and from a fresh install installed the 3.0 SDK
and still have the same problem.
Source: (StackOverflow)
When converting a project to use ARC what does "switch case is in protected scope" mean?
I am converting a project to use ARC, using Xcode 4 Edit -> Refactor -> Convert to Objective-C ARC...
One of the errors I get is "switch case is in protected scope" on "some" of the switches in a switch case.
Edit,
Here is the code:
the ERROR is marked on the "default" case:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"";
UITableViewCell *cell ;
switch (tableView.tag) {
case 1:
CellIdentifier = @"CellAuthor";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefQueries objectAtIndex:[indexPath row]] valueForKey:@"queryString"];
break;
case 2:
CellIdentifier = @"CellJournal";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"name"];
NSData * icon = [[prefJournals objectAtIndex:[indexPath row]] valueForKey:@"icon"];
if (!icon) {
icon = UIImagePNGRepresentation([UIImage imageNamed:@"blank72"]);
}
cell.imageView.image = [UIImage imageWithData:icon];
break;
default:
CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
break;
}
return cell;
}
Source: (StackOverflow)
Xcode 3.2 provides an awesome new feature under the Build menu, "Build and Archive" which generates an .ipa file suitable for Ad Hoc distribution. You can also open the Organizer, go to "Archived Applications," and "Submit Application to iTunesConnect."
Is there a way to use "Build and Archive" from the command line (as part of a build script)? I'd assume that xcodebuild
would be involved somehow, but the man
page doesn't seem to say anything about this.
UPDATE Michael Grinich requested clarification; here's what exactly you can't do with command-line builds, features you can ONLY do with Xcode's Organizer after you "Build and Archive."
- You can click "Share Application..." to share your IPA with beta testers. As Guillaume points out below, due to some Xcode magic, this IPA file does not require a separately distributed .mobileprovision file that beta testers need to install; that's magical. No command-line script can do it. For example, Arrix's script (submitted May 1) does not meet that requirement.
- More importantly, after you've beta tested a build, you can click "Submit Application to iTunes Connect" to submit that EXACT same build to Apple, the very binary you tested, without rebuilding it. That's impossible from the command line, because signing the app is part of the build process; you can sign bits for Ad Hoc beta testing OR you can sign them for submission to the App Store, but not both. No IPA built on the command-line can be beta tested on phones and then submitted directly to Apple.
I'd love for someone to come along and prove me wrong: both of these features work great in the Xcode GUI and cannot be replicated from the command line.
Source: (StackOverflow)
When I'm building my Xcode 4 apps I'm getting this warning:
ld: warning: directory not found for option '-L/Users/frenck/Downloads/apz/../../../Downloads/Google Analytics SDK/Library'
ld: warning: directory not found for option '-L/Users/frenck/Downloads/apz/../Google Analytics SDK/Library'
But I do not have Google Analytics in my app, I deleted all of it how can I remove the error?
And archiving an app gives me the error:
clang: error: no such file or directory: 'armv6'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
I've tried so many things but I'm still getting this error when I'm trying to make an .IPA file
Source: (StackOverflow)
It's been a while since I've had to adjust project build settings. After upgrading to a recent SDK I'm having trouble building my ad hoc distribution configuration.
Build generates this warning and error:
warning: iPhone apps should include an armv6 architecture (current
ARCHS = "armv7")
iPhone/iPod Touch: application executable is missing a required
architecture. At least one of the following architecture(s) must be
present: armv6 (-19033)
However in my project I thought I had things set correctly:
- Architectures is: Standard (armv6 armv7)
- Base SDK: Latest iOS (currently set to iOS 4.2)
- Valid Architectures: armv6 armv7
I have cleaned all targets.
I appreciate any tips.
Source: (StackOverflow)