Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12558] iOS: Allow external modules to use ARC

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-04-05T21:23:56.000+0000
Affected Version/sn/a
Fix Version/sRelease 3.1.0, 2013 Sprint 03 API, 2013 Sprint 03, Release 3.2.0
ComponentsiOS
LabelsARC, qe-closed-3.2.0
ReporterSindre Sorhus
AssigneeBlain Hamon
Created2013-02-01T23:28:16.000+0000
Updated2013-12-11T00:27:08.000+0000

Description

The original feature request was for ARC in all of TiMob codebase. This is less ambitious, and just to allow modules that use ARC to interact with Titanium. {quote} Automatic Reference Counting (ARC) for Objective-C makes memory management the job of the compiler. By enabling ARC with the new Apple LLVM compiler, you will never need to type retain or release again, dramatically simplifying the development process, while reducing crashes and memory leaks. The compiler has a complete understanding of your objects, and releases each object the instant it is no longer used, so apps run as fast as ever, with predictable, smooth performance. {quote} More info [here](http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/_index.html).

Comments

  1. Blain Hamon 2013-02-02

    Originally a community pull request. Max added a line. I added snarky comments. It's all good and merged. Unfortunately, the test case is not much more than 'compiles, make sure there's no side effects for Titanium itself' (Spoilers: no change for non-ARC code)
  2. Vishal Duggal 2013-02-02

    Pull requests https://github.com/appcelerator/titanium_mobile/pull/3838 https://github.com/appcelerator/titanium_mobile/pull/3839
  3. Peter Steinberger 2013-02-10

    Hi, I'm the original author of this pull request. Thanks for merging this in 3.0.2. I've tried it and compiling works now - thanks! Yet there are lots of warning now about the __bridge. There's an easy workaround for this: (KrollContext.h, Line 156) #if __has_feature(objc_arc) KrollContext *ctx = (__bridge KrollContext*)TiObjectGetPrivate(TiValueToObject(globalContext, value, NULL)); #else KrollContext *ctx = (KrollContext*)TiObjectGetPrivate(TiValueToObject(globalContext, value, NULL)); #endif Alternatively you can also make something like an __arc_bridge and define that to either "" or "__bridge" if you need this more than once.
  4. Max Stepanov 2013-02-11

    The following block would be better:
       #if !__has_feature(objc_arc)
       #define __bridge
       #endif
       
  5. Ingo Muschenetz 2013-02-19

    Will close issue after discussion with QE. Please reopen if this becomes a problem again.
  6. Daniel Sefton 2013-03-14

    Community user in TC-1965 suggests that the __bridge warnings still exist, and that one of the workarounds suggested in the last couple of comments should be implemented. Or alternatively an explanation as to why this was closed. Cheers.
  7. Blain Hamon 2013-03-18

    Actually, the better answer would be to move this into a non-inlined function so that it can be better optimized and avoid any conflicts if an old module runs on a newer SDK.
  8. Blain Hamon 2013-03-19

    https://github.com/appcelerator/titanium_mobile/pull/3985
  9. Matt Langston 2013-03-22

    Functional Test passed. This is how I tested:

    Created Titanium Module Project based on SDK 3.0.2GA. This SDK is not aware of ARC.

    Created Titanium Project based on SDK 3.1.0 master branch, which removed the inline function mentioning __bridge (i.e. an ARC construct).

    Noted there were no regressions, proving that functional test passed.

    Also noted there were 29 compiler warnings.

    Rebuild the Titanium project based on SDK 3.2.0GA.

    Noted there were 58 compiler warnings. The decrease in the number of compiler warnings is also an improvement.

  10. Pedro Enrique 2013-04-04

    Tested with 3.1.0.v20130402092426 and it is not working. I get two errors in the following files: TiBuffer.h http://f.cl.ly/items/1D2d1l3p1s3i0p2e2m3A/Screen%20Shot%202013-04-04%20at%2010.07.04%20AM.png KrollCallback.h http://f.cl.ly/items/2O092U2Q0M1Z001E3j1l/Screen%20Shot%202013-04-04%20at%2010.07.42%20AM.png
  11. Blain Hamon 2013-04-04

    TiBuffer.h is due to our -(NSNumber*)copy:(id)args (As in copy data in and return how much) with -(void)copy:(id)sender (as in cut, copy, paste). To support arc, we'll have to have a renamed version. KrollCallback.h is due to having code in the header not in the implementation. Guh.
  12. Sabil Rahim 2013-04-05

    3_1_X PR merged. pending master PR
  13. Sabil Rahim 2013-04-05

    Testing the PR
  14. Sabil Rahim 2013-04-05

    Testing Instruction ** Create a new Titanium Module Project for iOS from Studio. ** Open the module project in Xcode. ** click on the projectname on left pane in xcode and in build settings turn on Obj-C Automatic Reference Counting. ** Compile the project. You should see only on failure(That is because of the template. If you remove the dealloc method the project would compile successfully)
  15. Wilson Luu 2013-12-11

    Closing ticket as fixed. Verified using Sabil's steps. Tested on: Appcelerator Studio, build: 3.2.0.201312091648 SDK build: 3.2.0.v20131210112451 CLI: 3.2.0-cr Alloy: 1.3.0-cr Xcode: 5.0.2

JSON Source