我们可以在 Xcode 4 中导入 .apparchive 包吗

发布于 2024-10-18 02:31:50 字数 169 浏览 3 评论 0原文

在 Xcode 3 中,应用程序存档在 .apparchive 文件夹中。

在 Xcode 4 中,应用程序现在存档在 .xcarchive 包中。

有没有办法转换 .xcarchive 捆绑包中的 .apparchive 文件夹或使用 Xcode 4 打开 .apparchive 文件夹?

In Xcode 3, applications were archived in .apparchive folders.

In Xcode 4, applications are now archived in an .xcarchive bundle.

Is there a way to convert .apparchive folders in .xcarchive bundles or to open .apparchive folders with Xcode 4?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静若繁花 2024-10-25 02:31:50

戴夫·邓金(Dave Dunkin)的脚本效果很好,但在某些情况下我错过了图标和版本。下面是脚本的略有调整的版本。 您需要安装 MacRuby,可在此处获取:http://www.macruby.org/downloads.html

#!/System/Library/PrivateFrameworks/MacRuby.framework/Versions/A/usr/bin/macrub‌​y

framework 'Cocoa'
require 'date'
require 'fileutils'

Dir.glob(Dir.home() + '/Library/Application Support/Developer/Shared/Archived Applications/*.apparchive').each { |apparchivePath|

  print "Found archive at #{apparchivePath}... "

  archiveInfo = NSDictionary.dictionaryWithContentsOfURL(NSURL.fileURLWithPath(apparchivePath + '/ArchiveInfo.plist')) 

  name = archiveInfo['XCUserProvidedName'] || archiveInfo['XCApplicationName']
  appFilename = archiveInfo['XCApplicationFilename']
  appPath = 'Applications/' + appFilename
  archiveDate = archiveInfo['XCArchivedDate']
  xcarchivePath = Dir.home() + '/Library/Developer/Xcode/Archives/' + archiveDate.strftime('%Y-%m-%d') + '/' + name + ' ' + archiveDate.strftime('%m-%d-%y %I.%M %p') + '.xcarchive'
  appVersion = archiveInfo['CFBundleVersion']
  iconPaths = archiveInfo['XCInfoPlist']['CFBundleIconFiles']
  if not iconPaths
    iconPaths = appPath + '/' + archiveInfo['XCInfoPlist']['CFBundleIconFile']
  else
    iconPaths = archiveInfo['XCInfoPlist']['CFBundleIconFiles'].collect { |f| appPath + '/' + f }
  end

  if File.directory?(xcarchivePath)
    puts 'skipping'
  else
    puts 'importing'
    FileUtils.mkdir_p(xcarchivePath)

    xcarchiveInfo = {
      'ApplicationProperties' => {
        'ApplicationPath' => appPath,
        'CFBundleIdentifier' => archiveInfo['CFBundleIdentifier'],
        'CFBundleShortVersionString' => appVersion,
        'IconPaths' => iconPaths
      },
      'ArchiveVersion' => 1,
      'CreationDate' => archiveDate,
      'Name' => name,
      'SchemeName' => archiveInfo['XCApplicationName']
    }
    if archiveInfo.has_key?('XCUserProvidedComment')
      xcarchiveInfo['Comment'] = archiveInfo['XCUserProvidedComment']
    end
    xcarchiveInfo.writeToURL(NSURL.fileURLWithPath(xcarchivePath + '/Info.plist'), atomically:false)

    FileUtils.mkdir_p(xcarchivePath + '/Products/Applications')
    FileUtils.cp_r(apparchivePath + '/' + appFilename, xcarchivePath + '/Products/Applications')
    FileUtils.mkdir_p(xcarchivePath + '/dSYMs')
    FileUtils.cp_r(apparchivePath + '/' + appFilename + '.dSYM', xcarchivePath + '/dSYMs')
  end
}

Dave Dunkin's script worked great, but I missed the icon and version in some cases. Below a slightly adjusted version of the script. You need to install MacRuby, available here: http://www.macruby.org/downloads.html.

#!/System/Library/PrivateFrameworks/MacRuby.framework/Versions/A/usr/bin/macrub‌​y

