Titanium Mobile
  1. Titanium Mobile
  2. TIMOB-11961

CLI: iOS: Facebook - Error on assigning app id to the instance of Titanium.Facebook

    Details

      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();
      

        Activity

        Hide
        Blain Hamon (Inactive) added a comment -

        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.

        Show
        Blain Hamon (Inactive) added a comment - 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.
        Hide
        Vishal Duggal added a comment -

        Moved to JS sprint

        Show
        Vishal Duggal added a comment - Moved to JS sprint
        Hide
        Chris Barber added a comment -

        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.

        Show
        Chris Barber added a comment - 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.
        Show
        Chris Barber added a comment - Master pull request: https://github.com/appcelerator/titanium_mobile/pull/3553 3.0.x pull request: https://github.com/appcelerator/titanium_mobile/pull/3554
        Hide
        Eric Merriman added a comment -

        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

        Show
        Eric Merriman added a comment - 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
        Hide
        Pragya Rastogi added a comment -

        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] : }
        Show
        Pragya Rastogi added a comment - 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] : }
        Hide
        Chris Barber added a comment -

        You need to add this to the tiapp.xml:

        <modules>
            <module platform="ios">facebook</module>
        </modules>
        
        Show
        Chris Barber added a comment - You need to add this to the tiapp.xml: <modules> <module platform="ios">facebook</module> </modules>
        Hide
        Pragya Rastogi added a comment -

        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

        var win1 = Titanium.UI.createWindow({ 
            title:'Tab 1',
            backgroundColor:'#fff'
        });
        
        var facebook = require('facebook');
        facebook.appid = "495338853813822";
         
        var fb = facebook.createLoginButton();
            fb.width = 80;
            fb.height = 20;
            fb.top = 370;
            
        win1.add(fb);
        win1.open();
        

        tiapp.xml

         <modules>
            <!-- Add the appropriate line(s) to your modules section -->
            <module platform="android">facebook</module>
            <module platform="iphone">facebook</module>
        </modules>
        
        Show
        Pragya Rastogi added a comment - 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 var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var facebook = require('facebook'); facebook.appid = "495338853813822"; var fb = facebook.createLoginButton(); fb.width = 80; fb.height = 20; fb.top = 370; win1.add(fb); win1.open(); tiapp.xml <modules> <!-- Add the appropriate line(s) to your modules section --> <module platform="android">facebook</module> <module platform="iphone">facebook</module> </modules>

          People

          • Assignee:
            Chris Barber
            Reporter:
            Anshu Mittal
          • Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: