Skip to content

Commit

Permalink
Remove Bolts Framework
Browse files Browse the repository at this point in the history
Summary:
The Bolts framework served a minor role in this SDK, but maintaining this dependency was a decent pain point.

This diff removes the dependency on this framework.

Reviewed By: jingping2015

Differential Revision: D10440950

fbshipit-source-id: 58d78f9989ff394b3b29bf39314699cd31ba4898
  • Loading branch information
Cody Winton authored and facebook-github-bot committed Jan 17, 2019
1 parent 9d3dd8f commit 0bdd850
Show file tree
Hide file tree
Showing 35 changed files with 62 additions and 1,125 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "Carthage/Checkouts/Bolts-ObjC"]
path = Carthage/Checkouts/Bolts-ObjC
url = https://github.com/BoltsFramework/Bolts-ObjC.git
[submodule "Carthage/Checkouts/OHHTTPStubs"]
path = Carthage/Checkouts/OHHTTPStubs
url = https://github.com/AliSoftware/OHHTTPStubs.git
Expand Down
1 change: 0 additions & 1 deletion Cartfile

This file was deleted.

1 change: 0 additions & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
github "AliSoftware/OHHTTPStubs" "826a9217fcd468220d154ed0075cbc1a20d0c5c9"
github "BoltsFramework/Bolts-ObjC" "1b247a7047546e9eecd36387a121977b53e2ea43"
github "erikdoe/ocmock" "c4be5d9d9238fcd10449424f651fba2b7aff87c0"
github "facebook/Tweaks" "858506f594462073a1dee82a4c8254e23d10aef0"
github "facebook/xctool" "fe6fb5dfab112cfbb0a2fbda1f6a528abbe0d272"
1 change: 0 additions & 1 deletion Carthage/Checkouts/Bolts-ObjC
Submodule Bolts-ObjC deleted from 1b247a
2 changes: 0 additions & 2 deletions FBSDKCoreKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Pod::Spec.new do |s|
s.requires_arc = ['FBSDKCoreKit/FBSDKCoreKit/*',
'FBSDKCoreKit/FBSDKCoreKit/Internal/**/*']

s.ios.dependency 'Bolts', '~> 1.9'

s.public_header_files = 'FBSDKCoreKit/FBSDKCoreKit/*.h'
s.source_files = 'FBSDKCoreKit/FBSDKCoreKit/**/*.{h,m}'
s.resources = 'FacebookSDKStrings.bundle'
Expand Down
271 changes: 15 additions & 256 deletions FBSDKCoreKit/FBSDKCoreKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,6 @@
ReferencedContainer = "container:FBSDKCoreKit.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "81ED94111BE147CF00795F05"
BuildableName = "Bolts.framework"
BlueprintName = "Bolts-iOS"
ReferencedContainer = "container:../Carthage/Checkouts/Bolts-ObjC/Bolts.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down
67 changes: 6 additions & 61 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkResolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,75 +20,18 @@

#import "FBSDKAppLinkResolving.h"

@class BFTask;


// Check if Bolts.framework is available for import
#if __has_include(<Bolts/BFAppLinkResolving.h>)
// Import it if it's available
#import <Bolts/BFAppLinkResolving.h>
#else
// Otherwise - redeclare BFAppLinkResolving protocol to resolve the problem of missing symbols
// Please note: Bolts.framework is still required for AppLink resolving to work,
// but this allows FBSDKCoreKit to weakly link Bolts.framework as well as this enables clang modulemaps to work.

/**
Implement this protocol to provide an alternate strategy for resolving
App Links that may include pre-fetching, caching, or querying for App Link
data from an index provided by a service provider.
*/
DEPRECATED_MSG_ATTRIBUTE("Use `FBSDKAppLinkResolving`")
@protocol BFAppLinkResolving <NSObject>