framework 'Cocoa'
require 'date'
require 'fileutils'

Dir.glob(Dir.home() + '/Library/Application Support/Developer/Shared/Archived Applications/*.apparchive').each { |apparchivePath|

  print "Found archive at #{apparchivePath}... "

  archiveInfo = NSDictionary.dictionaryWithContentsOfURL(NSURL.fileURLWithPath(apparchivePath + '/ArchiveInfo.plist')) 

  name = archiveInfo['XCUserProvidedName'] || archiveInfo['XCApplicationName']
  appFilename = archiveInfo['XCApplicationFilename']
  appPath = 'Applications/' + appFilename
  archiveDate = archiveInfo['XCArchivedDate']
  xcarchivePath = Dir.home() + '/Library/Developer/Xcode/Archives/' + archiveDate.strftime('%Y-%m-%d') + '/' + name + ' ' + archiveDate.strftime('%m-%d-%y %I.%M %p') + '.xcarchive'
  appVersion = archiveInfo['CFBundleVersion']
  iconPaths = archiveInfo['XCInfoPlist']['CFBundleIconFiles']
  if not iconPaths
    iconPaths = appPath + '/' + archiveInfo['XCInfoPlist']['CFBundleIconFile']
  else
    iconPaths = archiveInfo['XCInfoPlist']['CFBundleIconFiles'].collect { |f| appPath + '/' + f }
  end

  if File.directory?(xcarchivePath)
    puts 'skipping'
  else
    puts 'importing'
    FileUtils.mkdir_p(xcarchivePath)

    xcarchiveInfo = {
      'ApplicationProperties' => {
        'ApplicationPath' => appPath,
        'CFBundleIdentifier' => archiveInfo['CFBundleIdentifier'],
        'CFBundleShortVersionString' => appVersion,
        'IconPaths' => iconPaths
      },
      'ArchiveVersion' => 1,
      'CreationDate' => archiveDate,
      'Name' => name,
      'SchemeName' => archiveInfo['XCApplicationName']
    }
    if archiveInfo.has_key?('XCUserProvidedComment')
      xcarchiveInfo['Comment'] = archiveInfo['XCUserProvidedComment']
    end
    xcarchiveInfo.writeToURL(NSURL.fileURLWithPath(xcarchivePath + '/Info.plist'), atomically:false)

    FileUtils.mkdir_p(xcarchivePath + '/Products/Applications')
    FileUtils.cp_r(apparchivePath + '/' + appFilename, xcarchivePath + '/Products/Applications')
    FileUtils.mkdir_p(xcarchivePath + '/dSYMs')
    FileUtils.cp_r(apparchivePath + '/' + appFilename + '.dSYM', xcarchivePath + '/dSYMs')
  end
}
淡淡的优雅 2024-10-25 02:31:50

这是我为完成此任务而编写的 MacRuby 脚本。

#!/usr/local/bin/macruby

framework 'Cocoa'
require 'date'
require 'fileutils'

