Questions tagged [weak-linking]

73 questions
87
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
  • 35,551
  • 33
  • 95
  • 134
45
votes
5 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
  • 51,579
  • 27
  • 135
  • 215
33
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,300
  • 6
  • 43
  • 55
30
votes
2 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
  • 393
  • 1
  • 4
  • 10
21
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
  • 37,829
  • 61
  • 213
  • 364
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
  • 42,652
  • 8
  • 68
  • 102
18
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
  • 51,562
  • 13
  • 126
  • 251
15
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
  • 462
  • 5
  • 16
13
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,029
  • 2
  • 9
  • 18
8
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
  • 23,410
  • 4
  • 50
  • 99
8
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
  • 17,607
  • 16
  • 70
  • 175
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,199
  • 15
  • 61
  • 124
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,294
  • 7
  • 57
  • 76
6
votes
2 answers

Xcode 7: -weak_library and -bitcode_bundle cannot be used together

When deploying to iPhone & Apple Watch with Xcode7, I got this error: ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together Would like to ask how best to resolve this issue ? Follow-ups: Apple Watch…
Felix
  • 751
  • 5
  • 10
1
2 3 4 5