Xcode unable to create snapshot: unable to write to file … plist

Xcode error:  Unable to create snapshot  Unable to write to info file ‘<DVTFilePath: ~~~~~ info.plist’>’.

Xcode has been tossing this error at me for over a year now.  This problem has persisted across multiple versions of Xcode and OS X.  Whenever I open an older project (from a previous version of Xcode), it often suggests some updates to the project and offers to create a snapshot of the project before continuing.  It always fails with an error similar to this.  Manually initiating an Xcode snapshot from menu FILE | Create Snapshot results in the same error.

It hasn’t been real issue for me, I use GIT for version control and have never relied on Xcode snapshots.  It’s only been a minor nuisance, but I’m procrastinating on some other work and this seems like a good time to investigate the problem.

Xcode unable to create snapshot

Quite a few web posts indicate it has something to do with corrupted .DS_Store files and/or conflicts with GIT and the location of the .git folder relative to the Xcode project.

To test those ideas, I tried deleting those files… it didn’t work.  Also tried creating a new project without using GIT at all.  It still failed with the error.

Creating a brand new directory, verifying permissions, and changing Xcode preferences to use that directory for snapshots didn’t work either.

For now, I’m stumped on this one.  Next step may be to try running clean copy of Xcode and OS X in a VM and see if the problem shows up there.  Maybe I’ll find something later… if I do, I’ll post an update.

A GUI utility to view & edit agents & daemons for OS X — Peter Borg’s Lingon.

Finally found a GUI utility to view/edit agents & daemons for OS X Mountain Lion 10.8.2   (should work with anything from 10.5 or newer)

OS X uses the “Mac launchd” facility to manage the startup of system services and to provide functions which may have previously used cron.

It works by utilizing PLIST scripts for three types of startup agents:

  1. /Library/LaunchDaemons – scripts in this folder run even if no users are logged in.  Useful for creating a “system service” to automatically startup whenever the operating system is booted.
    • summary: load on system startup; run as root.
  2. /Library/LaunchAgents – scripts in this folder run after any user has logged in.  These are often configured to run as root, but can run as any user.
    • summary: load on any user login; run as user.
  3. $HOME/Library/LaunchAgents – scripts in this folder run for a the specific user login and run under that user’s account.
    • summary: load on specific user login; run as user.

The plist is an XML file which specifies a command to run and a variety of options (parameters).  The specified command can be a shell script, application, or most anything available to you at Terminal‘s command line.

Editing agent and daemon plist scripts manually can be a bit cumbersome for infrequent changes.  Some requirements include:

  • creating the plist in the correct location and setting the file permissions.
  • use launchctl command with load, unload, start, stop, remove, submit, or list options.
  • manually editing the plist file with the correct keys and parameters.
  • moving back and forth between terminal window command line activities, text editing, and file management.
  • keeping track of desired results, the changes made to the system, and the actual results.  You do keep track of these things right?

In the interest of simplifying things, I went looking for a GUI utility.  

Given the jargon laden nature of this topic, it’s quite likely there may be other options out there which I haven’t found.  The concept of managing daemons is a common one Mac inherited from it’s Unix origins and shares with Linux.  Additionally, Apple has been changing “under-the-hood” aspects of OS X for several releases now.  Finding a combination of searchable keywords specific to a GUI utility for Mountain Lion’s launchd and launchctl features appeared to be getting me nowhere.  

Eventually I found an older piece of software which seems to fill my needs quite well.  Lingon 2.1.1 by Peter Borg.  Although this older version is no longer supported, it is still available from source forge.

Lingon 2.1.1 features include:

  • Display existing items and view/edit their plist files.
  • Easily enable or disable existing items.
  • Creates the plist file when creating a new agent.
  • GUI provides a “basic mode” to view or edit some of the parameters.
  • It also provides “expert mode” to view or edit the full XML.  Includes a list of about 40 parameters which can be inserted.
  • Expert mode also validates the plist to be a valid file.  (Verifies structure, but doesn’t magically verify parameter settings for you… you still have to do some work yourself.)
  • Source code is available as an Xcode project dated 2008-12-18.  It successfully builds and runs under Xcode 4.5.2 on Mountain Lion 10.8.2  I needed to set the project to use the 10.8 SDK I have installed, and it threw a few minor minor warnings about syntax.  But it’s pretty good to be able to compile and run four year old source code with no changes. 

 

