Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-754

Use of -weak_library in 'other library flags' of generated template XCode app causes crashes in Simulator when Obj-C Blocks are used

    XMLWordPrintableJSON

Details

    Description

      Create an Xcode project using the Cordova 1.7 Template.

      Open the MainViewController.m file, and overwrite the viewDidLoad method with:

      • (void) viewDidLoad
        {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.

      [UIView animateWithDuration:0.75
      animations:^

      { self.view.alpha = 0.5; self.view.alpha = 1.0; }

      completion:^(BOOL finished)

      { NSLog(@"Complete"); }

      ];

      }

      Run app in the iPhone simulator.
      App crashes with EXC_BAD_ACCESS (code=2 address 0x0) on line beginning [UIView ..

      Solution:

      Alter the build settings 'Other linker flags' for main target.

      • Remove -weak_library
      • Replace with -weak-lSystem

      Re-build, app no longer crashes. Note that it works on the device regardless of this setting.

      Suggest template includes this change.

      This stackoverflow post describes the problem in more detail:
      http://stackoverflow.com/questions/6738858/use-of-blocks-crashes-app-in-iphone-simulator-4-3-xcode-4-2-and-4-0-2

      Attachments

        Activity

          People

            shazron Shazron Abdullah
            benvium Ben Clayton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified