0
votes

I have a problem with re-sign IPA files with PHP

this is my code:

<?php
/*
unzip app.ipa

rm -rf Payload/MyApp.app/_CodeSignature/

cp ~/Downloads/AdHoc.mobileprovision Payload/MyApp.app/embedded.mobileprovision

codesign -f -s "iPhone Distribution: Company Certificate" --resource-rules Payload/MyApp.app/ResourceRules.plist  Payload/MyApp.app

zip -qr app-resigned.ipa Payload/
*/

if(file_exists('app.ipa')) {
    rename('app.ipa', 'app.zip');
    $zip = new ZipArchive;
    $res = $zip->open('app.zip');
    if ($res === TRUE) {
      $zip->extractTo('C:/Users/abdul/Dropbox/127.0.0.1/ios');
      $zip->close();
    }
}


// remove _CodeSignature
if(file_exists('Payload/Gab.ai ObjC.app/_CodeSignature')) {
    $dir = 'Payload/Gab.ai ObjC.app/_CodeSignature';
    $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
    $files = new RecursiveIteratorIterator($it,
                 RecursiveIteratorIterator::CHILD_FIRST);
    foreach($files as $file) {
        if ($file->isDir()){
            rmdir($file->getRealPath());
        } else {
            unlink($file->getRealPath());
        }
    }
    rmdir($dir);
}

unlink('Payload/Gab.ai ObjC.app/embedded.mobileprovision');

// copy mobileprovision file
copy('embedded.mobileprovision', 'Payload/Gab.ai ObjC.app/embedded.mobileprovision');


// i think there is a problem here!
exec('codesign -f -s "iPhone Distribution: ****" --resource-rules Payload/Gab.ai ObjC.app/ResourceRules.plist  Payload/Gab.ai ObjC.app');
?>

i have the app.ipa, embedded.mobileprovision and my Distribution.

but i think the problem with exec while using codesign it dose not create _CodeSignature folder !!

i don't have any idea about that codesign.

is there any one can help me?

1
php.net/manual/en/function.exec.php -- for debugging, you should add the $output and $return_var and then echo the results. Edit your question to include the results. - Dave S

1 Answers

0
votes

First of all, "codesign" binary will work only on OSX.

The other issue that you are having is due to permission limitation. you need to chmod the php script as well as the out put folder "the ipas Working directory".

i know my reply is too late, i just saw the post and though to mention the solution as i had it before and it was fixed.

Good luck