Last active
September 18, 2015 14:26
-
-
Save lucien144/488c2843824ba092dbd5 to your computer and use it in GitHub Desktop.
Packaging Adobe Air app for iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$appName = 'FILENAME'; | |
$adt = '/Applications/AIRSDK_Compiler/18/bin/adt'; | |
$target = 'ipa-app-store'; | |
$connect = ''; | |
$descriptor = 'application-testflight.xml'; | |
$cert = './cert/iOS/CERT.p12'; | |
$content = 'bin'; | |
$lib = './lib'; | |
$certPasshprase = '*****'; | |
$provisioning = './cert/iOS/CERT.mobileprovision'; | |
$sdk = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk'; | |
$shortopts = ""; | |
$shortopts .= "h"; // Help | |
$shortopts .= "d"; // Compile as debug? | |
$shortopts .= "c::"; // Demo, no value | |
$shortopts .= "v:"; // Build with a specific version code? | |
$shortopts .= "p:"; // Change provisioning progile? | |
$options = getopt($shortopts); | |
foreach ($options as $key => $value) { | |
switch ($key) { | |
case "h": | |
echo "Usage: php run.php [options]\n"; | |
echo " -c<content dir>\tDirectory with content. Default is: bin.\n"; | |
echo " -v<number>\t\tReset the descriptors version number.\n"; | |
echo " -p<filename>\t\tThe new name of provisioning profile without the '.mobileprovision' extension.\n"; | |
echo " -d\t\t\tBuild as debug.\n"; | |
echo " -h\t\t\tThis help.\n"; | |
exit; | |
break; | |
case 'c': | |
if (is_dir(__DIR__ . '/' . $value)) { | |
$content = $value; | |
echo "-> The content folder set to directory {$content}.\n"; | |
} else { | |
echo "-> The content folder {$value} not exists. Set to default directory {$content}.\n"; | |
} | |
break; | |
case 'd': | |
$target = 'ipa-debug'; | |
$connect = '-connect 192.168.0.170'; | |
echo "-> DEBUG package...\n"; | |
break; | |
case 'v': | |
if (preg_match('/^([0-9]*)\.([0-9]*)\.([0-9]*)$/', $value)) { | |
$newVersion = $value; | |
echo "-> Setting the version number manualy to: {$value}.\n"; | |
} else { | |
echo "-> Wrong version number. Increasing the descriptor's version by +1.\n"; | |
} | |
break; | |
case 'p': | |
if (is_file(__DIR__ . "/cert/iOS/{$value}.mobileprovision")) { | |
$provisioning = "./cert/iOS/{$value}.mobileprovision"; | |
echo "-> Setting the provisioning profile manually to: {$provisioning}.\n"; | |
} else { | |
echo "-> Wrong provisioning profile. Using default: {$provisioning}.\n"; | |
} | |
break; | |
} | |
}; | |
/** | |
* Getting the version | |
*/ | |
$desc = file_get_contents("{$content}/{$descriptor}"); | |
preg_match('/<versionNumber>([0-9]*)\.([0-9]*)\.([0-9]*)<\/versionNumber>/', $desc, $matches); | |
if (!isset($newVersion)) { | |
$newVersion = "<versionNumber>{$matches[1]}.{$matches[2]}.". ($matches[3] + 1) ."</versionNumber>"; | |
} else { | |
$newVersion = "<versionNumber>{$newVersion}</versionNumber>"; | |
} | |
$desc = preg_replace('/(<versionNumber>([0-9]*)\.([0-9]*)\.([0-9]*)<\/versionNumber>)/', $newVersion, $desc); | |
file_put_contents("{$content}/{$descriptor}", $desc); | |
preg_match('/<id>(.*)<\/id>/', $desc, $idMatches); | |
$appId = $idMatches[1]; | |
$ipa = "{$appId}_{$target}_{$matches[1]}.{$matches[2]}.". ($matches[3] + 1) .".ipa"; | |
echo passthru("{$adt} -package -target {$target} {$connect} -storetype pkcs12 -keystore {$cert} -storepass {$certPasshprase} -provisioning-profile {$provisioning} ${ipa} {$content}/{$descriptor} -C {$content} . -extdir {$lib} -platformsdk {$sdk}"); | |
exec('rm -fR ./*.tmp'); | |
exec('rm -fR ./*.dSYM'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/php | |
<?php | |
/** | |
* The IPA filename | |
*/ | |
$ipa = 'bundleid.ipa'; | |
/** | |
* The APP filename in /Payload directory | |
*/ | |
$filename = 'My.app'; | |
/** | |
* Certificate name as you have it | |
*/ | |
$certificateName = 'Distribution: Company'; | |
exec("unzip {$ipa}"); | |
exec("rm -r \"Payload/{$filename}/_CodeSignature\" \"Payload/{$filename}/CodeResources\" 2> /dev/null | true"); | |
$plist = file_get_contents("Payload/{$filename}/Info.plist"); | |
preg_match("/<key>UIRequiredDeviceCapabilities([\s\S]*?)<\/array>/i", $plist, $matches); | |
$plist = str_replace($matches[0], "", $plist); | |
file_put_contents("Payload/{$filename}/Info.plist", $plist); | |
exec("/usr/bin/codesign -f -s \"{$certificateName}\" \"Payload/{$filename}\""); | |
chdir("Payload/{$filename}/"); | |
exec("ln -s _CodeSignature/CodeResources CodeResources"); | |
chdir("../../"); | |
exec("zip --symlinks -qr \"{$ipa}-resigned.ipa\" Payload"); | |
exec("rm -fR Payload"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/php | |
<?php | |
$adl = '/Applications/AIRSDK_Compiler/18/bin/adl'; | |
$descriptor = 'application-run.xml'; | |
$screen = 'SamsungGalaxyS'; | |
$screens = 'iPhone|iPhoneRetina|iPhone5Retina|iPhone6|iPhone6Plus|iPod|iPodRetina|iPod5Retina|iPad|iPadRetina|Droid|NexusOne|SamsungGalaxyS|SamsungGalaxyTab|QVGA|WQVGA|FWQVGA|HVGA|WVGA|FWVGA|1080|720|480'; | |
$content = 'bin'; | |
$shortopts = ""; | |
$shortopts .= "h"; // Help | |
$shortopts .= "s::"; // Screen, optional value | |
$shortopts .= "c::"; // Demo, no value | |
$options = getopt($shortopts); | |
foreach ($options as $key => $value) { | |
switch ($key) { | |
case "h": | |
echo "Usage: php run.php [options]\n"; | |
echo " -s<screen>\t\tScreen name. Default is: SamsungGalaxyS\n"; | |
echo " -c<content dir>\tDirectory with content. Default is: bin.\n"; | |
echo " -h\t\t\tThis help.\n"; | |
exit; | |
break; | |
case 's': | |
$screens = explode("|", $screens); | |
if (in_array($value, $screens)) { | |
$screen = $value; | |
echo "-> Screen set to {$screen}.\n"; | |
} else { | |
echo "-> Unknown screen {$value}. Set to default {$screen}.\n"; | |
} | |
break; | |
case 'c': | |
if (is_dir(__DIR__ . '/' . $value)) { | |
$content = $value; | |
echo "-> The content folder set to directory {$content}.\n"; | |
} else { | |
echo "-> The content folder {$value} not exists. Set to default directory {$content}.\n"; | |
} | |
break; | |
} | |
}; | |
echo passthru("$adl -screensize $screen -nodebug {$content}/{$descriptor} {$content}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment