diff --git a/CHANGELOG.md b/CHANGELOG.md index a1d3c3c3aa..a616941149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Made `AccessToken.currentAccessToken` use a Swift name of `current`. - Made `AuthenticationToken.currentAuthenticationToken` use a Swift name of `current`. - Renamed `SharingValidation` protocol to `SharingValidatable`. +- Corrected type definition for `FBSDKUserIdentifier` to be `NSString *` instead of `NSString` for Swift compatibility. [2022-06-03](https://github.com/facebook/facebook-ios-sdk/releases/tag/v14.0.0) | [Full Changelog](https://github.com/facebook/facebook-ios-sdk/compare/v13.2.0...v14.0.0) diff --git a/FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.m b/FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.m index 2837073829..a00d18dad7 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.m +++ b/FBSDKCoreKit/FBSDKCoreKit/FBSDKProfile.m @@ -99,7 +99,7 @@ + (void)setUrlHoster:(nullable id)urlHoster _urlHoster = urlHoster; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -124,7 +124,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID gender:nil]; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -151,7 +151,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID gender:nil]; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -160,7 +160,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID refreshDate:(nullable NSDate *)refreshDate imageURL:(NSURL *)imageURL email:(NSString *)email - friendIDs:(NSArray *)friendIDs + friendIDs:(NSArray *)friendIDs { return [self initWithUserID:userID firstName:firstName @@ -179,7 +179,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID gender:nil]; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -188,7 +188,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID refreshDate:(nullable NSDate *)refreshDate imageURL:(NSURL *)imageURL email:(NSString *)email - friendIDs:(NSArray *)friendIDs + friendIDs:(NSArray *)friendIDs birthday:(NSDate *)birthday ageRange:(FBSDKUserAgeRange *)ageRange { @@ -209,7 +209,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID gender:nil]; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -218,7 +218,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID refreshDate:(nullable NSDate *)refreshDate imageURL:(NSURL *)imageURL email:(NSString *)email - friendIDs:(NSArray *)friendIDs + friendIDs:(NSArray *)friendIDs birthday:(NSDate *)birthday ageRange:(FBSDKUserAgeRange *)ageRange isLimited:(BOOL)isLimited @@ -241,7 +241,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID isLimited:isLimited]; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -250,7 +250,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID refreshDate:(nullable NSDate *)refreshDate imageURL:(nullable NSURL *)imageURL email:(nullable NSString *)email - friendIDs:(nullable NSArray *)friendIDs + friendIDs:(nullable NSArray *)friendIDs birthday:(nullable NSDate *)birthday ageRange:(nullable FBSDKUserAgeRange *)ageRange hometown:(nullable FBSDKLocation *)hometown @@ -278,7 +278,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID return self; } -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -287,7 +287,7 @@ - (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID refreshDate:(nullable NSDate *)refreshDate imageURL:(NSURL *)imageURL email:(NSString *)email - friendIDs:(NSArray *)friendIDs + friendIDs:(NSArray *)friendIDs birthday:(NSDate *)birthday ageRange:(FBSDKUserAgeRange *)ageRange hometown:(FBSDKLocation *)hometown @@ -449,7 +449,7 @@ + (BOOL)supportsSecureCoding - (instancetype)initWithCoder:(NSCoder *)decoder { - FBSDKUserIdentifier *userID = [decoder decodeObjectOfClass:[FBSDKUserIdentifier class] forKey:FBSDKProfileCodingKeyUserID]; + FBSDKUserIdentifier userID = [decoder decodeObjectOfClass:[NSString class] forKey:FBSDKProfileCodingKeyUserID]; NSString *firstName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyFirstName]; NSString *middleName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyMiddleName]; NSString *lastName = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyLastName]; @@ -458,7 +458,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder NSDate *refreshDate = [decoder decodeObjectOfClass:NSDate.class forKey:FBSDKProfileCodingKeyRefreshDate]; NSURL *imageURL = [decoder decodeObjectOfClass:NSURL.class forKey:FBSDKProfileCodingKeyImageURL]; NSString *email = [decoder decodeObjectOfClass:NSString.class forKey:FBSDKProfileCodingKeyEmail]; - NSArray *friendIDs = [decoder decodeObjectOfClass:NSArray.class forKey:FBSDKProfileCodingKeyFriendIDs]; + NSArray *friendIDs = [decoder decodeObjectOfClass:NSArray.class forKey:FBSDKProfileCodingKeyFriendIDs]; BOOL isLimited = [decoder decodeBoolForKey:FBSDKProfileCodingKeyIsLimited]; NSDate *birthday = [decoder decodeObjectOfClass:NSDate.class forKey:FBSDKProfileCodingKeyBirthday]; FBSDKUserAgeRange *ageRange = [decoder decodeObjectOfClass:FBSDKUserAgeRange.class forKey:FBSDKProfileCodingKeyAgeRange]; @@ -545,7 +545,7 @@ + (nullable FBSDKProfile *)fetchCachedProfile return nil; } -+ (NSURL *)imageURLForProfileID:(FBSDKUserIdentifier *)profileId ++ (NSURL *)imageURLForProfileID:(FBSDKUserIdentifier)profileId pictureMode:(FBSDKProfilePictureMode)mode size:(CGSize)size { @@ -655,7 +655,7 @@ + (void)loadProfileWithToken:(FBSDKAccessToken *)token if (urlString) { linkUrl = [FBSDKTypeUtility coercedToURLValue:[NSURL URLWithString:urlString]]; } - NSArray *friendIDs = [self friendIDsFromGraphResult:[FBSDKTypeUtility dictionaryValue:result[@"friends"]]]; + NSArray *friendIDs = [self friendIDsFromGraphResult:[FBSDKTypeUtility dictionaryValue:result[@"friends"]]]; FBSDKUserAgeRange *ageRange = [FBSDKUserAgeRange ageRangeFromDictionary:[FBSDKTypeUtility dictionaryValue:result[@"age_range"]]]; [FBSDKProfile.dateFormatter setDateFormat:@"MM/dd/yyyy"]; @@ -728,14 +728,14 @@ + (void)observeChangeAccessTokenChange:(NSNotification *)notification [self loadProfileWithToken:token completion:NULL]; } -+ (nullable NSArray *)friendIDsFromGraphResult:(NSDictionary *)result ++ (nullable NSArray *)friendIDsFromGraphResult:(NSDictionary *)result { NSArray *> *rawFriends = [FBSDKTypeUtility arrayValue:result[@"data"]]; - NSMutableArray *friendIDs = [NSMutableArray new]; + NSMutableArray *friendIDs = [NSMutableArray new]; for (NSDictionary *rawFriend in rawFriends) { if ([FBSDKTypeUtility dictionaryValue:rawFriend]) { - FBSDKUserIdentifier *friendID = [FBSDKTypeUtility coercedToStringValue:rawFriend[@"id"]]; + FBSDKUserIdentifier friendID = [FBSDKTypeUtility coercedToStringValue:rawFriend[@"id"]]; [FBSDKTypeUtility array:friendIDs addObject:friendID]; } } diff --git a/FBSDKCoreKit/FBSDKCoreKit/include/FBSDKProfile.h b/FBSDKCoreKit/FBSDKCoreKit/include/FBSDKProfile.h index 6e648a0de0..6f3b63a419 100644 --- a/FBSDKCoreKit/FBSDKCoreKit/include/FBSDKProfile.h +++ b/FBSDKCoreKit/FBSDKCoreKit/include/FBSDKProfile.h @@ -50,8 +50,7 @@ typedef void (^ FBSDKProfileBlock)(FBSDKProfile *_Nullable profile, NSError *_Nu NS_SWIFT_NAME(ProfileBlock); /// Represents the unique identifier for an end user -typedef NSString FBSDKUserIdentifier - NS_SWIFT_NAME(UserIdentifier); +typedef NSString *FBSDKUserIdentifier NS_SWIFT_NAME(UserIdentifier) NS_SWIFT_BRIDGED_TYPEDEF; /** Represents an immutable Facebook profile @@ -81,7 +80,7 @@ NS_SWIFT_NAME(Profile) @param linkURL the link for this profile @param refreshDate the optional date this profile was fetched. Defaults to [NSDate date]. */ -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -109,7 +108,7 @@ NS_SWIFT_NAME(Profile) When true, `loadCurrentProfileWithCompletion:` will assume the profile is incomplete and disregard any cached profile. Defaults to false. */ -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -118,7 +117,7 @@ NS_SWIFT_NAME(Profile) refreshDate:(nullable NSDate *)refreshDate imageURL:(nullable NSURL *)imageURL email:(nullable NSString *)email - friendIDs:(nullable NSArray *)friendIDs + friendIDs:(nullable NSArray *)friendIDs birthday:(nullable NSDate *)birthday ageRange:(nullable FBSDKUserAgeRange *)ageRange hometown:(nullable FBSDKLocation *)hometown @@ -144,7 +143,7 @@ NS_SWIFT_NAME(Profile) @param location the user's location @param gender the user's gender */ -- (instancetype)initWithUserID:(FBSDKUserIdentifier *)userID +- (instancetype)initWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -153,7 +152,7 @@ NS_SWIFT_NAME(Profile) refreshDate:(nullable NSDate *)refreshDate imageURL:(nullable NSURL *)imageURL email:(nullable NSString *)email - friendIDs:(nullable NSArray *)friendIDs + friendIDs:(nullable NSArray *)friendIDs birthday:(nullable NSDate *)birthday ageRange:(nullable FBSDKUserAgeRange *)ageRange hometown:(nullable FBSDKLocation *)hometown @@ -173,7 +172,7 @@ NS_SWIFT_NAME(Profile) NS_SWIFT_NAME(current); /// The user id -@property (nonatomic, readonly, copy) FBSDKUserIdentifier *userID; +@property (nonatomic, readonly, copy) FBSDKUserIdentifier userID; /// The user's first name @property (nullable, nonatomic, readonly, copy) NSString *firstName; /// The user's middle name @@ -207,7 +206,7 @@ NS_SWIFT_NAME(current); IMPORTANT: This field will only be populated if your user has granted your application the 'user_friends' permission. */ -@property (nullable, nonatomic, readonly, copy) NSArray *friendIDs; +@property (nullable, nonatomic, readonly, copy) NSArray *friendIDs; /** The user's birthday. diff --git a/FBSDKLoginKit/FBSDKLoginKit/FBSDKProfileCreating.h b/FBSDKLoginKit/FBSDKLoginKit/FBSDKProfileCreating.h index 64d027a1fa..3a6e6a1153 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/FBSDKProfileCreating.h +++ b/FBSDKLoginKit/FBSDKLoginKit/FBSDKProfileCreating.h @@ -8,10 +8,11 @@ #if !TARGET_OS_TV +#import + @class FBSDKLocation; @class FBSDKProfile; @class FBSDKUserAgeRange; -typedef NSString FBSDKUserIdentifier; NS_ASSUME_NONNULL_BEGIN @@ -25,7 +26,7 @@ NS_SWIFT_NAME(_ProfileCreating) @protocol FBSDKProfileCreating // UNCRUSTIFY_FORMAT_OFF -- (FBSDKProfile *)createProfileWithUserID:(FBSDKUserIdentifier *)userID +- (FBSDKProfile *)createProfileWithUserID:(FBSDKUserIdentifier)userID firstName:(nullable NSString *)firstName middleName:(nullable NSString *)middleName lastName:(nullable NSString *)lastName @@ -34,7 +35,7 @@ NS_SWIFT_NAME(_ProfileCreating) refreshDate:(nullable NSDate *)refreshDate imageURL:(nullable NSURL *)imageURL email:(nullable NSString *)email - friendIDs:(nullable NSArray *)friendIDs + friendIDs:(nullable NSArray *)friendIDs birthday:(nullable NSDate *)birthday ageRange:(nullable FBSDKUserAgeRange *)ageRange hometown:(nullable FBSDKLocation *)hometown diff --git a/FBSDKLoginKit/FBSDKLoginKit/Internal/_ProfileFactory.swift b/FBSDKLoginKit/FBSDKLoginKit/Internal/_ProfileFactory.swift index 81cef4499d..2bd107c04c 100644 --- a/FBSDKLoginKit/FBSDKLoginKit/Internal/_ProfileFactory.swift +++ b/FBSDKLoginKit/FBSDKLoginKit/Internal/_ProfileFactory.swift @@ -8,6 +8,8 @@ #if !os(tvOS) +import FBSDKCoreKit + /** Internal Type exposed to facilitate transition to Swift. API Subject to change or removal without warning. Do not use. @@ -20,7 +22,7 @@ public final class _ProfileFactory: NSObject, _ProfileCreating { // swiftlint:disable:next function_parameter_count public func createProfile( - userID: String, + userID: UserIdentifier, firstName: String?, middleName: String?, lastName: String?,