Copy link to clipboard
Copied
My company is developing a game for the iPhone and iPad devices using Flash cs5.5 and Air3.0
The client requires that certain features be supported - such things like GameCenter, Rating system, etc... none of which is currently supported by flash for the iOS.
However, they did provide us with a bunch of xCode sample files on how they want things to work.
My idea was to bridge the gap in functionality by creating a native exention that utilized the xcode source that was given to me, thus giving me the functionality that is required.
But first, I need to actually CREATE a native extension, even just a basic echo/hello world... I have followed all the steps from various guides and tutorials and I have managed to create an ipa and put it on my iPad2 to test, but when the program starts up, nothing happens, I am left with a black screen. When I comment out the lines of code that intialize the extension, it fires up just fine.
(and yes, I even tried to put things in try blocks in case there was an error - no luck)
So I am hoping that someone can read through the process of what I am doing below and point out what I am doing wrong, or what I am missing.
What I am using:
Mac Mini running OSX 10.7.2 - this is used to run xCode 4.1 build 4B110
PC - Windows 7 home 64bit - Running Flash CS5.5 (version 11.5.1.3469) with the AIR 3.0 SDK inside it. I also have the AIR 3.0 sdk in a seperate folder for command line running. (This is my primary developement platform)
The PC does have flash builder installed, but I have never really used it, nor do I know how to use it... everything that has been built to date has been done using Flash CS5.5
So, this is what I have done.
The first thing I do is create a .a static library on the mac.
I open xcode and create a new project.
//
// EchoExtension.m
// EchoExtension
//
#include "FlashRuntimeExtensions.h"
FREObject echo(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
return argv[0];
}
//----------- Extention intializer and finalizer ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// A native context instance is created
void ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet) {
// setup the number of functions in this extention
// for easy reference, set the number of function that this extention will use.
int FunctionCount = 1;
// set the pointer reference to the number of function this extention will use.
*numFunctionsToTest = FunctionCount;
// create an array to store all the functions we will use.
FRENamedFunction* func = (FRENamedFunction*)malloc(sizeof(FRENamedFunction)*FunctionCount);
// create an array entry for each function
func[0].name = (const uint8_t*)"echo"; // the name of the function
func[0].functionData = NULL; // the data type
func[0].function = &echo; // reference to the actual function
// save the array in a pointer.
*functionsToSet = func;
}
// A native context instance is disposed
void ContextFinalizer(FREContext ctx) {
return;
}
// Initialization function of each extension
void ExtInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, FREContextFinalizer* ctxFinalizerToSet) {
*extDataToSet = NULL;
*ctxInitializerToSet = &ContextInitializer;
*ctxFinalizerToSet = &ContextFinalizer;
}
// Called when extension is unloaded
void ExtFinalizer(void* extData) {
return;
}
I am now finish with that god foresaken mac (*shudders*)
Back on my PC, I create a folder for my test project. For all intents an purposes, let's call this "D:\src\EchoExtension" I then create 2 folders, one called "lib" and one called "app". Lib is where I will create the actionscript source for my extension.
package com.extensions.EchoExtension
{
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.external.ExtensionContext;
public class EchoExtension extends EventDispatcher
{
protected var _extensionContext:ExtensionContext;
/**
* Constructor.
*/
public function EchoExtension()
{
super();
// Initialize extension.
_extensionContext = ExtensionContext.createExtensionContext( "com.extensions.EchoExtension", "main" );
}
public function echo(Prompt:String):String
{
return _extensionContext.call( "echo" ) as String;
}
}
}
import com.extensions.EchoExtension.EchoExtension;
var ext:EchoExtension = new EchoExtension();
stop();
<extension xmlns="http://ns.adobe.com/air/extension/2.5">
<id>com.extensions.EchoExtension</id>
<versionNumber>1</versionNumber>
<platforms>
<platform name="iPhone-ARM">
<applicationDeployment>
<nativeLibrary>libEchoExtension.a</nativeLibrary>
<initializer>ExtInitializer</initializer>
<finalizer>ExtFinalizer</finalizer>
</applicationDeployment>
</platform>
</platforms>
</extension>
D:\SDKs\AirSDK30\bin\adt -package -target ane EchoExtension.ane extension.xml -swc EchoExtension.swc -platform iPhone-ARM library.swf libEchoExtension.a
Now that I have my swc, ane, and all that, it's time to create my sample application that will be used to test my new extension.
// basic imports.
import flash.desktop.NativeApplication;
import flash.events.MouseEvent;
import flash.text.TextField;
// import the extension from our swc.
import com.extensions.EchoExtension.EchoExtension;
// set our input text field to need the softkeyboard
txtInput.needsSoftKeyboard = true;
// add the event handlers to our buttons.
btnEcho.addEventListener(MouseEvent.CLICK, btnEcho_Click);
btnClear.addEventListener(MouseEvent.CLICK, btnClear_Click);
btnRunTime.addEventListener(MouseEvent.CLICK, btnRunTime_Click);
// create our extension variable.
var ext:EchoExtension;
try
{
// initialize our echo extension.
ext = new EchoExtension();
} catch (e:Error) {
txtEcho.text = "Error trying to create new EchoExtension:\n\n" + e;
}
stop();
// clear the echo text field
function btnClear_Click(e:MouseEvent):void
{
txtEcho.text = "";
}
// just for testing, put the current version of air runtime into our text field so we can make sure we are running air 3.0
function btnRunTime_Click(e:MouseEvent):void
{
txtEcho.text += "\nRuntime version = " + NativeApplication.nativeApplication.runtimeVersion;
}
// call the extension, passing it whatever is in the input text field and have it return it and place it in our echo text field
function btnEcho_Click(e:MouseEvent):void
{
txtEcho.text += "\n";
try
{
txtEcho.text += ext.echo(txtInput.text);
} catch (e:Error) {
txtEcho.text += "\nError calling ext.echo: " + e;
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<application xmlns="http://ns.adobe.com/air/application/3.0">
<extensions>
<extensionID>com.extensions.EchoExtension</extensionID>
</extensions>
<id>EchoExtensionTester</id>
<versionNumber>1.0</versionNumber>
<filename>EchoExtensionTester</filename>
<description/>
<!-- To localize the description, use the following format for the description element.<description><text xml:lang="en">English App description goes here</text><text xml:lang="fr">French App description goes here</text><text xml:lang="ja">Japanese App description goes here</text></description>-->
<name>EchoExtensionTester</name>
<!-- To localize the name, use the following format for the name element.<name><text xml:lang="en">English App name goes here</text><text xml:lang="fr">French App name goes here</text><text xml:lang="ja">Japanese App name goes here</text></name>-->
<copyright/>
<initialWindow>
<content>EchoExtensionTester.swf</content>
<systemChrome>standard</systemChrome>
<transparent>false</transparent>
<visible>true</visible>
<fullScreen>true</fullScreen>
<aspectRatio>landscape</aspectRatio>
<renderMode>gpu</renderMode>
<maximizable>true</maximizable>
<minimizable>true</minimizable>
<resizable>true</resizable>
<autoOrients>false</autoOrients>
</initialWindow>
<icon/>
<customUpdateUI>false</customUpdateUI>
<allowBrowserInvocation>false</allowBrowserInvocation>
<iPhone>
<InfoAdditions>
<![CDATA[<key>UIDeviceFamily</key><array><string>1</string><string>2</string></array>]]>
</InfoAdditions>
<requestedDisplayResolution>high</requestedDisplayResolution>
</iPhone>
</application>
Error creating files.
An implmentation for native extension 'com.extensions.EchoExtension' required by the application was not found for the target platform.
cls
"D:\SDKs\AirSDK30\bin\adt" -package -target ipa-ad-hoc -storetype pkcs12 -keystore "D:\src\mycert.p12" -storepass MYPASSWORD -provisioning-profile "D:\src\myprovfile.mobileprovision" "EchoExtensionTester.ipa" "EchoExtensionTester-app.xml" "EchoExtensionTester.swf" -extdir ../lib/Build
set /p dummy=
echo done
hrm. Time to do a little trial and error to see if I can figure out where the break down is.
And here I am stuck.
Can anyone tell me what I am doing wrong or what I have forgotten to do?
Thanks.
Hi Can you check if the SWC of the native extension is linked as external?
Following image can help locate and change the SWC link type.
The issue that many people face here (i.e. extension works in fast/interpreter mode and doesnt when packaged as standard mode) happens only when the SWC of the NE is not externally linked.
I hope this helps.
Regards,
Saumitra Bhave
AIR iOS
Copy link to clipboard
Copied
Andrea:
Ok... I recompiled the .a file first, only changing the compiler type to GCC4.2 only. I then rebuilt using both ad-hoc and testing and it acted the exact same way as before (Black screen/crashed)
I then changed Architectures to "Optimized (armv7)" and "valid architectures to "armv7" (removed the armv6) and in GCC4.2 preprocessing, changed teh "preprocessor Macros/Release" from "Any Architecture" to "armv7"
I then did a build for ad-hoc and I got the same black screen as before... I didn't test all the other configs as ad-hoc and appstore are the only ones I am really concerned with at the moment. I mean, great if it works in a debug-interpreter mode for developing, but if I can't release it to the clients, it doesn't really matter in the end.
Any other ideas? Is this the same problem that you are having?
Coline: Thank you for that info... I was informed by the powers that be that was are targeting the iPhone 3GS and higher, sot he regular iPhone 3G is not a concern.
Copy link to clipboard
Copied
Dave, I'm sorry but it looks like it's a different problem.
In my case compiling with plain GCC did solve the crashes.
Perhaps you could try to narrow down the exact place of the crash on the native side by inserting NSLog(@"...") calls in the methods (the output is visible in the device console in the XCode organizer); this should at least tell you if your native code has had a chance to run before the crash or not.
andrea
Copy link to clipboard
Copied
I tried to debug and step through the code and I found something interesting when I connected the app to the flash debugger.
When I fire it up on the device, it actually RUNS the application constructor... but as soon as it steps out of it, the application crashes.
If I try to initialize the extension in the constructor, the application crashes as soon as it tries
I moved all my extension code to a button click event, but it still crashes after the constructor runs.
here is the code of my main app:
package {
import flash.display.MovieClip;
import flash.text.TextField;
import fl.controls.Button;
import flash.desktop.NativeApplication;
import flash.events.MouseEvent
import com.extensions.EchoExtension.EchoExtension;
public class clsMain extends MovieClip {
private var txtInput:TextField;
private var txtEcho:TextField;
private var btnClear:Button;
private var btnRunTime:Button;
private var btnEcho:Button;
public function clsMain()
{
// constructor code
txtInput = new TextField;
txtInput.x = 20;
txtInput.y = 20;
txtInput.width = 900;
txtInput.height = 20;
txtInput.type = "input";
txtInput.needsSoftKeyboard = true;
txtInput.border = true;
this.addChild(txtInput);
txtEcho = new TextField;
txtEcho.type = "dynamic";
txtEcho.x = 20;
txtEcho.y = 50;
txtEcho.width = 900;
txtEcho.height = 400;
txtEcho.border = true;
this.addChild(txtEcho);
btnClear = new Button();
btnClear.label = "Clear";
btnClear.x = 20;
btnClear.y = 500;
addChild(btnClear);
btnRunTime = new Button();
btnRunTime.label = "RunTime";
btnRunTime.x = 140;
btnRunTime.y = 500;
this.addChild(btnRunTime);
btnEcho = new Button();
btnEcho.label = "Echo";
btnEcho.x = 400;
btnEcho.y = 500;
this.addChild(btnEcho);
btnEcho.addEventListener(MouseEvent.CLICK, btnEcho_Click);
btnClear.addEventListener(MouseEvent.CLICK, btnClear_Click);
btnRunTime.addEventListener(MouseEvent.CLICK, btnRunTime_Click);
}
// clear the echo text field
private function btnClear_Click(e:MouseEvent):void
{
txtEcho.text = "";
}
// just for testing, put the current version of air runtime into our text field so we can make sure we are running air 3.0
private function btnRunTime_Click(e:MouseEvent):void
{
txtEcho.text += "Runtime version = " + NativeApplication.nativeApplication.runtimeVersion +"\n" ;
}
// call the extension, passing it whatever is in the input text field and have it return it and place it in our echo text field
private function btnEcho_Click(e:MouseEvent):void
{
// create our extension variable.
private var ext:EchoExtension;
try
{
ext = new EchoExtension();
} catch (err:Error) {
txtEcho.text += "Error: " + err.message +"\n" ;
}
try
{
txtEcho.text += ext.echo(txtInput.text)+"\n" ;
} catch (err:Error) {
txtEcho.text += "Error: " + err.message +"\n" ;
}
ext = null;
}
}
}
Now, if I build the app using -target ipa-debug-interpreter and step through, it all works... however, when I try to set INTO the line "ext = new EchoExtension();" or "txtEcho.text += ext.echo(txtInput.text)+"\n" ;" it doesn't, it just steps over... but it still works.
I also added NSLog to start of every method in my xcode source, but it doesn't seem to make any difference. It doesn't output trace statements to the flash console (which I didn't think it would...)
So now I am left with the question... why does building with -target ipa-debug-interpreter/-target ipa-test-interpreter work but -target ipa-debug or anything else not work?
Copy link to clipboard
Copied
The output from NSLog is visible in the device console (it's in the xcode 'organizer' window, near the 'logs' item where you go to download crash stack traces), not in the flash debugger console.
It's quite puzzling that your application crashes even before trying to load the extension...
Interpreted and compiled builds seem to behave differently wrt bugs in native extensions. While experimenting, I managed to accidentally set a bogus number of functions (greater than actual) in the context initializer; this had no apparent ill effect in interpreted builds, but caused compiled builds to crash without fail.
andrea
Copy link to clipboard
Copied
I'm having this same issue also. The app crashing right when ExtensionContext.createExtensionContext is called
Copy link to clipboard
Copied
Hi Can you check if the SWC of the native extension is linked as external?
Following image can help locate and change the SWC link type.
The issue that many people face here (i.e. extension works in fast/interpreter mode and doesnt when packaged as standard mode) happens only when the SWC of the NE is not externally linked.
I hope this helps.
Regards,
Saumitra Bhave
AIR iOS
Copy link to clipboard
Copied
well, I'll be damned! That was my problem.... actually, my problem was 2 things.
the first thing I was doing wrong was that I was not adding the SWC's to the project, but the ANE's directly.
The second thing I was doing wrong was that I was not individually setting each to Link Type:External
Once I replaced the ANE's with SWC's in the action script settings (I am still including the ANE files with the the -extdir FOLDER in ADT command line builder) and set each to external, I was then able to do an ad-hoc build with ADT and it fired up.
Thank you everyone that replied in this thread. I hope that other people having the same issue will find this and help them too.
Cheers everyone.
Copy link to clipboard
Copied
Hello,
It seems like I've been down your road for about a week ago too. So I thought I provide some tips and also see if they can lead to
som clarity of my current problem. (I'm also quite new on the mac/ios/extensions development, but with the complete developing chain included,
it's one of the hardest things I've done so far). I guess that what you get when you using new technologies (like extensions) that no one had the time to test
or tutorialize properly.
Some things then:
- I made a test-app in the imac just to test my library. That way I can test the lib with a much shorter cycle, with xcode debugging (NSLog an such).
Since all FREObjects won't work this way I had to make a sub-lib that is used by the "FRE-lib" and test that sub-lib instead.
- I had to use FlexBuilder4.6 (beta) to be able to compile natives (or start the flex debugger) when using ane files. But apart from the debugger I'm using
command line mxmlc and adt so far.
- The Ipad has to be on the same subnet as my dev-computer, at least to my knowledge, just to minimize problems with firewalls and such.
- At some point I had to use the "http://ns.adobe.com/air/application/3.1" namespace in the app-descriptor xml file (and the extensions.xml) with the latest air sdk (3.1.0.4720, thats what my adt reports)
- I benefited greatly on comparison to the public iBattery and Vibration projects/tutorials.
- I still have to figure out how to use resources (like icons) in the native library since the .a file doesn't seem to be able to pack such files. I guess I have to pack in a resource bundle with adt, but I'm not sure.
- I have only tested interpreted code, and had it working.
- I have not been able to build .a files with LLVM3 or LLVM GCC 4.2. I get another format of the .a file, and cannot get any native results with them. I had to use the plain GCC 4.2 setting for any succes. It seems like the GCC4.2 .a files starts with a 48 byte header before the "!<arch>" continues. I have not yet figured
out what is the difference of the files or if the start of the file matters.
- Finally: I upgraded the dev-ipad to IOS5 and then I also had to go to xcode 4.2, and now I can't use the GCC4.2 anymore.
I get "Unsupported compiler 'GCC 4.2' selected for architecture 'armv7'". Can anyone point me in the right direction for this?
/Ola
Copy link to clipboard
Copied
@Dave: glad to know you solved your problem! Out of curiosity, were you able to use a native library compiled with llvm-gcc/clang or you just kept using gcc-4.2 ?
@OlaLofberg:
The problem I encountered is not with the library headers, but with the compiled objects themselves. I dug around a bit with otool -r and it seems that unlike plain GCC, the LLVM backend for ARMv7 emits a kind of relocation (type 9, HALF_DIF) which the linker in the AOT compiler cannot handle.
Therefore, when the native library is compiled with llvm-gcc or clang, the adt -package invocation produces a number of "ld warning: unexpected srelocation type 9"
messages and the packaged application crashes on extension initialization.
Given that the generation of half-word relocations for ARMv7 in LLVM cannot be turned off, and that all of the iOS native libraries in the example extensions I could find online appear to have been compiled with gcc-4.2, I'd like to know if I'm doing something wrong or if compilers using the LLVM backend are in fact not currently supported in AIR.
The iPhone 5.0 SDK that comes with XCode 4.2 only has clang and llvm-gcc. Until these issues are sorted out you have to uninstall it and go back to the 4.3 SDK (which means XCode 4.0 on Snow Leopard or 4.1 on Lion).
andrea
Copy link to clipboard
Copied
My alert view extension was set to GCC 4.2... I did try setting it back to LLVM GCC 4.2 and rebuild the .a file, then the ane, then the project without any errors... I put the device on the iPad and it ran without any problems.
As for xcode 4.2 - I tried to update my 4.1 but the it doesn't seem to want to take... I hate macs... sheesh...
The only problem I am having now is when I try to run 2 extensions in the same project.... one works, and the other gives me Error #3500: The extension context does not have a method with the name
If I add a third extension, only 1 will work and the other two will give me Error #3500: The extension context does not have a method with the name when I try to call functions in them
I don't know why.
Copy link to clipboard
Copied
@OlaLofberg:
The problem I encountered is not with the library headers, but with the compiled objects themselves. I dug around a bit with otool -r and it seems that unlike plain GCC, the LLVM backend for ARMv7 emits a kind of relocation (type 9, HALF_DIF) which the linker in the AOT compiler cannot handle.
Therefore, when the native library is compiled with llvm-gcc or clang, the adt -package invocation produces a number of "
ld warning: unexpected srelocation type 9"
messages and the packaged application crashes on extension initialization.Given that the generation of half-word relocations for ARMv7 in LLVM cannot be turned off, and that all of the iOS native libraries in the example extensions I could find online appear to have been compiled with gcc-4.2, I'd like to know if I'm doing something wrong or if compilers using the LLVM backend are in fact not currently supported in AIR.
The iPhone 5.0 SDK that comes with XCode 4.2 only has clang and llvm-gcc. Until these issues are sorted out you have to uninstall it and go back to the 4.3 SDK (which means XCode 4.0 on Snow Leopard or 4.1 on Lion).
andrea
Hello, thanks for the reply.
Yes, I recognize the "srelocation type 9".
@DaveGallant:
Are you really sure you managed to get an extension running with the LLVM GCC? No old libs or something? I know I always
have to check the build dates and often foced to do build clean before building again.
If you did, I guess there's still hope for me too.
Or else, I can't get an adobe flex extension running on IOS5.
(Since IOS5 needs xcode 4.2 and there's no GCC there and it's only GCC that can produce .a files that can be used
by adt) phew. crap..
Copy link to clipboard
Copied
Libraries built with older XCodes will work perfectly on iOS 5.
You only need to use the 5.0 SDK if you're using XCode to interactively debug an application on a device with iOS 5.
Copy link to clipboard
Copied
andrea.conti wrote:
Libraries built with older XCodes will work perfectly on iOS 5.
You only need to use the 5.0 SDK if you're using XCode to interactively debug an application on a device with iOS 5.
Ok, thanks. I get it.
But you can't use any library that has or uses a (sub)library which contain a "srelocation type 9" in flex native extensions then?
If so:
Is this an issue for adobe adt? Should one report it as a bug/feature somewhere maybe? Where?
/Ola
Copy link to clipboard
Copied
But you can't use any library that has or uses a (sub)library which contain a "srelocation type 9" in flex native extensions then?
If so:
Is this an issue for adobe adt? Should one report it as a bug/feature somewhere maybe? Where?
/Ola
I can't tell for sure. My (and apparently yours) experience would support that idea; however Dave seems to have managed to compile a working library with llvm-gcc without any problems.
That said, there is almost certainly an issue with the toolchain in AIR for iOS not being able to process valid compiled objects, probably because the version of llvm it's based on is quite old and is missing support for some recent features.
This was also reported a couple of weeks ago in the 4.6 prerelease forum (which seemed to me a better place to discuss a possible technical problem also affecting a beta release), but I got no answer.
15 minutes of rummaging through the support section of the sites gave me no indication that Adobe actually has the equivalent of a public issue tracker, so I gave up.
andrea
Copy link to clipboard
Copied
I was using xcode 4.1 to compile my extension... if I get some time soon (as I am working on something else at the moment) I will try to take some screen shots of my settings and verify that it is indeed using llvm-gcc
Copy link to clipboard
Copied
Here is the screen shot that I created from my mac mini that I used to build my extension:
Once it was compiled, I copied the .a file over to my PC where I used ADT in the AIR 3.0 sdk to build the ane. I then used Flash Pro to build a sample application and ADT to build it. Once I got the external linking issue fixed, I was able to build an Ad-hoc build and I put it on my iPad2 and everything fired up and worked.
The only problem I am having is that I can't use more than one extension in the same project.
If an of you want me to change any settings to do any tests, just let me know and I will give it a try to see if works or not with what I have.
Copy link to clipboard
Copied
I'm encountering something similar. I'm trying to write a native extension and have a very simple one working, however once I attempt to use a Framework library I get the "ld warning: unexpected srelocation type 9" and the app hangs after launch. I'm using XCode 4.2, AIR 3.1, and Flash Builer 4.6. Is the verdict that I need to roll back to 4.1, so I can use 4.3 as my Base SDK? Or maybe, there's a way to get Base SDK 4.3 for XCode 4.2?
It seems if I have "Enable Linking With Shared Libraries" set to Yes, I can build and deploy the app but it crashes on start-up. If I have it set to "No" it works fine as long as I don't use any Framework libraries. If I do use one, I get link errors.
I've tried a bunch of combinations of code generation and link options, to no real effect. Any pointers would be great. I'd hate to go down the path of reverting xcode, unless I really needed too.
Hmm. I suppose another potention issue is I'm using FB4.6 (beta) to compile the SWC and SWF.
Thanks!
- Rusty
Copy link to clipboard
Copied
Hmm. I suppose another potention issue is I'm using FB4.6 (beta) to compile the SWC and SWF.
I had the same issue with both FB 4.6 (with the bundled AIR 3.1) and FB 4.5.1 (with AIR 3.0), so I think you can rule that out.
andrea
Copy link to clipboard
Copied
Update: I now have a project compiled with LLVM GCC4.2 and don't get the srelocation error. That was obviously not what's causing
that problem. It might be that I now don't use any third party libs that have that relocation (type 9).
As I understand it (and as andrea was on to above): the adt uses a linker (llvm?) that probably not is supporting that type of relocation.
Frameworks: I discovered that I had to use a platformoptions-file for some frameworks. Here is a page that explains about it:
http://help.adobe.com/en_US/air/extensions/WSf268776665d7970d-2e74ffb4130044f3619-7fff.html
The additional frameworks that can be used are listed here on my win7 installation:
c:\Program Files (x86)\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\lib\aot\stub\
I also managed to use a third party framework (though the page above states that you can't/shouldn't);
I extracted the single lib-file from the framework-archive and linked it with my other
native lib in xcode. Seemed to work, but it feels like a kind of "hacky" solution.
Copy link to clipboard
Copied
Glad to hear you got it to work... did you compile with the 4.3 or the 5.0 SDK?
I am only linking to AVFoundation (and obviously Foundation), so there should be no need for a platform options file.
I was getting type 9 relocations in *all* functions exported from my library, including the extension initializer which does nothing except setting a pointer to the context initializer and finalizer.
From my understanding, type 9 relocations are emitted when using optimized instructions for loading string constants, so I still think it's an issue with code generation and not with whatever frameworks you're linking to.
I honestly have neither the time nor the motivation to get back to debugging this issue, especially seeing that there is no response whatsoever from Adobe.
If someone is interested in digging further I can provide the full source code of the extension (which is a simple wrapper around AVAudioPlayer to allow playing back AAC audio on iOS).
andrea
Copy link to clipboard
Copied
Yes, although I did not get it to work with my initial third party lib.
I'm using 4.3SDK.
I understand that these things take time. It might be a compiler flag that switches off the optimization you're suggesting.
But... a little help from Adobe would be nice.
Copy link to clipboard
Copied
Thanks for the help. Sounds like no one has gotten this to work with the
iOS5 SDK / XCode 4.2 / Air 3.1?
I notice XCode 4.2.1 was released recently, and the notes mention some
compiler fixes. I'll give that a shot first, before seeing if I can find
iOS 4.3 SDK somewhere. It wasn't included with XCode 4.2.
- Rusty
Copy link to clipboard
Copied
Hi:
I would recommend following http://blogs.adobe.com/rajorshi/2011/11/16/ios5-support-for-airusing-external-sdks-to-package-apps/ in case you are writing and ANE for iOS on xCode 4.X.
AIR 3.1 has included some new features specifically to address the support of iOS 5. This blog is applicable only for Mac currently.
UPDATE: If ADT throws some warnings while packaging an ipa you can ignore them. Your app should work.
Regards,
Saumitra Bhave
Copy link to clipboard
Copied
Thanks. I have tried including the iOS SDK using the -platformsdk flag.
Also tried including -framework Foundation as a linker flag, though the
blog post says it's included automatically, so that's probably not the
problem.
To be specific:
My extension works fine until I attempt to use the NSMutableDictionary
class from the Foundation SDK in my extension. If I set "Enable Linking
With Shared Libraries" to Yes, when I run adt I get linker "unexpected
srelocation type 9" warnings and the app hangs on launch.
If I set it to "No". I get the following link error, and am unable to build
an ipa:
"ld: absolute addressing (perhaps -mdynamic-no-pic) used in _getItem from
/var/folders/rc/w16r02qs70zgy9q02g2vlq2r0000gn/T/01ce07e6-4a7b-421b-8ac6-bce683ba7ea8/libcom.kongregate.KeyChain.a(KeyChainExtensionLib.o)
not allowed in slidable image. Use '-read_only_relocs suppress' to enable
text relocs"
Note: I already disabled the Generate Position Dependent Code option, to no
avail. Not sure what is creating the absolute addressing. Adding
-read_only_relocs suppress doesn't help much either. It just removes the
suggestion, but fails on essentially the same error. It's very possible,
there's some other linker or code generation option I need to throw in,
just not sure what. I'd love some confirmation from someone that has
successfully got this to work.
Copy link to clipboard
Copied
One correction. Actually, using NSMutableDictionary is working fine, so it's not the Foundation framework. It's when I add a constant from the Security framework that's getting me stuck. If I add this line:
CFTypeRef ref = kSecClassGenericPassword;
I get the "ld: absolute adressing .." error and'm unable to link. Guess I'll bang on it a bit more. Security framework should also be included with the default optoins, and I am pointing to the latest iPhoneOS5.0.sdk.