weak-linking

Weak-linking multiple frameworks for iPhone Apps (-weak_framework)

一世执手 提交于 2019-11-27 19:02:22
问题 How do I specify -weak_framework for multiple frameworks while compiling iPhone apps for older deployment targets? 回答1: In the Build Phases section of your target, you've got the list of the linked frameworks. For each one, you can select Required or Optional , optional meaning weak. 回答2: Add a linker flag -weak_framework < framework_name> Check this link: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html 来源: https://stackoverflow

Does Android support weak symbols?

霸气de小男生 提交于 2019-11-27 07:36:45
问题 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,

Alternatives to weak linking in iPhone SDK?

妖精的绣舞 提交于 2019-11-26 22:51:45
问题 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) ? 回答1: 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 ,

How do I weak link frameworks on Xcode 4?

浪尽此生 提交于 2019-11-26 22:49:13
I need to weak link some framework with my target. But I can't find how to do it... If I try to run my project on 3.2 iPad simulator i get the following error: dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd Reason : Image not found Thanks ! Go to your project -> Targets -> Build Phases -> Link Binary with Libraries. Then change the library you want to weak-link from "Required" to "Optional". ronguotech This doesn't work now. Please follow the link below: https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html

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

青春壹個敷衍的年華 提交于 2019-11-26 20:01:30
问题 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. 回答1: 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

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

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 19:51:30
问题 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

GCC style weak linking in Visual Studio?

a 夏天 提交于 2019-11-26 18:49:18
GCC has the ability to make a symbol link weakly via __attribute__((weak)) . I want to use the a weak symbol in a static library that users can override in their application. A GCC style weak symbol would let me do that, but I don't know if it can be done with visual studio. Does Visual Studio offer a similar feature? MSVC++ has __declspec(selectany) which covers part of the functionality of weak symbols: it allows you to define multiple identical symbols with external linkage, directing the compiler to choose any one of several available. However, I don't think MSVC++ has anything that would

Weak linking on iPhone refuses to work

删除回忆录丶 提交于 2019-11-26 17:44:20
问题 I've got an iPhone app that's mainly targetting 3.0, but which takes advantage of newer APIs when they're available. Code goes something like this: if (UIApplicationDidEnterBackgroundNotification != NULL) { [nc addObserver: self selector: @selector(irrelevantCallbackName:) name: UIApplicationDidEnterBackgroundNotification object: nil]; } Now, according to everything Apple's ever said, if the relevant APIs are weakly linked, that will work fine because the dynamic linker will evaluate

Weak Linking - check if a class exists and use that class

跟風遠走 提交于 2019-11-26 14:16:49
I'm trying to create a universal iPhone app, but it uses a class defined only in a newer version of the SDK. The framework exists on older systems, but a class defined in the framework doesn't. I know I want to use some kind of weak linking, but any documentation I can find talks about runtime checks for function existence - how do I check that a class exists? Senseful TLDR Current: Swift : if #available(iOS 9, *) Obj-C, iOS : if (@available(iOS 11.0, *)) Obj-C, OS X : if (NSClassFromString(@"UIAlertController")) Legacy: Swift (versions prior to 2.0) : if objc_getClass("UIAlertController") Obj

How do I weak link frameworks on Xcode 4?

我是研究僧i 提交于 2019-11-26 08:27:00
问题 I need to weak link some framework with my target. But I can\'t find how to do it... If I try to run my project on 3.2 iPad simulator i get the following error: dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd Reason : Image not found Thanks ! 回答1: Go to your project -> Targets -> Build Phases -> Link Binary with Libraries. Then change the library you want to weak-link from "Required" to "Optional". 回答2: This doesn't work now. Please follow the link below: https:/