Skip to content

Instantly share code, notes, and snippets.

@AKosmachyov
Created November 8, 2021 09:30
Show Gist options
  • Save AKosmachyov/e0cb860435a44a41e88ffee4dfdf4b26 to your computer and use it in GitHub Desktop.
Save AKosmachyov/e0cb860435a44a41e88ffee4dfdf4b26 to your computer and use it in GitHub Desktop.
Ad Hoc Distribution server

Xcode:

  1. Product (on the top menu) -> Archive
  2. Window -> Organizer
  3. Select archive
  4. Distribute App
  5. Developemnt enter app url: https:///apps/.ipa enter dispaly image url: https:///apps/57x57.png enter full size image url: https:///apps/512x512.png
  6. Move Apps folder from the Archive folder to the server.js folder
  7. Add 57x57 and 512x512 images in the Apps folder
  8. Use https://ngrok.com to link localhost with public url
ar http = require('http');
var fs = require('fs');
var path = require('path');
http.createServer(function (request, response) {
var filePath = '.' + request.url;
if (filePath == './')
filePath = './index.html';
var ip = request.headers['x-forwarded-for'] || req.socket.remoteAddress || null;
console.log('Request', filePath, 'User ip', ip);
var extname = path.extname(filePath);
var contentType = 'text/html';
switch (extname) {
case '.js':
contentType = 'text/javascript';
break;
case '.css':
contentType = 'text/css';
break;
case '.json':
contentType = 'application/json';
break;
case '.png':
contentType = 'image/png';
break;
case '.jpg':
contentType = 'image/jpg';
break;
case '.wav':
contentType = 'audio/wav';
break;
case '.ipa':
contentType = 'application/octet-stream';
break;
case '.plist':
contentType = 'text/xml';
break;
}
fs.readFile(filePath, function(error, content) {
if (error) {
if(error.code == 'ENOENT'){
fs.readFile('./404.html', function(error, content) {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
});
}
else {
console.log('error', error)
response.writeHead(500);
response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
response.end();
}
}
else {
response.writeHead(200, { 'Content-Type': contentType });
response.end(content, 'utf-8');
}
});
}).listen(8125);
console.log('Server running at http://127.0.0.1:8125/');
console.log('Use a link on iOS device to download app:');
console.log('itms-services://?action=download-manifest&url=https://<YOUR IP ADDRESS>:8125/manifest.plist');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment