Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPM integration #86

Open
victormihaita opened this issue Jan 13, 2021 · 11 comments
Open

SPM integration #86

victormihaita opened this issue Jan 13, 2021 · 11 comments

Comments

@victormihaita
Copy link

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

@diegoserranoa
Copy link
Contributor

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
Copy link
Contributor

mcmurrym commented Feb 2, 2021

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

@cassianodialpad
Copy link

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

@diegoserranoa Any updates on this issue?

@jaerod95
Copy link

jaerod95 commented Mar 27, 2021

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
Copy link

@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
Copy link

Stil fails on version 0.20.0

@kaydenthomson
Copy link

Still failing in version 0.21 with this error:
Wootric

@andresfilia
Copy link

The same issue here :/

@DanFechtman
Copy link

Same issue here as well

@reshadf
Copy link

reshadf commented Feb 2, 2022

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

@KoCMoHaBTa
Copy link

@diegoserranoa, please review #96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants