2016-08-12 00:02:00 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2017-07-26 19:55:30 +03:00
|
|
|
@class FBWeakFramework;
|
2018-05-25 18:06:30 +03:00
|
|
|
@protocol FBControlCoreLogger;
|
2017-07-26 19:55:30 +03:00
|
|
|
|
2017-06-29 13:29:19 +03:00
|
|
|
/**
|
|
|
|
Loads a Symbol from a Handle, using dlsym.
|
2019-03-04 12:58:38 +03:00
|
|
|
Will assert if the symbol cannot be found.
|
2017-06-29 13:29:19 +03:00
|
|
|
|
|
|
|
@param handle the handle to obtain.
|
|
|
|
@param name the name of the symbol.
|
|
|
|
@return the Symbol if successful.
|
|
|
|
*/
|
|
|
|
void *FBGetSymbolFromHandle(void *handle, const char *name);
|
|
|
|
|
2019-03-04 12:58:38 +03:00
|
|
|
/**
|
|
|
|
Loads a Symbol from a Handle, using dlsym.
|
|
|
|
Will return a NULL pointer if the symbol cannot be found.
|
|
|
|
|
|
|
|
@param handle the handle to obtain.
|
|
|
|
@param name the name of the symbol.
|
|
|
|
@return the Symbol if successful.
|
|
|
|
*/
|
|
|
|
void *FBGetSymbolFromHandleOptional(void *handle, const char *name);
|
|
|
|
|
2016-08-12 00:02:00 +03:00
|
|
|
/**
|
|
|
|
A Base Framework loader, that will ensure that the current user can load Frameworks.
|
|
|
|
*/
|
|
|
|
@interface FBControlCoreFrameworkLoader : NSObject
|
|
|
|
|
2019-02-22 18:38:01 +03:00
|
|
|
#pragma mark Initializers
|
|
|
|
|
2017-07-26 19:55:30 +03:00
|
|
|
/**
|
2019-02-22 18:38:01 +03:00
|
|
|
The Designated Initializer
|
|
|
|
|
|
|
|
@param frameworkName the name of the loading framework.
|
|
|
|
@param frameworks the framework dependencies
|
|
|
|
@return a new Framework Loader
|
2017-07-26 19:55:30 +03:00
|
|
|
*/
|
|
|
|
+ (instancetype)loaderWithName:(NSString *)frameworkName frameworks:(NSArray<FBWeakFramework *> *)frameworks;
|
|
|
|
|
2019-02-22 18:38:01 +03:00
|
|
|
/**
|
|
|
|
The Designated Initializer
|
|
|
|
|
|
|
|
@param frameworkName the name of the loading framework.
|
|
|
|
@param frameworks the framework dependencies
|
|
|
|
@return a new Framework Loader
|
|
|
|
*/
|
|
|
|
- (instancetype)initWithName:(NSString *)frameworkName frameworks:(NSArray<FBWeakFramework *> *)frameworks;
|
|
|
|
|
|
|
|
#pragma mark Properties
|
|
|
|
|
2017-07-26 19:55:30 +03:00
|
|
|
/**
|
|
|
|
The Named set of Frameworks.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, copy, readonly) NSString *frameworkName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
The Frameworks to load.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, copy, readonly) NSArray<FBWeakFramework *> *frameworks;
|
|
|
|
|
|
|
|
/**
|
|
|
|
YES if the Frameworks are loaded, NO otherwise.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign, readonly) BOOL hasLoadedFrameworks;
|
|
|
|
|
2019-02-22 18:38:01 +03:00
|
|
|
#pragma mark Public Methods
|
|
|
|
|
2016-08-12 00:02:00 +03:00
|
|
|
/**
|
|
|
|
Confirms that the current user can load Frameworks.
|
|
|
|
Subclasses should load the frameworks upon which they depend.
|
|
|
|
|
|
|
|
@param logger the Logger to log events to.
|
|
|
|
@param error any error that occurred during performing the preconditions.
|
2017-08-30 16:49:41 +03:00
|
|
|
@return YES if FBSimulatorControl is usable, NO otherwise.
|
2016-08-12 00:02:00 +03:00
|
|
|
*/
|
2017-07-26 19:55:30 +03:00
|
|
|
- (BOOL)loadPrivateFrameworks:(nullable id<FBControlCoreLogger>)logger error:(NSError **)error;
|
2016-08-12 00:02:00 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
Calls +[FBControlCore loadPrivateFrameworks:error], aborting in the event the Frameworks could not be loaded
|
|
|
|
*/
|
2017-07-26 19:55:30 +03:00
|
|
|
- (void)loadPrivateFrameworksOrAbort;
|
2016-08-12 00:02:00 +03:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2018-05-25 18:06:30 +03:00
|
|
|
/**
|
|
|
|
Wrappers around NSBundle.
|
|
|
|
*/
|
|
|
|
@interface NSBundle (FBControlCoreFrameworkLoader)
|
|
|
|
|
|
|
|
/**
|
|
|
|
Performs a dlopen on the executable path and returns the handle, or else aborts.
|
|
|
|
*/
|
|
|
|
- (void *)dlopenExecutablePath;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2016-08-12 00:02:00 +03:00
|
|
|
NS_ASSUME_NONNULL_END
|