weak-linking

How to access weak linked framework in iOS?

可紊 提交于 2019-12-03 16:36:36
I want to use Twitter framework for iOS 5, but be able to run my app in older OS. I added weak referenced framework (i.e. set "optional" flag) in Xcode 4.2 Target settings. Base SDK is iOS 5, iOS deployment Target is iOS 3.2. Next, I try to use Twitter framework: #import <Twitter/Twitter.h> ... Class twClass = NSClassFromString(@"TWTweetComposeViewController"); if (!twClass) // Framework not available, older iOS { [self shareWithTwitterPriorIOS5]; return; } if ([TWTweetComposeViewController canSendTweet]) // Check if twitter is setup and reachable { TWTweetComposeViewController* twc = [

How to build an iOS framework with weak-linked CocoaPods libraries

可紊 提交于 2019-12-03 05:41:00
I am trying to build an iOS Framework (Test.framework) using the new template offered by Xcode 6 for creating Cocoa Touch Frameworks. The framework has different dependencies (as AFNetworking or FacebookSDK) specified in a Podfile. I don't want dependencies to be included in the framework, I just want to link against them. The problem is that when I build the framework, the libPods.a is linked and included. Q: How can I link against libPods.a library, but not include it in the framework? More details: I have read about weak linking: https://developer.apple.com/library/ios/documentation/MacOSX

iOS Framework weak link: undefined symbols error

假装没事ソ 提交于 2019-12-03 04:28:03
I'm building my own framework which proposed to be distributed to other developers for including to their projects. This framework links optionally certain frameworks (e.g. CoreLocation). The problem is that when I link my framework to real stand-alone project which doesn't contain CoreLocation in Build Phases, I'm getting linker errors like 'Undefined symbols for architecture' when tryin to build this host-project Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_CLLocationManager", referenced from: objc-class-ref in MySDK(MyServerConnection.o) ld: symbol(s) not found for architecture

Weak link framework

丶灬走出姿态 提交于 2019-11-30 20:19:54
Due to the last release of the adMob package, I have added the MessageUI framework to my project. As I wish to deploy my application to 2.x OS devices, I have weak linked MessageUI as advised. If I build for iPhone device 3.0, it works fine. If I build for iPhone device 2.2.1, I get a link error: "ld: framework not found MessageUI" Where could I be wrong? You are getting that error because you are building against a version of the SDK that does not implemement the MessageUI framework. What you need to do is to build for iPhone OS 3.0, but in the build settings for your target set the iPhone OS

Dynamic loading and weak symbol resolution

谁说我不能喝 提交于 2019-11-30 07:07:13
问题 Analyzing this question I found out some things about behavior of weak symbol resolution in the context of dynamic loading ( dlopen ) on Linux. Now I'm looking for the specifications governing this. Let's take an example. Suppose there is a program a which dynamically loads libraries b.so and c.so , in that order. If c.so depends on two other libraries foo.so (actually libgcc.so in that example) and bar.so (actually libpthread.so ), then usually symbols exported by bar.so can be used to

Does Android support weak symbols?

微笑、不失礼 提交于 2019-11-28 13:01:17
I've been looking at questions like: Cannot load library: reloc_library[1285]: cannot locate 'rand' Android app crashes in the start because java.lang.UnsatisfiedLinkError It seems to me this could be solved with weak symbols . That is, a native component could provide symbols like rand but adorn them with __attribute__((weak)) . If the symbol is found in another library, like the standard runtime, then the weakly linked symbol would not be used. On the other hand, if the symbol was missing, then the native component's version would be used. I'm having trouble locating information on it for

Different behavior of override weak function in shared library between OS X and Android

谁都会走 提交于 2019-11-28 10:31:41
I am encountering a different behavior between OS X and Android: There is a weak function foo in my shared library, I want to override it with strong function defined in my executable. I expect the the overridden also affect the calling inside the library Result: I got expected result on OS X, but failed on Android. Here is my test project: File: shared.h void library_call_foo(); void __attribute__((weak)) foo(); File: shared.c #include "shared.h" #include <stdio.h> void library_call_foo() { printf("shared library call foo -> "); foo(); } void foo() { printf("weak foo in library\n"); } File:

Alternatives to weak linking in iPhone SDK?

半腔热情 提交于 2019-11-27 19:56:27
I'm looking to make my app compatible with older versions of iPhone OS. I did see weak linking mentioned as an option. Can I use OS version detection code to avoid code blocks that the OS can't handle? (Say iAD?) if(OS >= 4.0){ //set up iADs using "NDA code"... } If yes, what goes in place of if(OS >= 4.0) ? You should be weak linking against the new frameworks. Alongside that you should be checking the availability of new APIs using methods like NSClassFromString , respondsToSelector , instancesRespondToSelector etc. Eg. Weak linking against MessageUI.framework (an old example, but still

What does it mean to “weak-link” a framework?

[亡魂溺海] 提交于 2019-11-27 19:46:51
In Xcode, I can set a framework to "Optional" instead of "Required", which then means the framework is weak linked. Does that mean the framework is only included in the bundle when it is imported somewhere? I want to weak-link a few debugging frameworks which use private API , and I do not want them to appear in the App Store build. hagi Important note : This answer was written before iOS 8 was announced. While the technical details still apply to system frameworks, it is now possible to build your own, dynamically linked frameworks that ship within your app bundle. There are restrictions, e.g

How to make gcc link strong symbol in static library to overwrite weak symbol?

ぃ、小莉子 提交于 2019-11-27 19:45:01
My problem can be summarised in the following: bar.c : #include <stdio.h> void bar() { printf("bar\n"); } main.c : #include <stdio.h> void __attribute__((weak)) bar() { printf("foo\n"); } int main() { bar(); return 0; } Makefile : all: gcc -c bar.c ar -rc libbar.a bar.o gcc main.c -L. -lbar Output : $ ./a.out foo So the weak symbol bar in main.c is not overwritten by the strong symbol in bar.c due to bar.c being linked to main.c in a static library libbar.a. How can I tell gcc to make the strong symbol in libbar.a to overwritten the weak symbol in main.c? max.haredoom Generally speaking: if