Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20015] iOS: Improve deprecation macros

GitHub Issuen/a
TypeImprovement
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2015-11-20T03:20:05.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.2.0
ComponentsiOS
Labelsqe-5.2.0
ReporterHans Knöchel
AssigneeHans Knöchel
Created2015-11-19T04:31:31.000+0000
Updated2016-01-22T00:42:29.000+0000

Description

The macros for deprecating an API are misleading and need to be unified:
#define DEPRECATED_REPLACED(api,in,newapi) \
DebugLog(@"[WARN] Ti%@.%@ DEPRECATED in %@, in favor of %@.",@"tanium",api,in,newapi);
 
This macro expects DEPRECATED_REPLACED(@"Calendar.requestAuthorization", @"5.1.0", @"Titanium.Calendar.requestContactsPermissions"); Note, that the Titanium prefix is added by the macro in the deprecated API, but needs to be added manually in the replaced API. The approach is to clean this up and unify all usages, so that we call DEPRECATED_REPLACED(@"Calendar.requestAuthorization", @"5.1.0", @"Titanium.Calendar.requestContactsPermissions"); which generated a proper Ti-prefixed warning for all API's.

Comments

  1. Hans Knöchel 2015-11-19

    PR: https://github.com/appcelerator/titanium_mobile/pull/7476 I also created a test case to check every possible macro by calling 2 properties that internally call the macros:
       Ti.UI.createWindow({
       	backgroundColor: "#fff"
       }).open();
       
       Ti.API.info("\n\nWarnings following:\n");
       
       // -- Please run this code and verify the console logs with the logs below.
       
       /**
       			Deprecated -> Removed warnings
       */
       
       // Expected log: [WARN] Ti.Media.AUDIO_HEADPHONES DEPRECATED in 3.4.2: REMOVED in 3.6.0
       var a = Ti.Media.AUDIO_HEADPHONES;
       
       // Expected log: [WARN] Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND DEPRECATED in 3.4.2: REMOVED in 3.6.0
       var b = Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND;
       
       
       /**
       			Deprecated -> Replaced -> Removed warnings
       */
       
       // Expected log: [WARN] Ti.Media.audioLineType DEPRECATED in 3.4.2, in favor of Ti.Media.currentRoute: REMOVED in 3.6.0
       var c = Ti.Media.audioLineType;
       
       // Expected log: [WARN] Ti.UI.iPhone.StatusBar.OPAQUE_BLACK DEPRECATED in 3.4.2, in favor of Ti.UI.iPhone.StatusBar.LIGHT_CONTENT: REMOVED in 3.6.0
       var d = Ti.UI.iPhone.StatusBar.OPAQUE_BLACK;
       
       
       /**
       			Deprecated -> Replaced warnings
       */
       
       // Expected log: [WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONT
       var e = Ti.UI.iOS.ATTRIBUTE_FONT;
       
       // Expected log: [WARN] Ti.UI.iOS.ANIMATION_CURVE_LINEAR DEPRECATED in 2.1.0, in favor of Ti.UI.ANIMATION_CURVE_LINEAR
       var f = Ti.UI.iOS.ANIMATION_CURVE_LINEAR;
       
  2. Chee Kiat Ng 2015-11-20

    CR done. APPROVED!
  3. Harry Bryant 2016-01-20

    Ran the demo code provided by [~hans123] and received the following:
       Jan 20 09:52:34 SAMWISE keyboardType[552] <Warning>: [WARN] Ti.Media.AUDIO_HEADPHONES DEPRECATED in 3.4.2: REMOVED in 3.6.0
       Jan 20 09:52:34 SAMWISE keyboardType[552] <Warning>: [WARN] Ti.UI.iOS.COLOR_SCROLLVIEW_BACKGROUND DEPRECATED in 3.4.2: REMOVED in 3.6.0
       Jan 20 09:52:34 SAMWISE keyboardType[552] <Warning>: [WARN] Ti.Media.audioLineType DEPRECATED in 3.4.2, in favor of Ti.Media.currentRoute: REMOVED in 3.6.0
       Jan 20 09:52:34 SAMWISE keyboardType[552] <Warning>: [WARN] Ti.UI.iPhone.StatusBar.OPAQUE_BLACK DEPRECATED in 3.4.2, in favor of Ti.UI.iPhone.StatusBar.LIGHT_CONTENT: REMOVED in 3.6.0
       Jan 20 09:52:34 SAMWISE keyboardType[552] <Warning>: [WARN] Ti.UI.iOS.ANIMATION_CURVE_LINEAR DEPRECATED in 2.1.0, in favor of Ti.UI.ANIMATION_CURVE_LINEAR
       
    According to the demo, the message [WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONT should be present as e = Ti.UI.iOS.ATTRIBUTE_FONT is called, however it is not present when run with SDK 5.2.0.v20160114021251
  4. Hans Knöchel 2016-01-20

    Interesting. I just tried var e = Ti.UI.iOS.ATTRIBUTE_FONT; and got \[WARN] Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONT using the 5_2_X branch. Anyway, it is possible that the constant is only available in conjunction with the Ti.UI.AttributedString proxy. Long story short: Can you test the following (all words except the last should be times, the logs should state the warning):
       var win = Titanium.UI.createWindow({
           backgroundColor: '#ddd',
       });
       
       win.open();
       
       var text =  'Bacon ipsum dolor Appcelerator Titanium rocks! sit amet fatback leberkas salami sausage tongue strip steak.';
       
       var attr = Titanium.UI.iOS.createAttributedString({
           text: text,
           attributes: [{
               type: Titanium.UI.iOS.ATTRIBUTE_FONT,
       	value: "Times",
               range: [0, text.length - 6]
           }]
       });
       
       var label = Titanium.UI.createLabel({
           left: 20,
           right: 20,
           height: Titanium.UI.SIZE,
           attributedString: attr
       });
       
       win.add(label);
       
  5. Harry Bryant 2016-01-20

    As per the above comment on the matter, using the demo code successfully returns the following:
       // Some comments here
       [WARN]  Ti.UI.iOS.ATTRIBUTE_FONT DEPRECATED in 3.6.0, in favor of Ti.UI.ATTRIBUTE_FONT
       [WARN]  Ti.UI.iOS.createAttributedString() DEPRECATED in 3.6.0, in favor of Ti.UI.createAttributedString()
       
    Verified as fixed, Tested on: iPhone 6s Plus Device (9.2) & iPhone 6 Plus Device (8.4) Mac OSX El Capitan 10.11 (15A284) Ti SDK: 5.2.0.v20160114021251 Appc NPM: 4.2.3-1 App CLI: 5.2.0-228 Xcode 7.2 Node v4.2.3 *Closing Ticket.*

JSON Source