diff --git a/iphone/cli/commands/_build.js b/iphone/cli/commands/_build.js index a462937085d..8b8967db2fd 100644 --- a/iphone/cli/commands/_build.js +++ b/iphone/cli/commands/_build.js @@ -2514,7 +2514,7 @@ iOSBuilder.prototype.findProvisioningProfile = function findProvisioningProfile( iOSBuilder.prototype.determineLogServerPort = function determineLogServerPort(next) { this.tiLogServerPort = 0; - if (/^dist-(appstore|adhoc)$/.test(this.target)) { + if (this.target !== 'device') { // we don't allow the log server in production return next(); } @@ -3090,6 +3090,7 @@ iOSBuilder.prototype.createXcodeProject = function createXcodeProject(next) { // set additional build settings if (this.target === 'simulator') { + gccDefs.push('__LOG__ID__=' + this.tiapp.guid); gccDefs.push('DEBUG=1'); gccDefs.push('TI_VERSION=' + this.titaniumSdkVersion); } @@ -4596,6 +4597,11 @@ iOSBuilder.prototype.copyTitaniumiOSFiles = function copyTitaniumiOSFiles() { path.join(this.platformPath, 'iphone', 'Titanium.xcodeproj', 'xcshareddata', 'xcschemes', 'Titanium.xcscheme'), path.join(this.buildDir, this.tiapp.name + '.xcodeproj', 'xcshareddata', 'xcschemes', name + '.xcscheme') ); + copyAndReplaceFile.call( + this, + path.join(this.platformPath, 'iphone', 'Titanium.xcodeproj', 'project.xcworkspace', 'contents.xcworkspacedata'), + path.join(this.buildDir, this.tiapp.name + '.xcodeproj', 'project.xcworkspace', 'contents.xcworkspacedata') + ); if (this.enableLaunchScreenStoryboard && this.defaultLaunchScreenStoryboard) { this.logger.info(__('Installing default %s', 'LaunchScreen.storyboard'.cyan)); diff --git a/iphone/cli/hooks/run.js b/iphone/cli/hooks/run.js index 60746ea2392..2a11e51d7fb 100644 --- a/iphone/cli/hooks/run.js +++ b/iphone/cli/hooks/run.js @@ -1,3 +1,5 @@ +/* eslint-disable security/detect-non-literal-regexp */ + /* * run.js: Titanium iOS CLI run hook * @@ -35,7 +37,8 @@ exports.init = function (logger, config, cli) { const startLogTxt = __('Start simulator log'), endLogTxt = __('End simulator log'), levels = logger.getLevels(), - logLevelRE = new RegExp('^(\u001b\\[\\d+m)?\\[?(' + levels.join('|') + '|log|timestamp)\\]?\\s*(\u001b\\[\\d+m)?(.*)', 'i'); // eslint-disable-line security/detect-non-literal-regexp + trimRE = new RegExp('^.*' + builder.tiapp.name + '\\[[^\\]]+\\]\\s*', 'g'), + logLevelRE = new RegExp('^(\u001b\\[\\d+m)?\\[?(' + levels.join('|') + '|log|timestamp)\\]?\\s*(\u001b\\[\\d+m)?(.*)', 'i'); function endLog() { if (simStarted) { @@ -52,40 +55,18 @@ exports.init = function (logger, config, cli) { launchBundleId: cli.argv['launch-bundle-id'], launchWatchApp: builder.hasWatchApp && cli.argv['launch-watch-app'], launchWatchAppOnly: builder.hasWatchApp && cli.argv['launch-watch-app-only'], - logServerPort: builder.tiLogServerPort, + logFilename: builder.tiapp.guid + '.log', watchHandleOrUDID: builder.watchSimHandle, watchAppName: cli.argv['watch-app-name'] }) .on('log-file', function (line) { // Titanium app log messages - let skipLine = false; - if (!simStarted) { - if (line.indexOf('{') === 0) { - try { - const headers = JSON.parse(line); - if (headers.appId !== builder.tiapp.id) { - logger.error(__('Another Titanium app "%s" is currently running and using the log server port %d', headers.appId, builder.tiLogServerPort)); - logger.error(__('Stop the running Titanium app, then rebuild this app')); - logger.error(__('-or-')); - logger.error(__('Set a unique between 1024 and 65535 in the section of the tiapp.xml') + '\n'); - process.exit(1); - } - } catch (e) { - // squeltch - } - skipLine = true; - } - simStarted = true; logger.log(('-- ' + startLogTxt + ' ' + (new Array(75 - startLogTxt.length)).join('-')).grey); } - - if (skipLine) { - return; - } - - const m = line.match(logLevelRE); + line = line.replace(trimRE, ''); + var m = line.match(logLevelRE); if (m) { lastLogger = m[2].toLowerCase(); line = m[4].trim(); diff --git a/iphone/iphone/Titanium.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iphone/iphone/Titanium.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000000..919434a6254 --- /dev/null +++ b/iphone/iphone/Titanium.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/support/iphone/main.m b/support/iphone/main.m index c8d169153f2..4d66910700d 100644 --- a/support/iphone/main.m +++ b/support/iphone/main.m @@ -60,11 +60,19 @@ int main(int argc, char *argv[]) alpha:1.0f]; #endif [[TiSharedConfig defaultConfig] setDefaultBackgroundColor:defaultBgColor]; - + #if defined(DEBUG) || defined(DEVELOPER) [[TiSharedConfig defaultConfig] setDebugEnabled:YES]; #endif - + +#ifdef __LOG__ID__ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + NSString *logPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%s.log", STRING(__LOG__ID__)]]; + freopen([logPath cStringUsingEncoding:NSUTF8StringEncoding], "w+", stderr); + fprintf(stderr, "[INFO] Application started\n"); +#endif + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, @"TiUIApplication", @"TiApp"); [pool release];