[TIMOB-11961] CLI: iOS: Facebook - Error on assigning app id to the instance of Titanium.Facebook
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-11-01T06:09:49.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.1.0, 2012 Sprint 25, 2012 Sprint 25 JS, 2013 Sprint 22, 2013 Sprint 22 Core, Release 3.2.0 |
Components | CLI, iOS |
Labels | 3.0.0.rc2, module_titanium, qe-ios100112, qe-testadded, regression |
Reporter | Anshu Mittal |
Assignee | Chris Barber |
Created | 2012-12-05T07:30:50.000+0000 |
Updated | 2014-02-12T08:20:49.000+0000 |
Description
Error on assigning app id to the instance of Titanium.Facebook
This is regression since the issue does not occur on 2.1.4 GA and below.
Steps to reproduce:
1. Create an app using the code below.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var facebook = Titanium.Facebook;
facebook.appid = "495338853813822";
var fb = facebook.createLoginButton();
fb.width = 80;
fb.height = 20;
fb.top = 370;
win1.add(fb);
win1.open();
2. Launch the app.
Actual:
The error is thrown as below:
'undefined' is not an object (evaluating 'facebook.appid="495338853813822"') at app.js (line 1).
Expected:
The app should work normally.
But if the following code is used instead of above code, no error is thrown and the code works normally.
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
Titanium.Facebook.appid = "495338853813822";
var fb = Titanium.Facebook.createLoginButton();
fb.width = 80;
fb.height = 20;
fb.top = 370;
win1.add(fb);
win1.open();
Talked with emerriman, he was able to reproduce this while I wasn't, because I have the CLI disabled. When the issue was happening, #define USE_TI_FACEBOOK was missing from defines.h In latter tests, having Titanium.Facebook.createLoginButton, even on an unused line, was sufficient for CLI to add the define. I'm guessing that the search is of "Ti\.[A-Za-z]+\.", using a period as part of the search, instead of allowing whitespace or semicolon to be terminators. This is a CLI issue, so directing to Cbarber.
Moved to JS sprint
FWIW, the new CLI's iOS build command does not use fragile regular expressions. I load each and every JavaScript file into the AST parser, then walk the AST tree to find all Titanium instances. It's not bulletproof, but it's a million times better than what was there in the old builder.py.
Master pull request: https://github.com/appcelerator/titanium_mobile/pull/3553 3.0.x pull request: https://github.com/appcelerator/titanium_mobile/pull/3554
Verified fixed with: SDK: 3.0.0.v20121207120202 Titanium Studio, build: 3.0.0.201212061921 Mac OS X 10.8.2 Xcode 4.5.2 CLI: 3.0.20
Issue is still reproducible using: OSX: 10.8.4 Xcode:4.5 Appcelerator Studio, build: 3.1.2.201307232148 SDK:3.1.2.v20130723170106 Error also appears while using workaround code provided in test steps by Anshu: [INFO] : Application started [ERROR] : Script Error { [INFO] : TIMOB-11961/1.0 (3.1.2.v20130723170106.3bb836f) [ERROR] : backtrace = "#0 () at :0"; [ERROR] : line = 18; [ERROR] : message = "'undefined' is not an object (evaluating 'Titanium.Facebook.appid = \"495338853813822\"')"; [ERROR] : name = TypeError; [ERROR] : sourceId = 296909216; [ERROR] : sourceURL = "file://localhost/Users/pragya.rastogi/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/401C973E-BE4D-4862-AF73-399CE2CC6AEE/TIMOB-11961.app/app.js"; [ERROR] : }
You need to add this to the tiapp.xml:
Tested and Verified the fix with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201311122338 SDK: 3.2.0.v20131113183932 acs:1.0.7 alloy:1.3.0 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3 Device: iOS7(v7.0.3)-iPodTouch1 Simulator- iPhone Retina(3.5-inch) iOS 7.0 Test Code Used: app.js
tiapp.xml