Helping Geeks Win the War on Technology Since 2010

Fix “Boot Camp x64 is unsupported on this computer model” Error

December 7, 2012

Bootcamp is unsupported on this computer model error

A blog post ago I talked about how to get your hands on the Boot Camp drivers for Windows without having access to a Mac OS DVD. This post starts from where that one left off. I’ve separated the two as they each solve different problems.

To refresh yourself, go ahead and read through it first if you had a similar issue.

Now at this point, I double clicked the setup.exe file and encountered this error: Boot Camp x64 is unsupported on this computer model. I call BS! I had encountered this very same error the last time I did this and of course I had forgotten how to overcome it.

To make matters worse, I was still waiting for the Boot Camp drivers to install and without an external mouse I had no right click button.

You see, what you need to do is browse to the Drivers/Apple/BootCampx64.msi file and right click, Run as Administrator it to bypass the error. Since I had no right click, you can instead click on Start, then type “cmd”. Instead of typing “Enter” to run it, instead press “Control-Shift-Enter” to run it as the Administrator. Then browse to your folder where the BootCampx64.msi file is in the terminal and type the file name to run it.

That did the trick for me!

Install Boot Camp Drivers without Mac OS DVD Disc

December 6, 2012

Today I had to go through the trouble (again) to Boot Camp another Apple machine and (again) I encountered a very familiar error when attempting to install Boot Camp drivers. Wait, hold on. Let me back up a bit.

I recently had to go through the trouble of installing Boot Camp on my Macbook but as I never received a copy of the Snow Leopard installation DVD, I had to make do with a USB bootable version.

However, since the USB is bootable for installation on a Mac computer, that means your Windows Boot Camp partition will be unable to read the USB. As it happened to me, Windows asked me if I wanted to format it when I inserted the USB drive into the laptop!

So I needed to procure the Boot Camp drivers that Apple provides on the DVD, but without the DVD. I stumbled upon a few links where I could actually download those files directly from Apple. Based on the type of computer you have, be sure to download the correct link. Also be sure to do this in Mac OS as it downloads a pkg file which Windows won’t be able to read.

Model Identifier Direct Download Link
MacBookAir4,1
MacBookAir4,2
Macmini5,1
Macmini5,2
Macmini5,3
http://swcdn.apple.com/content/downloads/32/33/041-2303/W5jKtsQhhMgMXs3TKhPDqLXrpXyY2HdXMN/BootCampESD.pkg
MacBook2,1
MacBook3,1
MacBook4,1
MacBook5,1
MacBook5,2
MacBook5,3
MacBook6,1
MacBook7,1
MacBookAir1,1
MacBookAir2,1
MacBookAir3,1
MacBookAir3,2
MacBookPro2,1
MacBookPro2,2
MacBookPro3,1
MacBookPro4,1
MacBookPro5,1
MacBookPro5,2
MacBookPro5,3
MacBookPro5,4
MacBookPro5,5
MacBookPro6,1
MacBookPro6,2
MacBookPro7,1
MacBookPro8,1
MacBookPro8,2
MacBookPro8,3
MacPro1,1
MacPro2,1
MacPro3,1
MacPro4,1
MacPro5,1
Macmini2,1
Macmini3,1
Macmini4,1
iMac5,1
iMac6,1
iMac7,1
iMac8,1
iMac9,1
iMac10,1
iMac11,1
iMac11,2
iMac11,3
iMac12,1
iMac12,2
http://swcdn.apple.com/content/downloads/33/54/041-2011/pRtCDYcWShMLxFggy3TzFzmfnnWQNFQBfJ/BootCampESD.pkg
MacBookPro9,1
MacBookPro9,2
http://swcdn.apple.com/content/downloads/11/05/041-0925/g27es04pw9re5ggrfp3vuf8ew6r53asfz8/BootCampESD.pkg
MacBookPro10,1
MacBookAir5,1
MacBookAir5,2
http://swcdn.apple.com/content/downloads/55/51/041-3891/se4uhpqng48t842cdsosqh28lft54fmswl/BootCampESD.pkg
iMac13,1 http://swcdn.apple.com/content/downloads/18/26/041-6771/sp1lsdwztgihftf6utfx32jjl633tr7ox8/BootCampESD.pkg
Macmini6,1
Macmini6,2
MacBookPro10,2
http://swcdn.apple.com/content/downloads/34/23/041-3688/j3xfcx540z2bgx4iptkdhvj83rbz0s97io/BootCampESD.pkg
iMac13,2 http://swcdn.apple.com/content/downloads/25/23/041-6932/ezgnx0guny5bw6vm7to92ilew38ptli0z5/BootCampESD.pkg

