Eliminating the need for the Other Linker Flag "-all_load " in iOS

392 views
Skip to first unread message

Gardenofwine

unread,
Oct 19, 2010, 10:59:30 AM10/19/10
to phonegap
Hello,

Our team integrated some 3rd party libraries in an iOS PhoneGap based
application. Unfortunately, we encountered linkage problems because
this 3rd party library (RedLazer http://redlaser.com/) does not
compile with the "all_load" flag (an Internal bug).

We have researched the issue a bit, and found out that PhoneGap uses
the -all_load flag only becuase of Apple's bug concerning category
method declaration (http://developer.apple.com/library/mac/#qa/qa2006/
qa1490.html).

The solution we found is very simple - there are 3 files that declare
category methods in PhoneGap:
"Categories.h"
"NSObject+SBJSON.h"
"NSString+SBJSON.h"

We added a dummy class declaration at the end of each file, likewise:

@interface DummyClass_NSObject_SBJSON {}
@end
@implementation DummyClass_NSObject_SBJSON
@end

Doing so (with the obvious modifications for each file) we were able
to eliminate the need for the -all_load flag.

Hope this helps someone, and we also would like to suggest
incorporating this change in the next release of PhoneGap.

Thanks,
Benny.

Shazron Abdullah

unread,
Oct 19, 2010, 5:09:29 PM10/19/10
to Gardenofwine, phonegap
Hi Benny,
Good workaround for a quick fix. I think however -force_load on the PhoneGapLib.a would be a better permanent solution for PhoneGap. See http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html

Shazron

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Gardenofwine

unread,
Oct 20, 2010, 5:35:06 AM10/20/10
to phonegap
I tested your suggestion,

however when I add the linker flag:
-force_all ./PhoneGapLib/build/Debug-iphonesimulator/libPhoneGapLib.a

to my project settings', I Get the Duplicate symbol error. I'm not
sure why... because when I use the -all_load flag, the project
compiles correctly, and =all_load should be a stronger version of -
force_load...


Perhaps you can shed light on the matter?

On Oct 19, 11:09 pm, Shazron Abdullah <shazron.abdul...@nitobi.com>
wrote:
> Hi Benny,
> Good workaround for a quick fix. I think however -force_load on the PhoneGapLib.a would be a better permanent solution for PhoneGap. Seehttp://developer.apple.com/library/mac/#qa/qa2006/qa1490.html
>
> Shazron
>
> On 2010-10-19, at 7:59 AM, Gardenofwine wrote:
>
> > Hello,
>
> > Our team integrated some 3rd party libraries in an iOS PhoneGap based
> > application. Unfortunately, we encountered linkage problems because
> > this 3rd party library (RedLazerhttp://redlaser.com/) does not

D. Rimron

unread,
Oct 20, 2010, 5:47:43 AM10/20/10
to phon...@googlegroups.com
On 20/10/2010 10:35, Gardenofwine wrote:
> I tested your suggestion,
>
> however when I add the linker flag:
> -force_all ./PhoneGapLib/build/Debug-iphonesimulator/libPhoneGapLib.a
>
> to my project settings', I Get the Duplicate symbol error. I'm not
> sure why... because when I use the -all_load flag, the project
> compiles correctly, and =all_load should be a stronger version of -
> force_load...
>
>
> Perhaps you can shed light on the matter?
Are you running into the Apple libtool bug for universal binaries, where
it things the different ARM platform symbols are in conflict where
they're not. What's the exact error you're getting? Does it seem like
nonsense? :)

-Dx

Shazron Abdullah

unread,
Oct 21, 2010, 1:49:15 AM10/21/10
to Gardenofwine, phonegap
Firstly it might be because you are using "force_all" instead of "force_load".

For a solution based off the $(PHONEGAPLIB) location always - just tested it in my sample project. This works:
In your build settings (I put it in my Target settings here) --

1) Find "Other Linker Flags", select it (delete current value)
2) While (1) is selected, click on the Gear icon on the bottom left, select "Add Build Setting Condition"
3) Select "Any iOS Device" from the first dropdown
4) Do (2) again, but for (3), Select "Any iOS Simulator" from the dropdown instead

For (3), enter this value: -force_load $(PHONEGAPLIB)/build/$(CONFIGURATION)-iphoneos/libPhoneGapLib.a -Obj-C
For (4), enter this value: -force_load $(PHONEGAPLIB)/build/$(CONFIGURATION)-iphonesimulator/libPhoneGapLib.a -Obj-C

See attached screenshot.

otherldflags.jpeg

Benny Weingarten

unread,
Oct 21, 2010, 10:48:01 AM10/21/10
to Shazron Abdullah, phonegap
Hi Abdullah,

I had a typo in my Email - I was using -force_load in the actual project - still I'm not sure why it did not work. However, I managed to make it work with your instructions. Very instructive and helpful.

 Thanks!





--
Save Palmahim beach!
http://www.savepalmahim.org
------------------------------------------------
http://www.myspace.com/gardenofwine

Shazron Abdullah

unread,
Oct 21, 2010, 2:23:53 PM10/21/10
to Benny Weingarten, phonegap
Cool! I've added this info as a wiki page, also linked on the front page:
http://wiki.phonegap.com/w/page/Upgrade-your-PhoneGap-Xcode-Template-for-3rd-Party-Library-Linkage-Problems
Reply all
Reply to author
Forward
0 new messages