Skip to main content
Inspiring
February 2, 2012
Question

Native Extension Compile Error

  • February 2, 2012
  • 10 replies
  • 3602 views

I'm writing a Native Extension that will add Native UIAccessibilityElements in order to use the voice over capabilities in IOS.  This is my first Native Extension and I have followed the amazingly helpful tutorial here:

http://www.liquid-photo.com/2011/10/28/native-extension-for-adobe-air-and-ios-101/

so I have a functioning ANE that can communicate with native code and add elements to the View.  I am able to add many other objects in a custom View like a UIButton or UILabel, but when I add a UIAccessiblityElement i get this error in Flash Builder when I compile. 

Error occurred while packaging the application:

ld: absolute addressing (perhaps -mdynamic-no-pic) used in -[MyView initWithFrame:] from /var/folders/5+/5+qCHDuCFg8yA8ob60zAZlkBXYk/-Tmp-/303a648c-adb7-4249-9173-ba802e88720e/.NativeAccessibility.a(MyView.o) not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs

Compilation failed while executing : ld64

I've seen this error referenced in other discussions but the answers were all over the place, and often not even in readable english. But the effort was appreciated   I'm not an Objective C expert, but I'm getting better. But I'm probably doing something wrong in Obj-C.  At this point I've narrowed the error to the point where I set the accElem.accessibilityTraits.   Now I'm completely stuck. Here is my code for my custom View in which i am created the Element, I'm also creating a button just to test that stuff is working:

#import "MyView.h"

@implementation MyView

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

   

        CGRect localRect = CGRectMake( 10, 200, 100, 30 );

        CGRect globalRect = CGRectOffset(localRect, CGRectGetMinX(self.accessibilityFrame), CGRectGetMinY(self.accessibilityFrame));

        UIAccessibilityElement *accElem = [[UIAccessibilityElement alloc] initWithAccessibilityContainer:self];

        accElem.isAccessibilityElement = YES;

        accElem.accessibilityFrame =  globalRect;

        accElem.accessibilityHint = [NSString stringWithFormat:NSLocalizedString(@"xyz %@", nil), @"hint"];

        accElem.accessibilityTraits = UIAccessibilityTraitButton;// if I comment this out I get no error in Flash Builder compile, but i get no element on the screen

        accElem.accessibilityLabel =@"Label";

       

        [accElem release];

        CGRect buttonFrame1 = CGRectMake( 10, 120, 100, 30 );

        UIButton *button1 = [[UIButton alloc] initWithFrame: buttonFrame1];

        [button1 setTitle: @"My Button" forState: UIControlStateNormal];

        [button1 setTitleColor: [UIColor redColor] forState: UIControlStateNormal];

        [self addSubview: button1];

       

    }

    return self;

}

@8978565

Any help would be greatly appreciated....

This topic has been closed for replies.

10 replies

jt-digAuthor
Inspiring
March 15, 2012

Nope,  I took a break.  Debugging native extensions is very time consuming, especially when you are a beginner at Objective C.  I'm not giving up because this is basically a deal breaker for my institution when it comes to using Air for mobile.   I wish Adobe would work on the accessiblity issue, although I understand why they are asking the community to figure it out. I'm not sure they care that much about UI centric apps because it appears they are focusing AIR for games and not for the enterprise. PhoneGap is probably what they would tell people to use for Enterprise apps the need to use the UI elements a lot. So for now we are using Titanium Appcelerator because of the Native UI. It's okay, but is not quite write once run everywhere. 

jt-digAuthor
Inspiring
February 3, 2012

that didn't work.  I'm still debugging it.  thanks for the help, any other suggestions.  I'll let you know if I get it.

-Steve

pigiuz
Participant
March 15, 2012

any news on this topic?

did you get it work steve?

Inspiring
March 15, 2012

I did my UI based native extension a while ago.

Steve's error might be the Objective-C code, but I am not sure since I am a Objective-C noob.

And the way I compile my ANE file is different than the following link.

http://www.liquid-photo.com/2011/10/28/native-extension-for-adobe-air-and-ios-101/

I don't know whether that's the case.

February 3, 2012

Hi Steve:

Which version of Xcode are you using to write native code?

What is the compiler being used to create .o?

what is the naespace you are using in extension xml?

Are you using -platformsdk while compiling? (It is in Flash Builder->Project properties->iOS Build Packaging->Native Extensions)

This will really help answer your question.

Thanks,

Saumitra

jt-digAuthor
Inspiring
February 3, 2012

Hi Saumitra,  thanks for replying.

I'm using Xcode 4.2 build 4C199.

I'm using the Flash Builder compiler to create the .o file.  Or that's what appears to be happening.  I don't see a .o file created anywhere, I only see a mention of it during compilation in the error message.  I have MyView.h and MyView.m. I'm not doing command line ipa creation. Should I use the command line instead on Flash Builder 4.6 to generate the ipa?

My namespace is this, i believe it is fine.

<extension xmlns="http://ns.adobe.com/air/extension/3.1">

    <id>edu.uiowa.its.tomblin.NativeAccessibility</id>

    <versionNumber>0.0.1</versionNumber>

    <platforms>

        <platform name="iPhone-ARM">

            <applicationDeployment>

                <nativeLibrary>libNativeAccess.a</nativeLibrary>

                <initializer>ExtInitializer</initializer>

                <finalizer>ExtFinalizer</finalizer>

            </applicationDeployment>

        </platform>

    </platforms>

</extension>

I am not using -platformssdk while compiling.   Is the error I'm getting common when I'm trying to access frameworks that are not in the ANE? I've seen the article on external sdks here:

http://blogs.adobe.com/rajorshi/2011/11/16/ios5-support-for-airusing-external-sdks-to-package-apps/

the article which describes the process using command line generation but not in Flash Builder. 

-platformsdk /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/

I guess I could use the command line because when I add

to those compiler arguments to Flash Builder  I get an unknown compiler argument errors. 

this is what i am using to create the ANE:

/Applications/Adobe\ Flash\ Builder\ 4.6/sdks/4.6.0/bin/adt -package -target ane /Users/stomblin/Desktop/NativeAccess/build/debug/NativeAccess.ane /Users/stomblin/Desktop/NativeAccess/build/extension.xml  -swc /Users/stomblin/Desktop/NativeAccess/build/NativeAccess.swc  -platform iPhone-ARM -C /Users/stomblin/Desktop/NativeAccess/build/debug .

i probably need to add -platformoptions myplatformoptions.xml

thanks for the help

February 3, 2012

Hi:

I guess(from native code) that the Native features you are using exist from iOS 3.0. If you are not using anything iOS 5 specific. I would recommend trying with 2.5 namspace.

Just try replacing

<extension xmlns="http://ns.adobe.com/air/extension/3.1">

With

<extension xmlns="http://ns.adobe.com/air/extension/2.5">

Inspiring
February 2, 2012

You are several steps ahead of me. I am new to the native extension as well, and I am working on loading the WebView from Objective-C to the flex side. Since the stageWebview does not have the full control of html content, you are not able to re-select the content in stageWebView component. Therefore, I am trying to load the UIWebView from XCode with native extension.

Looking forward to see some good replies!!!!

And, Good Lucks!!