To get your model number click on the Apple icon in the task bar in the upper left corner. Then select “About This Mac”. Then click “More Info” and “System Report” (this is for Mountain Lion, others should be similar). Then in the hardware tab you should be able to see something like the model numbers you see above. Download the proper one as it contains the correct Windows drivers for your particular Apple hardware.

Once the download completes, open and install the BootCampESD.pkg. When the installer completes, copy the files over to a USB stick and boot into your Windows. Those files will be familiar .exes and such and will be readable by Windows.

Xcode “error: Codesign check fails” and “resource missing:” Fix

November 28, 2012

This error stumped me for the longest time and all the answers on stackoverflow were pretty much useless in getting it to work. I had an iOS app that was compiling fine for the first release into the App Store. After I made a few changes (and tested it to work in the simulator), I could not for the life of me get it to archive in Xcode so I could release an update for the app.

The errors I got were cryptic sounding: “Codesign check fails” and “resource missing.” The full error was:

error: Codesign check fails : /var/folders/.../App/myapp.app: a sealed resource is missing or invalid
In architecture: armv6
resource added: /private/var/folders/.../App/myapp.app/www/Icon
resource missing: /private/var/folders/.../App/myapp.app/www/Icon

If these sound familiar to you then let me ask you one thing: are your files stored on your Dropbox folder???

If so then you may be the victim of a phantom hidden Dropbox file called “Icon” which gets created by Dropbox. This file isn’t a normal one and you can’t delete it from Finder because it’s hidden. You can see it in Terminal with a simple list command but you won’t be able to remove it. It appears as “Icon?” in the Terminal.

You may notice this file appearing in your Xcode project as a tiny file called “Icon” that doesn’t quite line up with the other files in the folder. Its file name appears mis-indented, a half line up from where it should be.

So what do you do? You have to delete it from your Xcode project. You should also delete it from your folder files. The “resource missing” error should indicate where this icon file is located. When you have determined the folder where it’s at, launch Terminal and browse to that folder. Then execute:

rm $'Icon/r'

To delete it. After this is done you can re-import the folder back to your Xcode project and try to archive it again. This solution worked for me and I was able to archive my iOS project without any problems and submit it to Apple.

Xcode Command to Auto Indent Code

October 2, 2012

Xcode does a good job of keeping up with you as you program in terms of indentation. Its “smart indent” feature works for most of the time but sometimes it just can’t keep up with you if your own formatting gets out of whack.

Fortunately, there is an Xcode command to autoindent your code. Select the portion of code you wish to format, then hit Control-I. No, not Command-I, but Control-I.

I had some issues trying to find this originally somewhere in the Edit->Format menu seeing that it did not exist. Right clicking on the code revealed nothing I could do either. Somehow I stumbled into the Editor->Structure window once or twice where it was hidden but kept forgetting about it and going back to the Edit menu. After repeating this far too many times, I just wrote down keystroke combination on a post-it note until it stuck with me.

Now it’s here in case I ever forget it again, hope this saves you some time.

Accessing Next View Controller from Segue Function

October 1, 2012

This helpful little piece of code should allow you direct access to the next sequential view controller as defined in the current view controller’s segue handling function. This enables you to pass data between two view controllers, like the user’s information, so the next view can use it.