/**
Asynchronously resolves App Link data for a given URL.
@param url The URL to resolve into an App Link.
@return A BFTask that will return a BFAppLink for the given URL.
*/
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURL:handler:`");

@end

#endif
NS_ASSUME_NONNULL_BEGIN

/**
Provides an implementation of the BFAppLinkResolving protocol that uses the Facebook App Link
Provides an implementation of the FBSDKAppLinkResolving protocol that uses the Facebook App Link
Index API to resolve App Links given a URL. It also provides an additional helper method that can resolve
multiple App Links in a single call.
Usage of this type requires a client token. See `[FBSDKSettings setClientToken:]` and linking
Bolts.framework
Usage of this type requires a client token. See `[FBSDKSettings setClientToken:]`
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@interface FBSDKAppLinkResolver : NSObject<FBSDKAppLinkResolving, BFAppLinkResolving>
#pragma clang diagnostic pop

/**
Asynchronously resolves App Link data for multiple URLs.
@param urls An array of NSURLs to resolve into App Links.
@return A BFTask that will return dictionary mapping input NSURLs to their
corresponding BFAppLink.

You should set the client token before making this call. See `[FBSDKSettings setClientToken:]`
*/
- (BFTask *)appLinksFromURLsInBackground:(NSArray<NSURL *> *)urls
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURLs:handler:`");

/**
Asynchronously resolves App Link data for a given URL.
@param url The URL to resolve into an App Link.
@return A BFTask that will return a BFAppLink for the given URL.
*/
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
DEPRECATED_MSG_ATTRIBUTE("Use `appLinkFromURL:handler:`");
@interface FBSDKAppLinkResolver : NSObject<FBSDKAppLinkResolving>

