手工下载Xcode文档

Xcode自己下载文档慢的像狗屎,所以解决方法是,自己去下载。

首先,记住这些Apple Developer Connection的Xcode文档频道(以后可能会改变):

Snow Leopard核心文档 (包括Java和旧文档)
Xcode 3.2核心文档
Leopard核心文档
iPhone OS 3.1核心文档
iPhone OS 2.2 核心文档

直接在Safari或其他RSS阅读器中打开这些连接,你就能看到下载连接了:


你也可以打开Atom文件,分析里面的XML,以获取下载地址——人肉分析就可以了,很简单的。

举个例子:

<?xml version="1.0"?>
<feed xmlns="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>
    <title type="text">Apple Snow Leopard</title>
    <author>
        <name>Apple Developer Connection</name>
        <uri>http://developer.apple.com/</uri>
    </author>
    <rights>Copyright 2009 Apple Inc.</rights>
    <link rel="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>
        <title type="text">Mac OS X Java Library</title><!--这是文档包名,也就是Java文档-->
        <updated>2009-10-21T10:55:14-07:00</updated>
        <content type="text">Mac OS X Java Library (v401.13.0)</content> <!--这是文档包名和版本号-->
        <link rel="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=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,C=US</docset:signer>
        <docset:issuer>CN=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,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>
        <title type="text">Mac OS X 10.6 Core Library</title><!--这是雪豹的核心文档-->
        <updated>2009-11-17T11:55:04-08:00</updated>
        <content type="text">Mac OS X 10.6 Core Library (v402.20.0)</content>
        <link rel="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=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,C=US</docset:signer>
        <docset:issuer>CN=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,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>
        <title type="text">Mac OS X Legacy Library</title><!--这是旧文档-->
        <updated>2009-11-17T12:03:32-08:00</updated>
        <content type="text">Mac OS X Legacy Library (v3.20.0)</content>
        <link rel="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=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,C=US</docset:signer>
        <docset:issuer>CN=ADC DocSet Update,O=Apple Inc.,OU=Apple Developer Connection,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/下。解压缩方法:

sudo xar -xf com.apple.whateverxxxx.xar
sudo chown -R -P _devdocs com.apple.whateverxxx.docset
sudo chmod 775 com.apple.whateverxxx.docset
然后就能在Xcode的文档查看器里查看了。(在Xcode 3.2上测试通过)

因为苹果频繁更新Xcode的文档,所以我写了一个脚本,专门解决输入那一大串命令的问题。前提是,你把脚本放在了存放文档的目录,并且Mac和iPhone的文档xar分别置于Mac和iOS两个子目录种。看脚本你就知道为什么了。

#!/bin/bash

macdocs='/Developer/Documentation/DocSets/'
iosdocs='/Developer/Platforms/iPhoneOS.platform/Developer/Documentation/DocSets/'

# Function: Extract Docs From Xar Archives
do_extract() {
    echo In directory: $1
    echo Extract xars...
    for file in `ls -1`
    do
      xar -xf $file
    done

    echo Delete xars...
    rm -f *.xar

    echo Change ownerships...
    for dir in `ls -1`
    do
      chown -R -P _devdocs $dir
      chmod 775 $dir
    done
}

# Delete Old Docs and Copy xar to Mac Doc Dir
echo Operation Start.
echo
echo Deleting Old Mac Docsets...
rm -rf ${macdocs}*.docset
echo Copying xars to $macdocs
cp Mac/*.xar $macdocs

# Delete Old Docs and Copy xar to iOS Doc Dir
echo Deleting Old iOS Docsets...
rm -rf ${iosdocs}*.docset
echo Copying xars to $iosdocs...
cp iOS/*.xar $iosdocs

# Goto Mac Doc Dir and Extract Docs.
echo Start to Extract Mac Docs...
cd $macdocs
do_extract $macdocs

# Goto iOS Doc Dir and Extract Docs.
echo Start to Extract iOS Docs...
cd $iosdocs
do_extract $iosdocs

echo All Done.

你可能感兴趣的:(xcode)