Questions tagged [weak-linking]
74 questions
88
votes
2 answers
Weak Linking - check if a class exists and use that class
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…

psychotik
- 38,153
- 34
- 100
- 135
55
votes
6 answers
GCC style weak linking in Visual Studio?
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…

deft_code
- 57,255
- 29
- 141
- 224
34
votes
2 answers
How do I weak link frameworks on Xcode 4?
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…

Quentin Hayot
- 7,786
- 6
- 45
- 62
33
votes
3 answers
How to make gcc link strong symbol in static library to overwrite weak symbol?
My problem can be summarised in the following:
bar.c:
#include
void bar() {
printf("bar\n");
}
main.c:
#include
void __attribute__((weak)) bar() {
printf("foo\n");
}
int main() {
bar();
return…

user1777342
- 433
- 1
- 5
- 11
24
votes
3 answers
What does it mean to "weak-link" a framework?
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…

openfrog
- 40,201
- 65
- 225
- 373
21
votes
1 answer
Dynamic loading and weak symbol resolution
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…

MvG
- 57,380
- 22
- 148
- 276
19
votes
2 answers
Weak linking on iPhone refuses to work
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
…

Jonathan Grynspan
- 43,286
- 8
- 74
- 104
18
votes
2 answers
How to build an iOS framework with weak-linked CocoaPods libraries
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…

Vladimir
- 521
- 5
- 16
14
votes
1 answer
Weak-linking vs "--as-needed"
I'm having trouble with using a library that contains weak-symbols and the --as-needed linker flag.
Example
(This uses the Jack library)
$ cat <myjack.c
#include
#include
int main() {
if (jack_client_opent)
…

umläute
- 28,885
- 9
- 68
- 122
14
votes
1 answer
how can you find out if an NSObject has a certain property?
Let's say in Apple API version 1.0, there is a class NSFoo with a property 'color'. API 1.1 adds property 'size'.
I want to know whether I can use the getter: myFoo.size
[myFoo respondsToSelector:@selector(getSize)] doesn't work as expected.
What's…

strawtarget
- 1,059
- 2
- 9
- 18
12
votes
2 answers
Does LLVM/Clang support the 'weak' attribute for weak linking?
In brief: does LLVM/Clang support the 'weak' attribute?
I'm learning some Arduino library sources (HardwareSerial.cpp to be more detailed) and I've found some interesting attribute weak that I've never used before:
#if defined(HAVE_HWSERIAL0)
void…

4ntoine
- 19,816
- 21
- 96
- 220
7
votes
2 answers
Weak link framework
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…

Fred
- 73
- 1
- 4
7
votes
2 answers
Weak Linked Framework Causing "File Not Found" Error
I am building an app that uses the Social.h and Accounts.h frameworks.
I have both Frameworks set as optional.
I have my Base SDK set as 6.0
I have iOS Deployment Target set as 5.0
When I build the app to my iPhone running 6.0, everything works…

Chris
- 5,485
- 15
- 68
- 130
6
votes
1 answer
Does bitcode support weak linking third party frameworks?
Question stated simply in title. Here is my setup:
Building a dynamic framework that optionally links (weak link) to GoogleInteractiveMediaAds.framework. For apps that use my framework, GoogleInteractiveMediaAds is an optional dependency, and the…

Matt.M
- 1,039
- 3
- 14
- 21
6
votes
1 answer
Weak Linking Foundation and UIKit?
I introduced Printing via AirPrint recently, but wanted to not drop support for pre 4.2 versions (obviously). Done it before for things like Game Center, etc. What I found particularly odd in this case was I had to weak link UIKit. Printing was not…

MarkPowell
- 16,482
- 7
- 61
- 77