Apple documentation calls the next view the “destination” view controller and you can simply use the storyboard segue object to access the view where the segue goes.

This should be done in the prepareForSegue function where you will get a pointer to the UIStoryboardSegue object.

- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"ButtonClicked"])
    {
        NextViewController *nextViewController = [segue destinationViewController];
        nextViewController.username = self.username;
    }
}

This code defines the handling behavior for a segue identified as “ButtonClicked” in the storyboard editor.

To create a segue between two views, simply control-click a button to the view it should go to. Once that segue is created, give it a unique name in the “Identifier” field. In this example the identifier is “ButtonClicked”.

After the segue is created, you need to handle it in the current view’s implementation. That is a matter of simply overriding the default prepareForSegue function.

Just paste the sample code function into your master view’s .m code.

Clearing Cached Images in Xcode Build Folder

September 27, 2012

This problem confounded me for the longest time: I had replaced a few images to the resources folder in my project but when I ran my app in the Xcode iPhone simulator, the images continued to be the old ones, even though I triple checked and made sure they were up to date in the .xcproj folder.

As I suspected, the app’s local resource folder was not being updated when I manually checked it in the Mac OS file system at ~/Library/Developer/Xcode/DerivedData. Deleting the contents of this folder will clear any cached images and possibly any other files you have previously used.

I also looked up a shortcut to do this without resorting to Finder or the terminal from Xcode itself. You can also clear the local build folder with the Command-Option-Shift-K command. You will get a prompt confirming if you wish to delete the build folder for your application so hit “Clean” to execute.

WordPress Auto-Add Paragraphs to Double Spaced Text

September 20, 2012

I’ve had to look this one up twice now when doing WordPress theme-ing so that’s usually when I know I have to get this down on my blog so I can look it up easily. Hopefully by writing this post out for everyone I’ll just commit this WordPress function to memory.

If you are familiar with the HTML editor mode in WordPress when you create a post, you might have noticed that when you double space your text in the editor, it shows up as separate HTML paragraphs on the post complete with

markup. That’s because WordPress will automatically format your text paragraphs this way as a built in functionality.

I love it because I nearly always use the HTML editor since it affords me precise control over how the content looks. And who wants to spend all their time typing

when you simply need to hit the return key twice?

I was hoping to find a function for this useful formatting functionality in WordPress somewhere and luckily such a thing exists. The function is called wpautop(). You can call it any time you want paragraphs to be auto-added to text. Simply echo the output or save it to another string.

Using Custom Fonts in Xcode 4.2 iPhone Apps

September 18, 2012

The default Apple fonts are fine and all but sometimes you just want the pizzazz of using your own custom font in your iPhone app. This helps give your app a bit of character whether it is used as the font on a title menu text or just a simple label.

I stumbled upon a few tutorials on how to achieve this but they were pretty dated and were definitely not written for Xcode 4. Fortunately, the steps aren’t terribly different. I’ve put together a combination of sources to get a complete and working solution that anyone can follow.

I’ll assume that you already have a font you wish to use in mind. Let’s use it “Market_Deco.ttf” in our example (by the way it’s a beautiful vintage font). What you’ll need to do is drag it over to your resources folder in your Xcode project and make sure it gets copied to your application’s directory.

Now you need to tell your app that this exists. That means editing the automatically MyAppName-Info.plist generated file. This property list has a few of your projects settings already in there, that’s how you know its the right one.

Add a new entry by control-clicking (right clicking) on the .plist and selecting “Add row.” Type “UIAppFont” as the key. Xcode 4.2 will automatically know that this is an array so you won’t have to set its type. In fact its name will change to “Fonts provided by application.”

Add the file name of the font you wish to add to your iPhone app. This should be the first value of the font array at index 0. I would type “Market_Deco.ttf” into the “Value” column. Do this for any other fonts you are also using.

adding-font-to-plist

