0

Is adding Framework in Xcode necessary?

For using MultipeerConnectivity.

I only add #import header file, on the .h or .m file,

instead of adding MultipeerConnectivity.framework in Link Binary With Libraries or

adding the framework in project.

Is there any drawback about my behavior?

Thank you for precious time on my question.

Best,

2 Answers 2

1

If all you need from the framework header is a #defined constant, then you might not need to link to a framework. Otherwise, it is necessary to tell Xcode what framework to use so the linker can complete its job.

Also, There may be more than one framework that provides the same symbols, but provides different implementations of them. So it is necessary to specify which framework to use.

Sign up to request clarification or add additional context in comments.

Comments

1

You don't need to explicitly link and bundle Apple frameworks since they're already included on the device. Typically when including frameworks you #import what's known as an "umbrella header". This is basically a header file that contains #import statements for all of the framework header files.

For example, MultipeerConnectivity/MultipeerConnectivity.h looks like this:

//
//  MultipeerConnectivity.h
//  MultipeerConnectivity
//
//  Copyright 2013 Apple Inc. All rights reserved.
//

// MultipeerConnectivity headers
#import <MultipeerConnectivity/MCError.h>
#import <MultipeerConnectivity/MCPeerID.h>
#import <MultipeerConnectivity/MCNearbyServiceAdvertiser.h>
#import <MultipeerConnectivity/MCNearbyServiceBrowser.h>
#import <MultipeerConnectivity/MCSession.h>
#import <MultipeerConnectivity/MCBrowserViewController.h>
#import <MultipeerConnectivity/MCAdvertiserAssistant.h>

As part of learning more about this topic you should also check out information about weak linking.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.