Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions iphone/Classes/AppModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#import <UIKit/UILocalNotification.h>
#import <unistd.h>

extern NSString *const TI_APPLICATION_DEPLOYTYPE;
extern NSString *const TI_APPLICATION_DEPLOY_TYPE;
extern NSString *const TI_APPLICATION_ID;
extern NSString *const TI_APPLICATION_PUBLISHER;
extern NSString *const TI_APPLICATION_URL;
Expand Down Expand Up @@ -577,7 +577,7 @@ - (id)guid

- (id)deployType
{
return TI_APPLICATION_DEPLOYTYPE;
return TI_APPLICATION_DEPLOY_TYPE;
}

- (id)sessionId
Expand Down
63 changes: 37 additions & 26 deletions iphone/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class iOSBuilder extends Builder {

// macros used as preprocessor in project.xcconfig file
this.gccDefs = new Map();
this.swiftConds = [];
this.tiSymbolMacros = null;
}

Expand Down Expand Up @@ -3305,27 +3306,22 @@ class iOSBuilder extends Builder {
},
legacySwift = version.lt(this.xcodeEnv.version, '8.0.0');

this.gccDefs.set('DEPLOYTYPE', this.deployType);
// set additional build settings
if (this.target === 'simulator' || this.target === 'macos') {
this.gccDefs.set('__LOG__ID__', this.tiapp.guid);
this.gccDefs.set('LOGTOFILE', 1);
this.swiftConds.push('LOGTOFILE');
this.gccDefs.set('DEBUG', 1);
this.swiftConds.push('DEBUG');
}

if (this.enableLaunchScreenStoryboard) {
this.gccDefs.set('LAUNCHSCREEN_STORYBOARD', 1);
}

if (this.defaultBackgroundColor) {
this.gccDefs.set('DEFAULT_BGCOLOR_RED', this.defaultBackgroundColor.red);
this.gccDefs.set('DEFAULT_BGCOLOR_GREEN', this.defaultBackgroundColor.green);
this.gccDefs.set('DEFAULT_BGCOLOR_BLUE', this.defaultBackgroundColor.blue);
this.swiftConds.push('LAUNCHSCREEN_STORYBOARD');
}

if (this.tiLogServerPort === 0) {
this.gccDefs.set('DISABLE_TI_LOG_SERVER', 1);
} else {
this.gccDefs.set('TI_LOG_SERVER_PORT', this.tiLogServerPort);
this.swiftConds.push('DISABLE_TI_LOG_SERVER');
}