note: Newer versions of the Lingon app are only available from the Mac App Store and (due to GateKeeper / app rules) no longer have the ability to work on systemwide agents/daemons.  The App Store version is limited to the current log’d in user only.  The developer doesn’t seem to be offering an alternative update out side of the App Store; but the older 2.1.1 (2008-12-18) still works under Mountain Lion OS X 10.8.2 and is able to create or edit new agents and daemons.

If you’re only working with processes for the current log’d in user, “Lingon 3″ is currently available on the Mac App Store for $5.  For a single user setup or any system using FileVault2 (which requires a user login to unlock the drive before anything will startup), the App Store version may be all you need.

Lingon 2.2.1 is also still available in the Mac App Store for $5 as “Lingon“.  Satisfied with the version downloaded from sourceforge, I was curious to see how whether the older App Store version would still work with Mountain Lion.

$5 seems a fair price for a useful utility and an expensive test of whether Mountain Lion 10.8.2 is imposing any restrictions on pre GateKeeper App Store software. It pre-dates Apple’s latest GateKeeper app requirements, but worked just fine.

Xcode 4.4.1 update is 47.48MB from app store.

Today’s new Xcode update 4.4.1 (for production usage) comes as a 47.48MB update from the Mac App Store.

After the update completes, checking the Xcode preferences for components and documentation indicated “Command Line Tools (143MB)” was the only portion needed additional updating at this time.  It appears the simulators and documentation did not change. 

Install CentOS 6.3 64-bit Linux in VMware Fusion 4.1.3

As part of my iOS app development and testing lab, I have a need to be able to test client applications against multi-platform database services.  Last year I determined a collection of OS X, CentOS, and openSUSE virtual machines running MySQL and PostgreSQL provides an adequately diverse test environment for my needs.

A wide variety of application prototyping and testing needs can be served by these combinations without requiring a rack of high end hardware and a couple full time DBAs to maintain everything.  Many of my clients have performance testing and production requirements far beyond my little “proof of concept” setup.  However, my “proof of concept” environment often helps me better understand how to communicate with the DBAs in the large organizations.  And sometimes it allows testing ideas that they don’t have the luxury of trying out on a $25 Million production database cluster.

My virtual lab environment had grown a bit stale over the past year.  Over the past week or so, I’ve been updating to OS X 10.8 Mountain Lion and both the Xcode 4.4 general release and the Xcode 4.5 iOS 6 betas.  Now I’m beginning to update the Linux and SQL components of the environment.  I’ve had a long affinity for Suse Linux so I like to keep a familiar distro on hand.  Many clients are using Redhat in their production environments, so CentOS has become a necessity.  In the past, Solaris was always a key component of my setups but not so much any more; adding some new Solaris VMs will be deferred for another time.

For this portion of the lab update I’ll be building a couple new CentOS VMs and keeping some notes.  I’ll begin with the CentOS 6.3 x86-64 bit “netinstall.iso“.  Assuming you’re install to location with internet connectivity (and not organizationally firewalled into using sneakernet for your lab), the netinstall.iso option saves the time otherwise spent updating all of the packages in the LiveCD or full ISO images.

