Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we import .apparchive bundles in Xcode 4

Tags:

xcode

ios

archive

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?

like image 673
Christian Lemer Avatar asked Feb 20 '11 21:02

Christian Lemer


2 Answers

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
}
like image 157
Johan Kool Avatar answered Nov 04 '22 07:11

Johan Kool


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
}
like image 43
Dave Dunkin Avatar answered Nov 04 '22 08:11

Dave Dunkin