Wootric / WootricSDK-iOS

Wootric iOS SDK to show NPS, CSAT and CES surveys
MIT License
13 stars 24 forks source link

SPM integration #86

Open victormihaita opened 3 years ago

victormihaita commented 3 years ago

When you think we can have the SPM integration in the project?

diegoserranoa commented 3 years ago

Hi @victormihaita, we don't have an estimated time for when we'll support this. We will try to work on this as soon as we can but I don't have that information right now.

mcmurrym commented 3 years ago

There is already a Package.swift file. doesn't that mean it is supported in SPM?

cassianodialpad commented 3 years ago

@mcmurrym I've tried it out, it's not working properly.

@diegoserranoa Any updates on this issue?

jaerod95 commented 3 years ago

I've got a SPM fork building, but I'm having issues getting the survey to actually show. The delegate method willPresentSurvey is getting called but the survey never appears. Still trying to figure out why...

jaerod95 commented 3 years ago

@victormihaita I was able to get an updated Package.swift working for version 0.17.0 but for some reason it doesn't work on version 0.19.1. The big issues with 0.17.0 was the fact that the font wasn't being found since we were looking in the wrong bundle. Checking the auto generated SPM bundle, it was presenting the survey fine. I'm guessing somethings changed between version 0.17.0 and version 0.19.1 that's causing it to not work. Here's the Package.swift for those who'd like to continue tweaking with it. I'd create a MR, but since it doesn't work with the most current master I'd rather just post it here:

// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "WootricSDK",
    products: [
        .library(name: "WootricSDK", targets: ["WootricSDK"])
    ],
    targets: [
        .target(
            name: "WootricSDK",
            path: "WootricSDK/WootricSDK",
            exclude: ["Info.plist"],
            resources: [.process("fontawesome-webfont.ttf")],
            publicHeadersPath: "."
        )
    ]
)

Here's the other snippet for the changes needed in UIItems.m. I needed make a change in the dynamicallyAddFont method to look for thee SPM bundle::

+ (void)dynamicallyAddFont {
  NSString *fontPath = [[NSBundle bundleForClass:[UIItems class]] pathForResource:@"fontawesome-webfont" ofType:@"ttf"];

    if ([fontPath length] == 0) {
    // Try to find the font in the SPM bundle
    fontPath = [SWIFTPM_MODULE_BUNDLE pathForResource:@"fontawesome-webfont" ofType:@"ttf"];
  }

  CFErrorRef error;
  NSURL *url = [NSURL fileURLWithPath:fontPath isDirectory:NO];
  if (!CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeNone, &error)) {
    if (CFErrorGetCode(error) == kCTFontManagerErrorAlreadyRegistered) {
      CFRelease(error);
      return;
    }
    CFStringRef errorDescription = CFErrorCopyDescription(error);
    NSLog(@"WootricSDK: Failed to load font: %@", errorDescription);
    CFRelease(errorDescription);
    CFRelease(error);
  }
}
cassianodialpad commented 3 years ago

Stil fails on version 0.20.0

kaydenthomson commented 3 years ago

Still failing in version 0.21 with this error:

Wootric
andresfilia commented 2 years ago

The same issue here :/

DanFechtman commented 2 years ago

Same issue here as well

reshadf commented 2 years ago

there is a PR to fix it if someone can have a look at it 👁️

KoCMoHaBTa commented 2 years ago

@diegoserranoa, please review https://github.com/Wootric/WootricSDK-iOS/pull/96