In VMware Fusion 4.1.3,

  • select the menu options “File” and “New” to get the “Create New Virtual Machine” dialog window.
  • select “Continue without Disk
  • select “Choose a disk or disk image…
  • use the presented Finder popup to navigate to your target ISO image (which you’ve previously downloaded) and select “Continue“.
  • select Operating System: “Linux
  • select Version: “CentOS 64-bit
  • select “Continue”  note: the OS and Version selections are important as they inform VMware Fusion which drivers, VMtools, and VM configuration settings to utilize.  VMs can successfully be created using less specific settings, by you’d lose out on some features of Fusion and likely have to perform additional manually configuration work within your Linux VM.
  • you should be presented with a summary configuration of your new VM with the options to “Customize Settings” or “Finish“.  This default will likely be one processor core and 1GB memory; I recommended increasing this to two cores and 2GB memory.  After completing the installation and configuration, you might try lowering the settings but these will be helpful for getting thru the various package installations and configurations.
  • select “Finish” and use the Finder popup to name and save your new VM.  I like to configure a “base image” to my preferences and then make copies of as needed for testing new configurations or loading additional packages.  So it’s helpful to think of a naming convention if you are likely to have multiple copies over time.
  • Fusion will start the new VM and the netinstall.iso will boot to a setup process.  Netinstall will be a text based interface (use your keyboard arrows keys to move between options).  The first dialog will be for testing the installation media.  I’ll “Skip” the media test.  If you uncertain about where you image came from or the quality of your internet connection, you may want to let the me test proceed.
  • choose a language
  • choose a keyboard type
  • choose an installation method.  select “URL“. (you’ll be prompted for details later).
  • configure TCP/IP.  unless you need to change, accept the defaults by selecting “OK“.
  • a dialog will display “waiting for network manager to configure eth0
  • URL setup.  enter “http://mirror.centos.org/centos/6.3/os/x86_64&#8243;.  The text interface does not allow copy/paste from the host, so you will need to type this in exactly.  cents.org redirectors the download to one of many mirror sites.  If the URL doesn’t work for you, check your typing and try again.  It’s possible the redirection could get sent to a server that is temporarily busy or offline.  Trying again usually works.  If not, you’ll need to do some searching to locate a direct URL to mirror server that is reachable from your network location.
  • After the netinstall process begins, in a few moments you’ll see a graphical screen displaying a CentOS 6 logo.  Select “Next“.
  • Basic storage device should be ok. Select “Next“.
  • Storage Device Warning.  This is a fresh install, so select “Yes, discard any data“.
  • local hostname:  Enter a hostname for your VM.
  • select a timezone.
  • enter a root password (twice to confirm, must be at least six characters).
  • which type of installation would you like?  select “use all space“.
  • write changes to disk
  • select optional software to install.  Note:  Selecting software packages is a lot easier if you wait until the system is up and running with VMtools providing proper mouse and video drivers plus the ability to select the various package repositories you’ll want to use.  So, for this step,  select “Minimal Desktop” and “Next“.  If you choose the “Minimal” option, you’ll be limited to the command line.
  • The necessary packages will be downloaded and installed (about 30 minutes of this older Core 2 Duo MacMini).  When it’s complete, you’ll be prompted to “Reboot“.
  • After the reboot, a Welcome screen will continue the process of setting up the new system.  Select “Forward“.
  • Agree to the license and select “Forward“.
  • Create User: input your desired user information. Select “Forward“.
  • Set Date and Time. Select “Forward“.
  • At this point I get a warning message “Insufficient memory to auto-enable dump. …” That’s ok, I don’t need it for this usage, so I’ll select “Ok” and “Finish“.  The VM will reboot to complete the setup.
  • After the reboot, a GUI login screen will prompt to login with the account just created in the previous steps and delivery you to the new desktop.