Dir.glob(Dir.home() + '/Library/Application Support/Developer/Shared/Archived Applications/*.apparchive').each { |apparchivePath|

  print "Found archive at #{apparchivePath}... "

  archiveInfo = NSDictionary.dictionaryWithContentsOfURL(NSURL.fileURLWithPath(apparchivePath + '/ArchiveInfo.plist')) 

  name = archiveInfo['XCUserProvidedName'] || archiveInfo['XCApplicationName']
  appFilename = archiveInfo['XCApplicationFilename']
  appPath = 'Applications/' + appFilename
  archiveDate = archiveInfo['XCArchivedDate']
  xcarchivePath = Dir.home() + '/Library/Developer/Xcode/Archives/' + archiveDate.strftime('%Y-%m-%d') + '/' + name + ' ' + archiveDate.strftime('%m-%d-%y %I.%M %p') + '.xcarchive'

  if File.directory?(xcarchivePath)
    puts 'skipping'
  else
    puts 'importing'
    FileUtils.mkdir_p(xcarchivePath)

    xcarchiveInfo = {
      'ApplicationProperties' => {
        'ApplicationPath' => appPath,
        'CFBundleIdentifier' => archiveInfo['CFBundleIdentifier'],
        'IconPaths' => archiveInfo['XCInfoPlist']['CFBundleIconFiles'].collect { |f| appPath + '/' + f }
      },
      'ArchiveVersion' => 1,
      'CreationDate' => archiveDate,
      'Name' => name,
      'SchemeName' => archiveInfo['XCApplicationName']
    }
    if archiveInfo.has_key?('XCUserProvidedComment')
      xcarchiveInfo['Comment'] = archiveInfo['XCUserProvidedComment']
    end
    xcarchiveInfo.writeToURL(NSURL.fileURLWithPath(xcarchivePath + '/Info.plist'), atomically:false)

    FileUtils.mkdir_p(xcarchivePath + '/Products/Applications')
    FileUtils.cp_r(apparchivePath + '/' + appFilename, xcarchivePath + '/Products/Applications')
    FileUtils.mkdir_p(xcarchivePath + '/dSYMs')
    FileUtils.cp_r(apparchivePath + '/' + appFilename + '.dSYM', xcarchivePath + '/dSYMs')
  end
}

Here's a MacRuby script I wrote to do this for me.

#!/usr/local/bin/macruby

framework 'Cocoa'
require 'date'
require 'fileutils'

Dir.glob(Dir.home() + '/Library/Application Support/Developer/Shared/Archived Applications/*.apparchive').each { |apparchivePath|

  print "Found archive at #{apparchivePath}... "

  archiveInfo = NSDictionary.dictionaryWithContentsOfURL(NSURL.fileURLWithPath(apparchivePath + '/ArchiveInfo.plist')) 

  name = archiveInfo['XCUserProvidedName'] || archiveInfo['XCApplicationName']
  appFilename = archiveInfo['XCApplicationFilename']
  appPath = 'Applications/' + appFilename
  archiveDate = archiveInfo['XCArchivedDate']
  xcarchivePath = Dir.home() + '/Library/Developer/Xcode/Archives/' + archiveDate.strftime('%Y-%m-%d') + '/' + name + ' ' + archiveDate.strftime('%m-%d-%y %I.%M %p') + '.xcarchive'

  if File.directory?(xcarchivePath)
    puts 'skipping'
  else
    puts 'importing'
    FileUtils.mkdir_p(xcarchivePath)

    xcarchiveInfo = {
      'ApplicationProperties' => {
        'ApplicationPath' => appPath,
        'CFBundleIdentifier' => archiveInfo['CFBundleIdentifier'],
        'IconPaths' => archiveInfo['XCInfoPlist']['CFBundleIconFiles'].collect { |f| appPath + '/' + f }
      },
      'ArchiveVersion' => 1,
      'CreationDate' => archiveDate,
      'Name' => name,
      'SchemeName' => archiveInfo['XCApplicationName']
    }
    if archiveInfo.has_key?('XCUserProvidedComment')
      xcarchiveInfo['Comment'] = archiveInfo['XCUserProvidedComment']
    end
    xcarchiveInfo.writeToURL(NSURL.fileURLWithPath(xcarchivePath + '/Info.plist'), atomically:false)

    FileUtils.mkdir_p(xcarchivePath + '/Products/Applications')
    FileUtils.cp_r(apparchivePath + '/' + appFilename, xcarchivePath + '/Products/Applications')
    FileUtils.mkdir_p(xcarchivePath + '/dSYMs')
    FileUtils.cp_r(apparchivePath + '/' + appFilename + '.dSYM', xcarchivePath + '/dSYMs')
  end
}
時窥 2024-10-25 02:31:50

我只是手工做了一个,所以绝对是可能的,但是超过一两个就很乏味了。只要花点时间,有人就可以编写一个脚本来做到这一点。

.xcarchive 捆绑包只是目录,就像它们之前的 .apparchive 捆绑包一样。新的格式移动了一些内容并简化了顶层 Info.plist

Xcode 3 将存档存储在 ~/Library/Application Support/Developer/Shared/Archived Applications 中。各个存档包被命名为 GUID。每个内部都有 ArchiveInfo.plist、实际的 .app 包和 .dSYM 包。