if (/device|dist-appstore|dist-adhoc/.test(this.target)) {
Expand Down Expand Up @@ -4602,22 +4598,36 @@ class iOSBuilder extends Builder {
const origSrc = await fs.readFile(srcFile, 'utf8');

// replace templated values
const consts = {
__PROJECT_NAME__: this.tiapp.name,
__PROJECT_ID__: this.tiapp.id,
__DEPLOYTYPE__: this.deployType,
__SHOW_ERROR_CONTROLLER__: this.showErrorController,
__APP_ID__: this.tiapp.id,
__APP_PUBLISHER__: this.tiapp.publisher,
__APP_URL__: this.tiapp.url,
__APP_NAME__: this.tiapp.name,
__APP_VERSION__: this.tiapp.version,
__APP_DESCRIPTION__: this.tiapp.description,
__APP_COPYRIGHT__: this.tiapp.copyright,
__APP_GUID__: this.tiapp.guid,
__APP_RESOURCE_DIR__: '',
__APP_DEPLOY_TYPE__: this.buildType
let consts = {
__PROJECT_NAME__: this.tiapp.name,
__PROJECT_ID__: this.tiapp.id,
__DEPLOY_TYPE__: this.deployType,
__SHOW_ERROR_CONTROLLER__: this.showErrorController,
__APP_ID__: this.tiapp.id,
__APP_PUBLISHER__: this.tiapp.publisher,
__APP_URL__: this.tiapp.url,
__APP_NAME__: this.tiapp.name,
__APP_VERSION__: this.tiapp.version,
__APP_DESCRIPTION__: this.tiapp.description,
__APP_COPYRIGHT__: this.tiapp.copyright,
__APP_GUID__: this.tiapp.guid,
__APP_RESOURCE_DIR__: '',
__BUILD_TYPE__: this.buildType,
__TI_LOG_SERVER_PORT__: this.tiLogServerPort
};
if (this.defaultBackgroundColor) {
Object.assign(consts, {
__APP_DEFAULT_BGCOLOR_RED__: this.defaultBackgroundColor.red,
__APP_DEFAULT_BGCOLOR_GREEN__: this.defaultBackgroundColor.green,
__APP_DEFAULT_BGCOLOR_BLUE__: this.defaultBackgroundColor.blue
});
} else {
Object.assign(consts, {
__APP_DEFAULT_BGCOLOR_RED__: 0.0,
__APP_DEFAULT_BGCOLOR_GREEN__: 0.0,
__APP_DEFAULT_BGCOLOR_BLUE__: 0.0
});
}
const contents = origSrc.replace(/(__.+?__)/g, function (match, key) {
const s = Object.prototype.hasOwnProperty.call(consts, key) ? consts[key] : key;
return typeof s === 'string' ? s.replace(/"/g, '\\"').replace(/\n/g, '\\n') : s;
Expand Down Expand Up @@ -4651,7 +4661,8 @@ class iOSBuilder extends Builder {
'OTHER_LDFLAGS[sdk=iphonesimulator*]=$(inherited) $(JSCORE_LD_FLAGS)',
'OTHER_LDFLAGS[sdk=iphoneos9.*]=$(inherited) -weak_framework Contacts -weak_framework ContactsUI -weak_framework WatchConnectivity -weak_framework CoreSpotlight',
'OTHER_LDFLAGS[sdk=iphonesimulator9.*]=$(inherited) -weak_framework Contacts -weak_framework ContactsUI -weak_framework WatchConnectivity -weak_framework CoreSpotlight',
'GCC_DEFINITIONS=' + Array.from(this.gccDefs.entries()).map(function ([ key, value ]) { return key + '=' + value; }).join(' '),
'GCC_DEFINITIONS=' + Array.from(this.gccDefs.entries()).map(([ key, value ]) => { return key + '=' + value; }).join(' '),
'SWIFT_CONDITIONS=' + this.swiftConds.join(' '),
'TI_SYMBOL_MACROS=' + this.tiSymbolMacros,
'#include "module"'
].join('\n') + '\n';
Expand Down
4 changes: 2 additions & 2 deletions iphone/iphone/Titanium.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2545,7 +2545,7 @@
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(GCC_DEFINITIONS) $(TI_SYMBOL_MACROS)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(SWIFT_CONDITIONS) $(TI_SYMBOL_MACROS)";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -2607,7 +2607,7 @@
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(GCC_DEFINITIONS) $(TI_SYMBOL_MACROS)";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(SWIFT_CONDITIONS) $(TI_SYMBOL_MACROS)";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand Down
23 changes: 10 additions & 13 deletions iphone/iphone/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@
#import <TitaniumKit/TiSharedConfig.h>
#import <UIKit/UIKit.h>

#ifndef TI_LOG_SERVER_PORT
#define TI_LOG_SERVER_PORT 10571
#endif

// NOTE: this main is only used inside Xcode. In the real SDK, it's
// automatically replaced and built on the fly - when running in
// Xcode give some reasonable values

NSString *const TI_APPLICATION_DEPLOYTYPE = @"development";
NSString *const TI_APPLICATION_DEPLOY_TYPE = @"development";
NSString *const TI_APPLICATION_ID = @"com.tidev.kitchensink.xcode";
NSString *const TI_APPLICATION_PUBLISHER = @"TiDev, Inc";
NSString *const TI_APPLICATION_URL = @"https://titaniumsdk.com";
Expand All @@ -34,6 +30,10 @@
NSString *const TI_APPLICATION_RESOURCE_DIR = @"";
#endif
NSString *const TI_APPLICATION_BUILD_TYPE = @"";
NSUInteger const TI_LOG_SERVER_PORT = 10571;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_RED = 1.0f;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_GREEN = 1.0f;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_BLUE = 1.0f;

// Currently unused
NSString *const TI_APPLICATION_SDK_VERSION = @"8.0.0";
Expand All @@ -42,7 +42,7 @@

int main(int argc, char *argv[])
{
[[TiSharedConfig defaultConfig] setApplicationDeployType:TI_APPLICATION_DEPLOYTYPE];
[[TiSharedConfig defaultConfig] setApplicationDeployType:TI_APPLICATION_DEPLOY_TYPE];
[[TiSharedConfig defaultConfig] setApplicationID:TI_APPLICATION_ID];
[[TiSharedConfig defaultConfig] setApplicationPublisher:TI_APPLICATION_PUBLISHER];
[[TiSharedConfig defaultConfig] setApplicationURL:[NSURL URLWithString:TI_APPLICATION_URL]];
Expand All @@ -61,13 +61,10 @@ int main(int argc, char *argv[])
[[TiLogServer defaultLogServer] setPort:TI_LOG_SERVER_PORT];
#endif

UIColor *defaultBgColor = UIColor.blackColor;
#if defined(DEFAULT_BGCOLOR_RED) && defined(DEFAULT_BGCOLOR_GREEN) && defined(DEFAULT_BGCOLOR_BLUE)
defaultBgColor = [UIColor colorWithRed:DEFAULT_BGCOLOR_RED
green:DEFAULT_BGCOLOR_GREEN
blue:DEFAULT_BGCOLOR_BLUE
alpha:1.0f];
#endif
UIColor *defaultBgColor = [UIColor colorWithRed:TI_APPLICATION_DEFAULT_BGCOLOR_RED
green:TI_APPLICATION_DEFAULT_BGCOLOR_GREEN
blue:TI_APPLICATION_DEFAULT_BGCOLOR_BLUE
alpha:1.0f];
[[TiSharedConfig defaultConfig] setDefaultBackgroundColor:defaultBgColor];
#if defined(DEBUG) || defined(DEVELOPER)
[[TiSharedConfig defaultConfig] setDebugEnabled:YES];
Expand Down
32 changes: 13 additions & 19 deletions support/iphone/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
#import <TitaniumKit/TiApp.h>
#import <TitaniumKit/TiLogServer.h>
#import <TitaniumKit/TiSharedConfig.h>
#define _QUOTEME(x) #x
#define STRING(x) _QUOTEME(x)

#ifndef TI_LOG_SERVER_PORT
#define TI_LOG_SERVER_PORT 10571
#endif

NSString *const TI_APPLICATION_DEPLOYTYPE = @"__DEPLOYTYPE__";
NSString *const TI_APPLICATION_DEPLOY_TYPE = @"__DEPLOY_TYPE__";
NSString *const TI_APPLICATION_ID = @"__APP_ID__";
NSString *const TI_APPLICATION_PUBLISHER = @"__APP_PUBLISHER__";
NSString *const TI_APPLICATION_URL = @"__APP_URL__";
Expand All @@ -23,15 +17,18 @@
NSString *const TI_APPLICATION_COPYRIGHT = @"__APP_COPYRIGHT__";
NSString *const TI_APPLICATION_GUID = @"__APP_GUID__";
BOOL const TI_APPLICATION_SHOW_ERROR_CONTROLLER = __SHOW_ERROR_CONTROLLER__;
NSString *const TI_APPLICATION_BUILD_TYPE = @"__APP_DEPLOY_TYPE__";

NSString *const TI_APPLICATION_BUILD_TYPE = @"__BUILD_TYPE__";
#ifdef TARGET_OS_SIMULATOR
NSString *const TI_APPLICATION_RESOURCE_DIR = @"__APP_RESOURCE_DIR__";
#endif
NSUInteger const TI_LOG_SERVER_PORT = __TI_LOG_SERVER_PORT__ ? __TI_LOG_SERVER_PORT__ : 10571;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_RED = __APP_DEFAULT_BGCOLOR_RED__;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_GREEN = __APP_DEFAULT_BGCOLOR_GREEN__;
CGFloat const TI_APPLICATION_DEFAULT_BGCOLOR_BLUE = __APP_DEFAULT_BGCOLOR_BLUE__;

int main(int argc, char *argv[])
{
[[TiSharedConfig defaultConfig] setApplicationDeployType:TI_APPLICATION_DEPLOYTYPE];
[[TiSharedConfig defaultConfig] setApplicationDeployType:TI_APPLICATION_DEPLOY_TYPE];
[[TiSharedConfig defaultConfig] setApplicationID:TI_APPLICATION_ID];
[[TiSharedConfig defaultConfig] setApplicationPublisher:TI_APPLICATION_PUBLISHER];
[[TiSharedConfig defaultConfig] setApplicationURL:[NSURL URLWithString:TI_APPLICATION_URL]];
Expand All @@ -50,23 +47,20 @@ int main(int argc, char *argv[])
[[TiLogServer defaultLogServer] setPort:TI_LOG_SERVER_PORT];
#endif

UIColor *defaultBgColor = UIColor.blackColor;
#if defined(DEFAULT_BGCOLOR_RED) && defined(DEFAULT_BGCOLOR_GREEN) && defined(DEFAULT_BGCOLOR_BLUE)
defaultBgColor = [UIColor colorWithRed:DEFAULT_BGCOLOR_RED
green:DEFAULT_BGCOLOR_GREEN
blue:DEFAULT_BGCOLOR_BLUE
alpha:1.0f];
#endif
UIColor *defaultBgColor = [UIColor colorWithRed:TI_APPLICATION_DEFAULT_BGCOLOR_RED
green:TI_APPLICATION_DEFAULT_BGCOLOR_GREEN
blue:TI_APPLICATION_DEFAULT_BGCOLOR_BLUE
alpha:1.0f];
[[TiSharedConfig defaultConfig] setDefaultBackgroundColor:defaultBgColor];

#if defined(DEBUG) || defined(DEVELOPER)
[[TiSharedConfig defaultConfig] setDebugEnabled:YES];
#endif

#ifdef __LOG__ID__
#ifdef LOGTOFILE
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%s.log", STRING(__LOG__ID__)]];
NSString *logPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.log", TI_APPLICATION_GUID]];
freopen([logPath cStringUsingEncoding:NSUTF8StringEncoding], "w+", stderr);
fprintf(stderr, "[INFO] Application started\n");
#endif
Expand Down
Loading