At this point the new VM is is ready to use with a base configuration of the “Minimal Desktop” distribution of CentOS v6.3.  However, there are some additional steps to make it bit more user friendly prior to archiving a copy and proceeding with the desired dev / test work this VM is intended for.

  • Use the VMware Fusion menu to select “Virtual Machine | Install VMware Tools“.  If you’ve not used previously used this feature in your current version / installation of VMware Fusion, you’ll be prompted that “VMware Fusion needs to download the following component: VMware Tools for Linux“.  Select “Download“.
  • VMware Fusion will be adding an additional component to the Fusion application on your Mac OS X host, so you will be prompted to authenticate and permit this action.
  • Next you’ll be prompted by Fusion to “Click Install to connect the VMware Tools installer CD to this virtual machine“.
  • This should result in the CentOS VM’s desktop displaying a DVD (or CD) icon titled “VMware Tools”.  Unfortunately, mine displayed a blank folder with an empty disk as a result.
    • Checking /Applications/VMware Fusion.app/Contents/Library/isoimages” confirmed that a “linux.iso” file was present (dated 2012-05-27).
    • Rebooting the VM and re-trying the VMtools installation still resulted in an empty disc image / folder.  This is a common problem between Fusion and many Linux distributions.  VMware’s support forums offer several work arounds, most of them at the command line.
  • My solution is to use the OS X Finder to browse the “VMware Fusion.app” package contents, copy the “linux.iso” to another folder, and mount it to the VM’s CD drive.
  • Return to the CentOS desktop, use “Computer” to browse the CD.  You should now see a “VMware-Tools……tar.gz” file.
  • Drag the “….tar.gz” file to your home folder.  Don’t bother trying right click and select “Open with archive mounter”. Extracting the files through the GUI will probably result in a process that estimates a couple hours to complete.
  • Use the CentOS “Applications” menu to launch “Terminal“.
  • “CD” to your home folder.
  • Use the “ls” command to verify the “…tar.gz” file is there.
  • Expand the archive using “tar zxpf VMwareTools-….tar.gz”  HINT: type “tar zxpf VMw” and hit “Tab” to autocomplete the command.
    • This should result in a new folder named “vmware-tools-distrib” containing 3,275 items for 178.6MB.
  • In terminal, type “CD vm” and hit “Tab” (to autocomplete).
  • Another “ls” command should verify the presence of “vmware-install.pl”.
  • You’ll need super user (root) privileges to run this script.  Type “su” and then enter the root password established during installation.
  • Enter “./vmware-install.pl” (or just type “./v” followed with a tab key to autocomplete).
  • The script will prompt with about nine questions.  Use “Enter” to accept the defaults for each.
  • When the script completes you can delete the “…tar.gz” from the VM to save diskspace.  In all likelihood, if you ever need them again for this specific VM, they’ll be out of date by then.  Reboot the VM to activate the VMware Tools features.

Now that VMware Tools is active the mouse should work much better, and you’ll be able to resize the VM window to whatever fits on your available host machines OS X desktop the best for your preferences. Copy/paste from the host machine should be enable.

VMware Fusion shared folders should also be working now.  However, you should verify as this is another feature where Fusion yields different results across various Linux distributions.  On this particular CentOS VM, sharing some folders from the host machine resulted in them be available within CentOS at the path “/mnt/hgfs/”.  Fortunately it wasn’t necessary to perform any additional commands to use them.  A quick test confirmed the shared path was readable and writeable from the VM.  note: this feature mounts the shared folders with the guest VM as virtual file system, there isn’t any shared/virtual networking going on with this feature.  

The next step I recommend is selecting the Applications menu “System | Software Update“.  Despite having just completed a network installation, this new instance of CentOS Minimal Desktop config had 43 available updates (124.6MB).  The update process will prompt for the root password.  You will also likely be prompted to authenticate to accept certificates, signatures, and various packages during the update process (so it’s not a walk away and leave it process).

Now that the base config is installed and updated, I’ll shut down the VM and make a Zip Archive (using OS X Finder) of it’s VM image.

It was about 2.5 hours to get this far.  A quad core host machine with SSD, and a faster internet connection, would reduce that considerably.  Some of the time was also spent writing these notes.

With this new configuration built and a backup tucked away, I probably won’t need to perform a base install of CentOS in this environment for another year.  I didn’t keep as much detail last time, so I’ll have to wait another year to compare whether things get faster.

My next steps for CentOS will be to configure the various application packages and settings that I need (and make another Zip Archive backup).  From there it is much faster to deploy additional instances for dev/test work whenever needed.

Testing “Xcode 4.5 and iOS 6 SDK beta 3” using a virtual machine instance of OS X Lion

For a couple weeks now, I’ve been using Xcode 4.3.3 and the iOS 5.1 SDK on a mid 2012 MacBook Air 13″ with 8GB Ram.  It’s very nice.

With the July 16th update to the iOS 6 development betas, it was time test running the new Xcode environment under a VM on the MacBook Air.  The first step in the process was to get a virtual instance of OS X Lion 10.7 running under VMware Fusion.

I’ve done this before, but the new 2012 MacBook CPU (Intel Ivy Bridge) caused a “CPU disabled by guest operating system… ” error under Fusion.  The solution was to add this line to the *.vmx config file of the target VM.

      cpuid.1.eax = “—-:—-:—-:0010:—-:—-:1010:0111”

VMware should have a 2012 update to Fusion for OS X Mountain Lion 10.8, they are currently testing it as a “technical preview”.  This post provides more information on the error and it’s solution.