Before you can use the font in your app, you will need to determine the system name of the font. To do that, you simply open up your font in Font Book. Do this by double clicking on the font file in Finder, not from Xcode. You will note a name that appears in the menu. Note that this could be totally different from your font file name. In this example, the Font Book name is “Market Deco” which is a good example as this could totally be the case for multi-word fonts. Jot it down or just remember it. You’ll need to use this when you actually set the font of a UITextView of UILabelView. Make note of proper caps (I didn’t test this but followed capitalization precisely to be safe).

font-book

For the TextView or LabelView whose font you wish to change, call it “mylabel”, simply use this line of code:

self.mylabel.font = [UIFont fontWithName:@"Market Deco" size:24];

Again, make a note that the string you use here to reference the font is not necessarily always the file name of the font. The only way to see the system name is by opening it up in Font Book.

Though using your own custom font for iPhone apps is still mostly the same process, you can see how easy it is to get lost in all the updates since before Xcode 4.2 without someone pointing it exactly out to you. Hope this saved some people some time from figuring it out themselves from all the old tutorials out there.

Saving Persistent Data in Xcode iOS Apps

September 14, 2012

Figuring out how to store data persistently in my iOS app took me all damn day but I did it! Between multiple example implementations of saving iOS app data, I finally managed to piece together a comprehensive example template you can use in Xcode. This implementation, in my opinion, is a little bit more clear and intuitive though all credit goes to my references for the starting point.

The sample implementations I am talking about are here, here, and here, saved for posterity and my own future reference in case things go FUBAR with my implementation.

Where to begin… let’s start with a general synopsis: this implementation uses only one of many ways to save your application’s data. It’s one of the simpler methods and utilizes something called Property Lists, a standard in Apple programming. It’s good for storing anything basic to moderate and can even store data types such as NSArray and NSDictionary. Since between those two you can store nearly anything you could need, I believe this to be a quick and easy solution.

First of all, you’ll need to create a base plist file which your app can use to load its settings on its very first run. To create it, you need to open up the Xcode interface. Insert a new file, under the iOS section select “Resource” and then click on the “Property List” icon on the right. Then you will be prompted to give it a name, I gave it “GameSave” so the file created was “GameSave.plist”.

Now you will see it in your main project directory, but you will have to drag it over to the “Supporting Files” folder to have access to it. It still needs a bit of modification to be ready. Create a new entry in the file and make sure its type is “Dictionary.” You can give it any name you want.

Expand your new dictionary type and add a new row, this of Number type (this is what is used in my example, you may want to use something else here). Also be sure to set the value. Give it the key name of “CurrentGameState” which is what I will be using. It is a number that is used to indicate to the app what state it is in. What is for is not so important.

Once this is done, you have a plist that looks like this:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>CurrentGameState</key>
	<integer>0</integer>
</dict>
</plist>

The rest of the steps will be done purely in the code implementation.

The idea here is to use that as a base file which you can then copy to your app’s Documents directory where it will be readable and writable. This implementation has checks for whether the copied file exists in your app and if it doesn’t, will copy it over. After that, the app will simply read from the file, whether it previously existed or was just copied. It doesn’t matter at that point.

The first thing to do is define a function that will return the path to your app’s plist file in the Documents directory in your main view controller. Then you will define functions for saving and loading the app date. Finally, you will add your own handler for applicationDidEnterBackground in your controller.

This should go in the .h file:

@interface GameViewController : UIViewController
- (NSString*)saveGameDataPath;
- (void)loadGameData;
- (void)saveGameData;
- (void)applicationDidEnterBackground:(UIApplication *)application;
@end

The implementations belong in the .m file. Let’s start with the first function that we declared.

- (NSString *) saveGameDataPath
{
	NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
	return [[path objectAtIndex:0] stringByAppendingPathComponent:@"GameSave.plist"];    
}

saveGameDataPath Notes: This looks for a copy of the GameSave.plist file we created earlier in our Xcode project as a base file in the Documents directory. Each app gets its own Documents folder in iOS to store its application data.

