The document “XXXX.xib” could not be opened. Could

2019-02-03 04:48发布

After opening my project in the Xcode5 developer preview, errors appeared against a few .xib files when I tried to open the project in Xcode 4.5. The error text was:

 The document "XXXX.xib" could not be opened. Could not read archive.

 Please use a newer version of Xcode. Consider changing the document's Development Target to preserve compatibility.

The project's development target in Xcode5 appears to be iOS 5.0.

Looking at the source code of the .xib files with errors, it is clear that the .xml structure for .xib files in Xcode5 has changed quite dramatically, and it needs to be reformatted to be backwards compatible.

Is there a way to set development targets for specific .xib files? Does anyone know how this error can be resolved?

Many thanks.

7条回答
Luminary・发光体
2楼-- · 2019-02-03 05:16

Just open Storyboard in XCode 5, into right panel and "File Inspector" tab do:

  1. edit your "Interface Builder Document" like follow:

enter image description here

  1. Save it and open in previous XCode.
查看更多
爷的心禁止访问
3楼-- · 2019-02-03 05:17

First of all open project with Xcode5. and then

  • select XXX.xib find Interface Builder Document
  • Opens in Xcode 4.6(if is 5.0)
  • close project
  • open it with 4.6
查看更多
别忘想泡老子
4楼-- · 2019-02-03 05:20

A better and easier solution that works even if your project isn't under source control can be found here (mine):

Just installed xcode 5 and have missing storyboards

Hope that helps.

查看更多
smile是对你的礼貌
5楼-- · 2019-02-03 05:21

well obviously you created your project prior to the new xcode developer preview. then you tried opening your project with the new DP and boom, it automatically changed everything in your xibs to be able to present your xibs in a higher version. easy to fix. with your xcode 4 ios 6 open the same project, then right click on the name of the xib that is not opening and select source control and from there select discard changes. that should return the xib back to the shape it was before you opened it with the new xcode DP.

let me know if you need more help but that should take care of your problem.

查看更多
贪生不怕死
6楼-- · 2019-02-03 05:24

It's a current problem when you open your Xcode 4.6 project with the new XCode 5. To reuse correctly your XIB with Xcode 4.6 :

1 Open your project with XCode 5

2 Select your Xib to restore

3 In the File Inspector Section, in "Interface Builder Document", select Xcode 4.6 in the Development's version of Document Versioning

4 Build and close

5 Reopen your project with XCode 4.6

It's possible to have some regression with elements width & size in your XIB, but it was restored successfully.

Cheers,

查看更多
成全新的幸福
7楼-- · 2019-02-03 05:30

Once I used to manage a project with XCode 5 xibs in XCode 4. I split xibs for each XCode version and made this build script that compiles xib to nib and place that nib them inside the app

#get SDK version
SDK_VERSION=$(echo $SDKROOT | sed -e 's/.*iPhone\(OS\)*\(Simulator\)*\([0-9]*.[0-9]*\).sdk/\3/')

if [ $SDK_VERSION == '7.0' ]; then
   echo 'Current SDK is 7.0'

   ibtool --compile ${TARGET_BUILD_DIR}/${TARGET_NAME}.app/output.nib ${PROJECT_DIR}/ProjectFolder/input.xib.xib 

   echo 'Copied nibs to' ${TARGET_BUILD_DIR}/${TARGET_NAME}.app
else
   echo 'Current SDK is not 7.0 (SDK is' $SDK_VERSION')'
fi
查看更多
登录 后发表回答