With that problem solved, it was time to get Xcode 4.5 beta 3 up and running.  Right after installing VMware Tools and configuration some OS X settings to my preferences (I didn’t use Migration Assistant for this VM as I wanted a fresh environment).

The next issue was with the Xcode 4.5 app.  It would not run.  I used Lion 10.7.3 to create the VM the new beta requires a minimum of 10.7.4.  Using software updates to get 10.7.4, iTunes, and Safari updates downloaded about 1GB.  After the updates, the Xcode 4.5 beta is now able to run.  This is a good place to make a backup of the VMDK and save for future use.

VMware snapshots or Fusion Time Machine integration are both good features, but I prefer to locate the *.vmwarevm file (package) in Finder and copy to a compressed zip file.  I’ll use this zip as a clean start for additional beta releases as well as some OSX Server testing.  Will also use it to testing the Mountain Lion upgrade.

After installing Xcode, you’ll most likely want the ability to do something with it.  This entails installing some “core libraries”.  From within Xcode Preferences, the Downloads tab provides access to additional Components and Documentation. Plan for another GB or more of downloads.

If you’re setting up your virtual dev/test environment for first time, plan on 4 or 5 hours and several GB of downloads/updates during the process.  After that you’ll be able to test beta releases or do other experimental work in a VM (with USB access to physical devices if desired) without affecting any of the apps of your host Mac.

Installing OSX Lion into VMware Fusion on Macbook 2012 gets “cpu disabled by guest operating system” error.

In order to install OS X Lion into a virtual machine running under VMware Fusion, you need the install file from the Mac App store.  In this case, I started with:

  • the Mac App store file “Install Max OS X Lion_10.7.3.app”
  • VMware Fusion 4.1.1
  • Macbook Air 13″ mid-2012

I’ve run OS X Lion under VMs previously, so expected this should work without any difficulties.  I expected wrong.

Attempting to start a new VM resulted in a Fusion error message stating, “The CPU has been disabled by the guest operating system…”

To troubleshoot I:

  1.  started by checking for Fusion updates; the in app update check didn’t show any available updates.
  2. Next I decided to try a reinstall of Fusion.  Deleted the app, rebooted, and went to vmware.com to download a fresh copy.  Found a newer version 4.1.3  Trying this version resulted in same CPU error.
  3. Did some additional searching and found a vmware forum thread which referred to a work around listed in another vmware forum thread.

Here’s a summary of the solution to save the time of going through all of the forum thread references.

The physical Intel CPU in the mid-2012 MacBooks is new.  As a result, if you are using a Mac App store installation file for OS X obtained prior to the 2012 MacBooks, that version won’t understand the new processor.

The solution is to edit the configuration file of the OS X Lion virtual machine to add this entry

cpuid.1.eax = “—-:—-:—-:0010:—-:—-:1010:0111”

The configuration file will be located within the actual VM storage file.  You can use Finder to location the *.vmwarevm file, then right click to “Show Package Contents”.  The config file will be the *.vmx

Any easier way to open the VM’s configuration file is using the VMware Fusion Virtual Machine Library window.  Use the OPTION key + Right Click on the target VM.  An option to “Open Config File in Editor” will be available.

This solution should work on the following combinations of hardware software:

  • All mid-2012 MacBooks
  • VMware Fusion 4.1.3
  • OS X host operating system version Lion 10.7.4
  • OS X guest operating system versions Lion 10.7.3 or 10.7.4

VMware is working on a “Technology Preview 2012″ for OS X Mountain Lion 10.8  As of this writing the workaround for that version is different.    Hopefully VMware will clean this up prior to release the 2012 version.

If Apple releases a Mac App store installation package of Lion 10.7.5, that may also solve the VM CPU configuration issue.

Running OS X Lion in virtual machines is my preferred method of testing new versions of the iOS SDK and Apple’s iOS Device Management tools.  With a recent move to a 2012 MacBook Air 13” and the developer release of iOS v6, apparently it was time to encounter a new collection of configuration issues.

Xcode 4.2 – using source code branches and other Xcode shortcuts

