Asked by:
Fixed: OS X Yosemite: The document ... could not be opened. The operation couldn’t be completed.

Question
-
User13824 posted
Xcode 6's
ibtool
has a bug under OS X 10.10 Yosemite that causes an error when attempting to compile interface documents that reference image resources within subfolders.http://stackoverflow.com/questions/25754763/cant-open-storyboard
Example failing image path (in the solution folder)
Resources\Images\image.png
Example working image path (in the solution folder)
Resources\image.png
Error message
// ibtoold[881:13909] Exception raised while unarchiving document objects - -[NSTaggedPointerString getCharacters:range:]: Range {0, 10} out of bounds; string length 4 // /* com.apple.ibtool.errors */ // /Users/macuser/Desktop/iPhoneApp1/iPhoneApp1/MainStoryboard.storyboard: error: The document "MainStoryboard.storyboard" could not be opened. The operation couldn’t be completed. (com.apple.InterfaceBuilder error -1.) // Recovery Suggestion: Check the console log for additional information. // ibtool exited with code 1
Workarounds
Here are a few possible workarounds that can be used until Apple resolves this bug.
Option 1: Manage all
UIImageView.Image
properties in codeRather than setting the
Image
property of aUIImageView
in the storyboard or.xib
file, you can set the property in one of the view life cycle override methods in the view controller (for example, inViewDidLoad()
). See also http://developer.xamarin.com/guides/ios/applicationfundamentals/workingwith_images/ for tips about usingUIImage.FromBundle()
vs.UIImage.FromFile()
.Option 2: Move all of the image resources to the top-level
Resources
folderAfter this change, you will need to update the storyboard and
.xib
files to use the new top-level image paths.Option 3: Set the
LogicalName
for any problematic image assets so they are copied to the top level of the.app
bundleFor the example above, the
.csproj
file will by default contain the following entry:<BundleResource Include="Resources\Images\image.png" />
You can change this element and add a
LogicalName
so that the image will instead be copied to the top level of the.app
bundle:<BundleResource Include="Resources\Images\image.png"> <LogicalName>image.png</LogicalName> </BundleResource>
In Xamarin Studio the
LogicalName
can also be set using the "Resource ID" field for the image under "View -> Pads -> Properties". (See also: http://stackoverflow.com/questions/16938250/xamarin-studio-folder-structure-issue-in-ios-project/16951545#16951545)After this change, you will need to update the storyboard and
.xib
files to use the new top-level image paths. Xamarin Studio will automatically update the list of autocompletions for the "Image" property in the iOS Designer. In Visual Studio, you'll need to edit the path by hand (toimage.png
for the example). The iOS Designer will then display this as a missing image, but the project will build and run correctly.Friday, October 24, 2014 7:42 PM
All replies
-
User13824 posted
Duplicate threads (closed):
- http://forums.xamarin.com/discussion/26666/the-document-mainwindow-xib-could-not-be-opened
Friday, October 24, 2014 8:04 PM -
User3151 posted
Thanks for the info @BrendanZagaeski?
Friday, October 24, 2014 8:37 PM -
User8884 posted
Thanks for the information, very useful! @BrendanZagaeski?
Tuesday, October 28, 2014 8:48 PM -
User13824 posted
Apple fixed this
ibtool
bug in Xcode 6.1.1, so upgrading to Xcode 6.1.1 or higher is now the easiest way to solve this problem.Friday, April 10, 2015 4:04 AM