Xcode 4 将存档存储在 ~/Library/Developer/Xcode/Archives 中,并分成以存档创建日期命名的文件夹。每个日期文件夹中都有 .xcarchive 包,使用可读名称而不是 GUID。其中包含 Info.plist.app 所在的 Products 文件夹以及用于存放 .appdSYMs 文件夹。持有 .dSYM 捆绑包。

.apparchive 复制到 .xcarchive 的一种快速而肮脏的方法:

  1. 使用创建存档的日期创建一个新文件夹。
  2. .apparchive 的内容复制到该新文件夹中以 .xcarchive 结尾的新文件夹中。
  3. cd 进入新的 .xcarchive 文件夹。从现在开始,一切都与此相关。
  4. 创建 ProductsdSYMs 文件夹。
  5. 将您的 .app 包移至 Products 中。
  6. 将您的 .dSYM 包移动到 dSYMs 中。
  7. 删除旧的 ArchiveInfo.plist 文件。
  8. 创建一个如下所示的新 Info.plist,并根据需要进行替换。

(结束列表以便 StackOverflow 正确格式化 XML...)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ApplicationProperties</key>
    <dict>
        <key>ApplicationPath</key>
        <string>AppBundleName.app</string>
        <key>CFBundleIdentifier</key>
        <string>com.example.app-id</string>
        <key>IconPaths</key>
        <array>
            <string>AppBundleName.app/Icon.png</string>
            <string>AppBundleName.app/Icon-Small.png</string>
        </array>
    </dict>
    <key>ArchiveVersion</key>
    <real>1</real>
    <key>CreationDate</key>
    <date>2010-12-15T15:10:34Z</date> <!-- this is a GMT time stamp -->
    <key>Name</key>
    <string>AppName</string>
    <key>SchemeName</key>
    <string>AppName</string>
</dict>
</plist>

I just did one by hand, so it's definitely possible, but tedious for more than one or two. With a bit of time, someone could write a script to do this.

.xcarchive bundles are just directories, like .apparchive bundles before them. The newer format moved some things around and simplified the top level Info.plist.

Xcode 3 stores the archives in ~/Library/Application Support/Developer/Shared/Archived Applications. Individual archive bundles are named as a GUID. Inside each is the ArchiveInfo.plist, the actual .app bundle and the .dSYM bundle.

Xcode 4 stores the archives in ~/Library/Developer/Xcode/Archives, separated into folders named after the date the archive is created. Within each date folder is the .xcarchive bundle, using a readable name instead of a GUID. Within that is the Info.plist, a Products folder where the .app lives, and a dSYMs folder to hold the .dSYM bundles.

A quick-and-dirty way to copy a .apparchive to a .xcarchive:

  1. Create a new folder with the date when the archive was created.
  2. Copy the contents of the .apparchive into a new folder ending with .xcarchive inside that new folder.
  3. cd into that new .xcarchive folder. Everything is relative to that from this point forward.
  4. Create Products and dSYMs folders.
  5. Move your .app bundle into Products.
  6. Move your .dSYM bundle into dSYMs.
  7. Remove the old ArchiveInfo.plist file.
  8. Create a new Info.plist that looks like this, substituting as appropriate.

(ending the list so StackOverflow formats the XML properly...)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ApplicationProperties</key>
    <dict>
        <key>ApplicationPath</key>
        <string>AppBundleName.app</string>
        <key>CFBundleIdentifier</key>
        <string>com.example.app-id</string>
        <key>IconPaths</key>
        <array>
            <string>AppBundleName.app/Icon.png</string>
            <string>AppBundleName.app/Icon-Small.png</string>
        </array>
    </dict>
    <key>ArchiveVersion</key>
    <real>1</real>
    <key>CreationDate</key>
    <date>2010-12-15T15:10:34Z</date> <!-- this is a GMT time stamp -->
    <key>Name</key>
    <string>AppName</string>
    <key>SchemeName</key>
    <string>AppName</string>
</dict>
</plist>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文