{"id":6656,"date":"2023-10-05T12:39:20","date_gmt":"2023-10-05T04:39:20","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=6656"},"modified":"2023-10-05T12:39:20","modified_gmt":"2023-10-05T04:39:20","slug":"php%e8%8b%b9%e6%9e%9c%e7%ad%be%e5%90%8d%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2023\/10\/05\/php%e8%8b%b9%e6%9e%9c%e7%ad%be%e5%90%8d%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e7%9a%84%ef%bc%9f\/","title":{"rendered":"php\u82f9\u679c\u7b7e\u540d\u5982\u4f55\u5b9e\u73b0\u7684\uff1f"},"content":{"rendered":"
PHP\u82f9\u679c\u7b7e\u540d\u662f\u6307\u4f7f\u7528PHP\u7f16\u7a0b\u8bed\u8a00\u6765\u5b9e\u73b0\u5bf9\u82f9\u679c\u5e94\u7528\u8fdb\u884c\u7b7e\u540d\u7684\u64cd\u4f5c\u3002\u82f9\u679c\u7b7e\u540d\u662f\u4e00\u79cd\u5bf9\u5e94\u7528\u8fdb\u884c\u6570\u5b57\u7b7e\u540d\u7684\u65b9\u5f0f\uff0c\u7528\u4e8e\u9a8c\u8bc1\u5e94\u7528\u7684\u5b89\u5168\u6027\u548c\u5b8c\u6574\u6027\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdPHP\u82f9\u679c\u7b7e\u540d\u7684\u539f\u7406\u548c\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n
1. \u82f9\u679c\u7b7e\u540d\u7684\u539f\u7406<\/p>\n
\u82f9\u679c\u7b7e\u540d\u662f\u901a\u8fc7\u4f7f\u7528Apple\u63d0\u4f9b\u7684\u5bc6\u94a5\u548c\u8bc1\u4e66\u6765\u5bf9\u5e94\u7528\u8fdb\u884c\u6570\u5b57\u7b7e\u540d\u3002\u6bcf\u4e2a\u5e94\u7528\u90fd\u6709\u4e00\u4e2a\u7279\u5b9a\u7684Bundle ID\uff0c\u4f7f\u7528\u79c1\u94a5\u5bf9\u5e94\u7528\u8fdb\u884c\u7b7e\u540d\u540e\uff0c\u751f\u6210\u4e00\u4e2aProvisioning Profile\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u5e94\u7528\u7684\u7b7e\u540d\u4fe1\u606f\u548c\u8bc1\u4e66\u3002\u5f53\u7528\u6237\u8fdb\u884c\u5e94\u7528\u5b89\u88c5\u65f6\uff0c\u7cfb\u7edf\u4f1a\u9a8c\u8bc1\u5e94\u7528\u7684\u7b7e\u540d\u548c\u8bc1\u4e66\uff0c\u786e\u4fdd\u5e94\u5b89\u5353\u624b\u673a\u5b89\u88c5\u5305\u7b7e\u540d\u4e0d\u4e00\u81f4\u662f\u4ec0\u4e48\u610f\u601d<\/a>\u7528\u6765\u6e90\u53ef\u9760\u3002<\/p>\n 2. PHP\u82f9\u679c\u7b7e\u540d\u7684\u5b9e\u73b0\u65b9\u6cd5<\/p>\n \u4e0b\u9762\u662f\u4e00\u4e2a\u4f7f\u7528PHP\u5b9e\u73b0\u82f9\u679c\u7b7e\u540d\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n “`php<\/p>\n<\/p>\n function signApp($appPath, $provisioningProfilePath, $certificatePath, $keyPath, $keyPassword) {<\/p>\n \/\/ \u8bfb\u53d6\u5e94\u7528\u6587\u4ef6\u548c\u7b7e\u540d\u6587\u4ef6<\/p>\n $appContent = file_get_contents($appPath);<\/p>\n $provisioningProfileContent = file_get_contents($provisioningProfilePath);<\/p>\n<\/p>\n \/\/ \u521b\u5efa\u4e00\u4e2a\u4e34\u65f6\u76ee\u5f55<\/p>\n $tempDir = tempnam(sys_get_temp_dir(), ‘sign’);<\/p>\n unlink($tempDir);<\/p>\n mkdir($tempDir);<\/p>\n<\/p>\n \/\/ \u5c06\u5e94\u7528\u6587\u4ef6\u548c\u7b7e\u540d\u6587\u4ef6\u590d\u5236\u5230\u4e34\u65f6\u76ee\u5f55\u4e0b<\/p>\n $appCopyPath = $tempDir . ‘\/app.ipa’;<\/p>\n $provisioningProfileCopyPath = $tempDir . ‘\/provisioning.mobileprovision’;<\/p>\n file_put_contents($appCopyPath, $appContent);<\/p>\n file_put_contents($provisioningProfileCopyPath, $provisioningProfileContent);<\/p>\n<\/p>\n \/\/ \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177codesign\u5bf9\u5e94\u7528\u8fdb\u884c\u7b7e\u540d<\/p>\n $command = “codesign -f -s \\”$certificatePath\\” –keychain \\”$keyPath\\” –keychain-password \\”$keyPassword\\” –entitlements \\”$provisioningProfileCopyPath\\” \\”$appCopyPath\\””;<\/p>\n exec($command, $output, $result);<\/p>\n<\/p>\n \/\/ \u5982\u679c\u7b7e\u540d\u6210\u529f\uff0c\u5219\u5c06\u7b7e\u540d\u540e\u7684\u5e94\u7528\u6587\u4ef6\u4fdd\u5b58\u5230\u6307\u5b9a\u8def\u5f84<\/p>\n if ($result == 0) {<\/p>\n