/**
Asynchronously resolves App Link data for a given array of URLs.
Expand All @@ -105,3 +48,5 @@ NS_EXTENSION_UNAVAILABLE_IOS("Not available in app extension");
+ (instancetype)resolver;

@end

NS_ASSUME_NONNULL_END
127 changes: 1 addition & 126 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkResolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@

#import <UIKit/UIKit.h>

#import <Bolts/BFAppLink.h>
#import <Bolts/BFAppLinkTarget.h>
#import <Bolts/BFTask.h>
#import <Bolts/BFTaskCompletionSource.h>

#import "FBSDKAccessToken.h"
#import "FBSDKAppLink.h"
#import "FBSDKAppLinkTarget.h"
#import "FBSDKGraphRequest+Internal.h"
#import "FBSDKGraphRequestConnection.h"
#import "FBSDKInternalUtility.h"
Expand All @@ -46,33 +42,21 @@

@interface FBSDKAppLinkResolver ()

@property (nonatomic, strong) NSMutableDictionary<NSURL *, BFAppLink *> *cachedBFAppLinks;
@property (nonatomic, strong) NSMutableDictionary<NSURL *, FBSDKAppLink *> *cachedFBSDKAppLinks;
@property (nonatomic, assign) UIUserInterfaceIdiom userInterfaceIdiom;
@end

@implementation FBSDKAppLinkResolver

static Class g_BFTaskCompletionSourceClass;
static Class g_BFAppLinkTargetClass;
static Class g_BFAppLinkClass;
static Class g_BFTaskClass;

+ (void)initialize
{
if (self == [FBSDKAppLinkResolver class]) {
g_BFTaskCompletionSourceClass = [FBSDKInternalUtility
resolveBoltsClassWithName:@"BFTaskCompletionSource"];
g_BFAppLinkTargetClass = [FBSDKInternalUtility resolveBoltsClassWithName:@"BFAppLinkTarget"];
g_BFTaskClass = [FBSDKInternalUtility resolveBoltsClassWithName:@"BFTask"];
g_BFAppLinkClass = [FBSDKInternalUtility resolveBoltsClassWithName:@"BFAppLink"];
}
}

- (instancetype)initWithUserInterfaceIdiom:(UIUserInterfaceIdiom)userInterfaceIdiom
{
if (self = [super init]) {
self.cachedBFAppLinks = [NSMutableDictionary dictionary];
self.cachedFBSDKAppLinks = [NSMutableDictionary dictionary];
self.userInterfaceIdiom = userInterfaceIdiom;
}
Expand Down Expand Up @@ -182,115 +166,6 @@ - (void)appLinksFromURLs:(NSArray<NSURL *> *)urls handler:(FBSDKAppLinksFromURLA
}];
}

- (BFTask *)appLinksFromURLsInBackground:(NSArray *)urls
{
if (![FBSDKSettings clientToken] && ![FBSDKAccessToken currentAccessToken]) {
[FBSDKLogger singleShotLogEntry:FBSDKLoggingBehaviorDeveloperErrors
logEntry:@"A user access token or clientToken is required to use FBAppLinkResolver"];
}
NSMutableDictionary<NSURL *, BFAppLink *> *appLinks = [NSMutableDictionary dictionary];
NSMutableArray<NSURL *> *toFind = [NSMutableArray array];
NSMutableArray<NSString *> *toFindStrings = [NSMutableArray array];

@synchronized (self.cachedBFAppLinks) {
for (NSURL *url in urls) {
if (self.cachedBFAppLinks[url]) {
appLinks[url] = self.cachedBFAppLinks[url];
} else {
[toFind addObject:url];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSString *toFindString = [url.absoluteString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
#pragma clang diagnostic pop
if (toFindString) {
[toFindStrings addObject:toFindString];
}
}
}
}
if (toFind.count == 0) {
// All of the URLs have already been found.
return [g_BFTaskClass taskWithResult:appLinks];
}
NSMutableArray<NSString *> *fields = [NSMutableArray arrayWithObject:kIOSKey];

NSString *idiomSpecificField = nil;

switch (self.userInterfaceIdiom) {
case UIUserInterfaceIdiomPad:
idiomSpecificField = kIPadKey;
break;
case UIUserInterfaceIdiomPhone:
idiomSpecificField = kIPhoneKey;
break;
default:
break;
}
if (idiomSpecificField) {
[fields addObject:idiomSpecificField];
}
NSString *path = [NSString stringWithFormat:@"?fields=%@.fields(%@)&ids=%@",
kAppLinksKey,
[fields componentsJoinedByString:@","],
[toFindStrings componentsJoinedByString:@","]];
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:path
parameters:nil
flags:FBSDKGraphRequestFlagDoNotInvalidateTokenOnError | FBSDKGraphRequestFlagDisableErrorRecovery];
BFTaskCompletionSource *tcs = [g_BFTaskCompletionSourceClass taskCompletionSource];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (error) {
[tcs setError:error];
return;
}
for (NSURL *url in toFind) {
id nestedObject = result[url.absoluteString][kAppLinksKey];
NSMutableArray *rawTargets = [NSMutableArray array];
if (idiomSpecificField) {
[rawTargets addObjectsFromArray:nestedObject[idiomSpecificField]];
}
[rawTargets addObjectsFromArray:nestedObject[kIOSKey]];

NSMutableArray<BFAppLinkTarget *> *targets = [NSMutableArray arrayWithCapacity:rawTargets.count];
for (id rawTarget in rawTargets) {
[targets addObject:[g_BFAppLinkTargetClass appLinkTargetWithURL:[NSURL URLWithString:rawTarget[kURLKey]]
appStoreId:rawTarget[kIOSAppStoreIdKey]
appName:rawTarget[kIOSAppNameKey]]];
}

id webTarget = nestedObject[kWebKey];
NSString *webFallbackString = webTarget[kURLKey];
NSURL *fallbackUrl = webFallbackString ? [NSURL URLWithString:webFallbackString] : url;

NSNumber *shouldFallback = webTarget[kShouldFallbackKey];
if (shouldFallback && !shouldFallback.boolValue) {
fallbackUrl = nil;
}

BFAppLink *link = [g_BFAppLinkClass appLinkWithSourceURL:url
targets:targets
webURL:fallbackUrl];
@synchronized (self.cachedBFAppLinks) {
self.cachedBFAppLinks[url] = link;
}
appLinks[url] = link;
}
[tcs setResult:appLinks];
}];
return tcs.task;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (BFTask *)appLinkFromURLInBackground:(NSURL *)url
{
// Implement in terms of appLinksFromURLsInBackground
BFTask *resolveTask = [self appLinksFromURLsInBackground:@[url]];
return [resolveTask continueWithSuccessBlock:^id(BFTask *task) {
return task.result[url];
}];
}
#pragma clang diagnostic pop

+ (instancetype)resolver
{
return [[self alloc] initWithUserInterfaceIdiom:UI_USER_INTERFACE_IDIOM()];
Expand Down
6 changes: 1 addition & 5 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,7 @@ typedef void (^FBSDKDeferredAppInviteHandler)(NSURL *url);
DEPRECATED_MSG_ATTRIBUTE("This method is no longer available.");

/*
Call this method to fetch promotion code from the url, if it's present. This function
requires Bolts framework.
Note: This throws an exception if Bolts.framework is not linked. Add '[BFURL class]' in intialize method
of your AppDelegate.
Call this method to fetch promotion code from the url, if it's present.
@param url App Link url that was passed to the app.
Expand Down
5 changes: 2 additions & 3 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKAppLinkUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@

#import "FBSDKAppLinkUtility.h"

#import <Bolts/BFURL.h>

#import "FBSDKAppEventsUtility.h"
#import "FBSDKGraphRequest.h"
#import "FBSDKInternalUtility.h"
#import "FBSDKSettings.h"
#import "FBSDKURL.h"
#import "FBSDKUtility.h"

static NSString *const FBSDKLastDeferredAppLink = @"com.facebook.sdk:lastDeferredAppLink%@";
Expand Down Expand Up @@ -87,7 +86,7 @@ + (BOOL)fetchDeferredAppInvite:(FBSDKDeferredAppInviteHandler)handler

+ (NSString*)appInvitePromotionCodeFromURL:(NSURL*)url;
{
BFURL *parsedUrl = [[FBSDKInternalUtility resolveBoltsClassWithName:@"BFURL"] URLWithURL:url];
FBSDKURL *parsedUrl = [FBSDKURL URLWithURL:url];
NSDictionary *extras = parsedUrl.appLinkExtras;
if (extras) {
NSString *deeplinkContextString = extras[@"deeplink_context"];
Expand Down
6 changes: 3 additions & 3 deletions FBSDKCoreKit/FBSDKCoreKit/FBSDKApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#import "FBSDKUtility.h"

#if !TARGET_OS_TV
#import "FBSDKBoltsMeasurementEventListener.h"
#import "FBSDKMeasurementEventListener.h"
#import "FBSDKBridgeAPIRequest.h"
#import "FBSDKBridgeAPIResponse.h"
#import "FBSDKContainerViewController.h"
Expand Down Expand Up @@ -104,8 +104,8 @@ + (void)initializeWithLaunchData:(NSNotification *)note
[[self sharedInstance] application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:launchData];

#if !TARGET_OS_TV
// Register Listener for Bolts measurement events
[FBSDKBoltsMeasurementEventListener defaultListener];
// Register Listener for App Link measurement events
[FBSDKMeasurementEventListener defaultListener];
#endif
// Set the SourceApplication for time spent data. This is not going to update the value if the app has already launched.
[FBSDKTimeSpentData setSourceApplication:launchData[UIApplicationLaunchOptionsSourceApplicationKey]
Expand Down
2 changes: 1 addition & 1 deletion FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ FOUNDATION_EXPORT NSString *const FBSDKProfileChangeNewKey;
/**
A URL to the user's profile.
Consider using Bolts and `FBSDKAppLinkResolver` to resolve this
Consider using `FBSDKAppLinkResolver` to resolve this
to an app link to link directly to the user's profile in the Facebook app.
*/
@property (nonatomic, readonly) NSURL *linkURL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@

#import <Foundation/Foundation.h>

@interface FBSDKBoltsMeasurementEventListener : NSObject
+ (FBSDKBoltsMeasurementEventListener *)defaultListener;
@interface FBSDKMeasurementEventListener : NSObject
+ (FBSDKMeasurementEventListener *)defaultListener;
@end
Loading

0 comments on commit 0bdd850

Please sign in to comment.