- (void)loadGameData
{
    NSString *dataPath = [self saveGameDataPath];
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:dataPath];
    
    if (!fileExists) { // a save file does not exist, create it for the first time
        // grab the master game save data that is shipped with the game
        NSString *bundleFile = [[NSBundle mainBundle]pathForResource:@"GameSave" ofType:@"plist"];
        
        //copy the file from the bundle to the game's own Documents directory 
        [[NSFileManager defaultManager]copyItemAtPath:bundleFile toPath:dataPath error:nil];
    }
    
    // ok to read values from the plist (whether already existing or just copied from master)
    NSDictionary *dict = [[NSMutableDictionary alloc] initWithContentsOfFile:dataPath];
    
    currentGameState = [[dict valueForKey:@"CurrentGameState"] integerValue];
}

loadGameData Notes: It uses the path function we created earlier to look up whether it exists or not. If it doesn’t, it copies over the one supplied with the project to the app’s Documents directory. After this is done, the GameSave.plist can now be read. Either it was freshly copied over or else had previously been created. Regardless, the application data is now present. An NSDictionary class is used to read in the .plist data (which for consistency is also used when saving to the file below). It’s just an empty core implementation at this point, which allows for a object to be retrieved with a key. You could have used an NSArray for the same effect but you would need to save data as an array for consistency. Just remember this when you are using your own data structures.

- (void)saveGameData
{        
    NSString *dataPath = [self saveGameDataPath];
    NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithContentsOfFile:dataPath];
        
    //adding the new objects to the plist
    NSNumber *stateNumber = [[NSNumber alloc] initWithInt:currentGameState];
    [dict setObject:stateNumber forKey:@"CurrentGameState"];
    
    //finally saving the changes made to the file
    [dict writeToFile:dataPath atomically:YES];
}

saveGameData Notes: This function grabs the path to the GameSave.plist file and writes to it.

- (void)applicationDidEnterBackground:(UIApplication *)application {
	[self saveGameData];
}

applicationDidEnterBackground Notes: This is your opportunity to call saveGameData. This function gets automatically called whenever the app enters background mode. This happens when the user pressed the Home button. Whether they make it back to your app or not you can’t take any chances. You will need to save the data here in case they don’t come back and your app gets kicked out of the running threads by the iOS thread manager (this was Apple’s new multithreading feature introduced in 5.0).

Now, your program won’t automatically call the controller’s applicationDidEnterBackground function unless you register it explicitly. This is done in the viewDidLoad function:

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    UIApplication *myApp = [UIApplication sharedApplication];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(applicationDidEnterBackground:)
                                                 name:UIApplicationDidEnterBackgroundNotification
                                               object:myApp];
    [self loadGameData];
}

Note that I also added a call to loadGameData here. This makes sure the saved data gets loaded when the app starts.

That’s all there is to it. Hopefully you found this clearer than the source examples I based this implementation off of. If there are any questions or clarifications needed please let me know in the comments.

Making Button Backgrounds Transparent in Xcode

September 13, 2012

If you want just a simple line of text (the text of the button) to be a “link” that you can click on in your app, you will want to turn the button background transparent. I tried initially tried a few things like playing with the alpha settings which did not work as well as setting the button background. I even made sure in the color palette to choose the “iPhoneSDK” group and select “clearColor” which is supposed to be like the system color for transparency.

No dice…

Until I found this little solution on the web, which I am documenting here for my own reference. Making a button background invisible is actually brilliantly simple. You just make the button type “Custom,” which is the very first setting available to you in the settings panel on the right when you click the button. Code wise, this is equivalent to UIButtonTypeCustom. Apparently “Custom” is a clean slate so even the color goes away. After that you are free to play with the text color, that will stick. Thus you can create a clickable “link” in your app.

This is better than trying to use a clear image as a button background or any of that other nonsense. Simple and elegant.

 
Powered by Wordpress and MySQL on MDDHosting. Theme by Shlomi Noach, openark.org