Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): added xcworkspacedata file generation #11245

Merged
merged 8 commits into from
Oct 17, 2019
8 changes: 7 additions & 1 deletion iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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));
Expand Down
33 changes: 7 additions & 26 deletions iphone/cli/hooks/run.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable security/detect-non-literal-regexp */

/*
* run.js: Titanium iOS CLI run hook
*
Expand Down Expand Up @@ -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) {
Expand All @@ -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 <log-server-port> between 1024 and 65535 in the <ios> 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();
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions support/iphone/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down