google/promises

'NSInvalidArgumentException', reason: '-[FBLPromise HTTPBody]: unrecognized selector sent to instance

johndpope opened this issue · 1 comments

I'm stuck integrating firebase with bazel - I have made some progress
firebase/firebase-ios-sdk#6115

but when I run the build - the xcframework that's built with firebase analytics - doesn't have this method - HTTPBody

Screen Shot 2022-08-30 at 10 06 11 pm

Screen Shot 2022-08-30 at 10 07 02 pm

I'm using this BUILD file inside FirebaseAnalytics directory

load("@build_bazel_rules_apple//apple:apple.bzl",
    "apple_dynamic_xcframework_import","apple_static_xcframework_import"
)




objc_library(
    name = "FirebaseAnalytics",
    deps = ["FirebaseAnalyticsXCFramework"],
    enable_modules = True,
    module_name = "FirebaseAnalytics",
    visibility = ["//visibility:public"],

)


objc_library(
    name = "FBLPromises",
    deps = ["FBLPromisesXCFramework"],
    enable_modules = True,
    module_name = "FBLPromises",
    visibility = ["//visibility:public"],

)


apple_static_xcframework_import(
    name = "FirebaseAnalyticsXCFramework",
    xcframework_imports = glob(["FirebaseAnalytics.xcframework/**"] ),
    library_identifiers = {
        "ios_device": "ios-arm64_armv7",
        "ios_simulator": "ios-arm64_i386_x86_64-simulator",
    },
    deps = ["FBLPromisesXCFramework",
    "FirebaseAnalyticsSwiftXCFramework",
    "FirebaseCoreXCFramework"
    ,"FirebaseCoreDiagnosticsXCFramework", 
    "FirebaseCoreInternalXCFramework",
    "FirebaseInstallationsXCFramework",
    "GoogleAppMeasurementXCFramework",
    "GoogleAppMeasurementIdentitySupportXCFramework",
    "GoogleUtilitiesXCFramework",
    "GoogleDataTransportXCFramework",
    "nanopbXCFramework",
    ],
    visibility = ["//visibility:public"],
)





apple_dynamic_xcframework_import(
    name = "FBLPromisesXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FBLPromises.xcframework/**"] ),
)



apple_dynamic_xcframework_import(
    name = "FirebaseAnalyticsSwiftXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FirebaseAnalyticsSwift.xcframework/**"] ),
)

apple_dynamic_xcframework_import(
    name = "FirebaseCoreXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FirebaseCore.xcframework/**"] ),
      visibility = ["//visibility:public"],
)

apple_dynamic_xcframework_import(
    name = "FirebaseCoreDiagnosticsXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FirebaseCoreDiagnostics.xcframework/**"] ),
)

apple_dynamic_xcframework_import(
    name = "FirebaseCoreInternalXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FirebaseCoreInternal.xcframework/**"] ),
)


apple_dynamic_xcframework_import(
    name = "FirebaseInstallationsXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["FirebaseInstallations.xcframework/**"] ),
)


apple_dynamic_xcframework_import(
    name = "GoogleAppMeasurementXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64_armv7",
        "ios_simulator": "ios-arm64_i386_x86_64-simulator",
    },
    xcframework_imports = glob(["GoogleAppMeasurement.xcframework/**"] ),
)

apple_dynamic_xcframework_import(
    name = "GoogleAppMeasurementIdentitySupportXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64_armv7",
        "ios_simulator": "ios-arm64_i386_x86_64-simulator",
    },
    xcframework_imports = glob(["GoogleAppMeasurementIdentitySupport.xcframework/**"] ),
)

apple_dynamic_xcframework_import(
    name = "GoogleDataTransportXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["GoogleDataTransport.xcframework/**"] ),
)


apple_dynamic_xcframework_import(
    name = "GoogleUtilitiesXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["GoogleUtilities.xcframework/**"] ),
)


apple_dynamic_xcframework_import(
    name = "nanopbXCFramework",
    library_identifiers = {
        "ios_device": "ios-arm64",
        "ios_simulator": "ios-arm64_x86_64-simulator",
    },
    xcframework_imports = glob(["nanopb.xcframework/**"] ),
)

someone suggested on stackoverflow to patch it - but I'm new to bazel - and it is not straightforward.

BUILD


objc_library(
    name = "FBLPromises",
    module_name = "FBLPromises",
    enable_modules = True,
    srcs = glob([
        "Sources/*.m",
        "Sources/*.h",
    ]),
    hdrs = glob([
        "PublicHeaders/*.h",
    ]),
    includes = [
       "PublicHeaders", 
    ],
    sdk_frameworks = [
        "Foundation",
        "UIKit",
    ],
    visibility = [
        "//visibility:public",
    ],
)


//  FBLPromise+Extension.h
#if __has_include(<FBLPromises/FBLPromises.h>)
#import <FBLPromises/FBLPromises.h>
#else
#import "FBLPromises.h"
#endif
#import <Foundation/Foundation.h>

@interface FBLPromise (Extension)

@property(nonatomic, readonly) NSHTTPURLResponse *HTTPResponse;
@property(nonatomic, readonly) NSData *HTTPBody;

- (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(NSData *)body;

@end

//  FBLPromise+Extension.m
#import "FBLPromises.h"
#import <Foundation/Foundation.h>

@implementation FBLPromise (Extension)
+ (NSData *)HTTPBody {
    return nil;
}

- (NSData *)HTTPBody {
    return nil;
}

+ (void)setHTTPBody:(NSData *)data {
}

- (void)setHTTPBody:(NSData *)data {
}

+ (NSHTTPURLResponse *)HTTPResponse {
    return nil;
}

- (NSHTTPURLResponse *)HTTPResponse {
    return nil;
}

+ (void)setHTTPResponse:(NSHTTPURLResponse *)data {
}

- (void)setHTTPResponse:(NSHTTPURLResponse *)data {
}

+ (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(nullable NSData *)body {
    return nil;
}

- (instancetype)initWithResponse:(NSHTTPURLResponse *)response HTTPBody:(nullable NSData *)body {
    return nil;
}
@end

should this be necessary? does this method exist in this code? is it straightforward to spit out an xcframework for this project? I had a go with carthage and it was ok.