command T — to open a new tab in Xcode.  Tabs can be pulled outside the main tab to create a multi-window environment.  These additional windows can then be pulled over to a second monitor.  The Xcode | Settings | Behavior pane can be used to setup window layouts to automatically launch when performing certain activities (like debugging, building, or testing).

Run multiple instances of your project simultaneously:  Xcode 4.2 supports launching multiple instances of an app (or multiple apps).  This helps with testing client-server scenarios and multi-user peer-to-peer apps.  You can mix and match simulator versions and physical device types, or just run multiple instances of the same version.

running Xcode from the command line:
$ /Xcode/usr/bin/clang -c myfile.h
$ /Xcode/usr/bin/clang++ -c another_file.cpp

Source control and multiple branches: From Organizer | Repositiories you can navigate into the Branches folder under a project, and the select the + Add Branch icon to create a new branch (additional options appear in popup dialog boxes).  From within your Xcode Workspace and the Editor, activate the “Show the Version Editor” icon (it’s in the upper right area of the toolbar).  Now you’ll have a navigator bar display at the bottom of each editor pane, and you can use this navigator bar to view items in various branches.

Note: navigating in the Version Editor does not switch your currently actively branch.  Be sure to use the Organizer’s Repository view to switch branches.  When clicking the Version Editor icon, it will initially display the currently active branch and version in the lower navigation bar (in case you need to quickly verify which branch you are working in).

To switch your active editing to a different branch, navigate back to the Organizer | Repositories and select the blue folder under your project repository (left side of screen).  From here, the lower area of the Repository view will display icons to Pull, Commit, or Switch Brach.  The upper right hand portion of the Repository view will display “Current Branch: yourBranchNameHere“.  If you switch branches while a workspace has that project open, the workspace window will refresh and load the selected branch’s files into the navigator.

Reconciling code from multiple branches:  When using the Version Editor, the navigation bar in the lower area of screen “appears” to allow you to look at two branches simultaneously.  At least for me (and my installation of Xcode 4.2.1), that doesn’t actually work.  The version editor is limited to viewing within the currently active branch.   Instead, when you need to compare across branches (or are ready to merge), it seems necessary use the Xcode | File | Source Control | Merge menu option.  This will launch you into a another popup window version of the version editor; however, it will only show the most recent version in each branch (the other version navigation features are disabled in the Merge view).

I’ll update these notes if I find a better way to compare versions across multiple branches or if this is updated/fixed in a subsequent release of Xcode.

Handling Interruptions in your iOS App.

iOS – Handling Interruptions

As we all know, iOS Apps run on mobile devices.  The users of mobile devices can be interrupted by any number of things.  Many of the interruptions come from other services and features of the devices themselves.  Incoming phone calls, text messages, notifications, alerts, etc.
As an App developer, it is a good idea to plan for handling interruptions and test the results.
One simple technique for testing uses the iPhone’s built in Clock App.  Setting the alarm clock about ~ 1 minute ahead, use app and observe behavior when alarm interrupts the app.
A well designed App should respect the interruption, be prepared to be backgrounded, and be prepared to be exited.  For a good user experience, the current application state should be saved (if applicable) so the user can eventually return to the app and resume where they left off.

displaying web content withing an iOS app

I’ve been using some work related iOS apps which have a frustrating habit of kicking you out to a Safari browser to view something, and then leaving it up to you (the user) to find your way back into the app and also to deal with the left over Safari windows later.  Had this app developer paid attention to the interface guidelines, perhaps they would have noticed a better design pattern.

~~~~~~~~~~~~~~~

Instead of sending the user to an external Safari browser session (which has no good options for navigating “back” to the part of your app the user was at);

incorporate one of these into your app:

iOS web content:
UIWebView
NSUrlConnection

HTTP Authentication
NSUrlConnection to download content

OffscreenRendererViewController – does a background conversion of the web content to create an image of that page and then display the image to the user within the app’s view.

Xcode 4 Shortcuts

Xcode 4 shortcuts:

hold COMMAND key and double click a method to find it’s header.

hold OPTION key and double click a method to find it’s documentation.

rename a local variable within a method….
place cursor behind an object (ie., after last character), and then MENU | EDIT ALL IN SCOPE to rename all occurances of that object WITHIN the current local scope.