手工下载Xcode文档
Xcode自己下载文档慢的像狗屎,所以解决方法是,自己去下载。
首先,记住这些AppleDeveloperConnection的Xcode文档频道(以后可能会改变):
SnowLeopard核心文档(包括Java和旧文档)
Xcode3.2核心文档
Leopard核心文档
iPhoneOS3.1核心文档
iPhoneOS2.2核心文档
直接在Safari或其他RSS阅读器中打开这些连接,你就能看到下载连接了:
你也可以打开Atom文件,分析里面的XML,以获取下载地址——人肉分析就可以了,很简单的。
举个例子:
<?xmlversion="1.0"?>
<feedxmlns="http://www.w3.org/2005/Atom"xmlns:docset="http://developer.apple.com/rss/docset_extensions"xml:lang="en">
<id>http://developer.apple.com/rss/com.apple.adc.documentation.AppleSnowLeopard.atom/20080609120049</id>
<titletype="text">AppleSnowLeopard</title>
<author>
<name>AppleDeveloperConnection</name>
<uri>http://developer.apple.com/</uri>
</author>
<rights>Copyright2009AppleInc.</rights>
<linkrel="self"href="http://developer.apple.com/rss/com.apple.adc.documentation.AppleSnowLeopard.atom"></link>
<updated>2009-11-17T12:03:32-08:00</updated>
<docset:publisherName>Apple</docset:publisherName>
<docset:publisherID>com.apple.adc.documentation</docset:publisherID>
<entry>
<id>tag:developer.apple.com,2009-10-21:com.apple.adc.documentation.AppleSnowLeopard.JavaReference/401.13.0</id>
<titletype="text">MacOSXJavaLibrary</title><!--这是文档包名,也就是Java文档-->
<updated>2009-10-21T10:55:14-07:00</updated>
<contenttype="text">MacOSXJavaLibrary(v401.13.0)</content><!--这是文档包名和版本号-->
<linkrel="enclosure"type="application/octet-stream"href="http://devimages.apple.com/docsets/Oct2009/com.apple.adc.documentation.AppleSnowLeopard.JavaReference.xar"length="129621213"></link><!--这是文档包下载地址-->
<docset:identifier>com.apple.adc.documentation.AppleSnowLeopard.JavaReference</docset:identifier>
<docset:version>401.13.0</docset:version><!--这是文档包版本号-->
<docset:signer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:signer>
<docset:issuer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:issuer>
<docset:minimumXcodeVersion>3.1.0</docset:minimumXcodeVersion><!--适合的最低版本的Xcode版本号-->
</entry>
...
<entry>
<id>tag:developer.apple.com,2009-11-17:com.apple.adc.documentation.AppleSnowLeopard.CoreReference/402.20.0</id>
<titletype="text">MacOSX10.6CoreLibrary</title><!--这是雪豹的核心文档-->
<updated>2009-11-17T11:55:04-08:00</updated>
<contenttype="text">MacOSX10.6CoreLibrary(v402.20.0)</content>
<linkrel="enclosure"type="application/octet-stream"href="http://devimages.apple.com/docsets/Nov2009/com.apple.adc.documentation.AppleSnowLeopard.CoreReference.xar"length="553074896"></link>
<docset:identifier>com.apple.adc.documentation.AppleSnowLeopard.CoreReference</docset:identifier>
<docset:version>402.20.0</docset:version>
<docset:signer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:signer>
<docset:issuer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:issuer>
<docset:minimumXcodeVersion>3.2.0</docset:minimumXcodeVersion>
</entry>
<entry>
<id>tag:developer.apple.com,2009-11-17:com.apple.adc.documentation.AppleLegacy.CoreReference/3.20.0</id>
<titletype="text">MacOSXLegacyLibrary</title><!--这是旧文档-->
<updated>2009-11-17T12:03:32-08:00</updated>
<contenttype="text">MacOSXLegacyLibrary(v3.20.0)</content>
<linkrel="enclosure"type="application/octet-stream"href="http://devimages.apple.com/docsets/Nov2009/com.apple.adc.documentation.AppleLegacy.CoreReference.xar"length="898424019"></link>
<docset:identifier>com.apple.adc.documentation.AppleLegacy.CoreReference</docset:identifier>
<docset:version>3.20.0</docset:version>
<docset:signer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:signer>
<docset:issuer>CN=ADCDocSetUpdate,O=AppleInc.,OU=AppleDeveloperConnection,C=US</docset:issuer>
<docset:minimumXcodeVersion>3.2.0</docset:minimumXcodeVersion>
</entry>
</feed>
</source>
分析结束,下载需要的xar文件。把Xcode和OSX的文档解压缩到/Developer/Documentation/DocSets,把iPhone的文档解压到/Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets/下。解压缩方法:
sudoxar-xfcom.apple.whateverxxxx.xar
sudochown-R-P_devdocscom.apple.whateverxxx.docset
sudochmod775com.apple.whateverxxx.docset
然后就能在Xcode的文档查看器里查看了。(在Xcode3.2上测试通过)
因为苹果频繁更新Xcode的文档,所以我写了一个脚本,专门解决输入那一大串命令的问题。前提是,你把脚本放在了存放文档的目录,并且Mac和iPhone的文档xar分别置于Mac和iOS两个子目录种。看脚本你就知道为什么了。
#!/bin/bash
macdocs='/Developer/Documentation/DocSets/'
iosdocs='/Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets/'
#Function:ExtractDocsFromXarArchives
do_extract(){
echoIndirectory:$1
echoExtractxars...
forfilein`ls-1`
do
xar-xf$file
done
echoDeletexars...
rm-f*.xar
echoChangeownerships...
fordirin`ls-1`
do
chown-R-P_devdocs$dir
chmod775$dir
done
}
#DeleteOldDocsandCopyxartoMacDocDir
echoOperationStart.
echo
echoDeletingOldMacDocsets...
rm-rf${macdocs}*.docset
echoCopyingxarsto$macdocs
cpMac/*.xar$macdocs
#DeleteOldDocsandCopyxartoiOSDocDir
echoDeletingOldiOSDocsets...
rm-rf${iosdocs}*.docset
echoCopyingxarsto$iosdocs...
cpiOS/*.xar$iosdocs
#GotoMacDocDirandExtractDocs.
echoStarttoExtractMacDocs...
cd$macdocs
do_extract$macdocs
#GotoiOSDocDirandExtractDocs.
echoStarttoExtractiOSDocs...
cd$iosdocs
do_extract$iosdocs
echoAllDone.