-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Swift Package Manager #248
Comments
My own experience is that it cannot. There is a package.swift file in the project, and I added this package to my own project. However when I ran the app, I got a crash on line 94 of FontAwesome.swift - return UIFont(name: style.fontName(), size: fontSize)! I assume that the font otf files themselves are not being loaded through the package manager. I have switched back to using Carthage for this dependency in my project and now I do get the fonts I was expecting |
Further to my reply, I have now figured out how to get FontAwesome working. Include the package as you would any other, but manually copy the 3 otf font files into your project - I copied them to the same folder as my storyboard and other assets |
I didn't manage to make it work using SPM |
Did you follow my instructions. Just add as you would any other SPM package. However you must manually copy the 3 font files into your project - I put them in my Resources folder. The files are named Font Awesome 5 Free-Regular-400.otf, and another two with similar names. Also make sure to set the Target Membership flag for your target. That's all I did and I have FontAwesome fonts in my app. Apparently there will be a fix for SPM in Swift 5.3 later this year; this should allow the fonts to be included in the package There is one issue however when you're running a Mac-Catalyst app. It occurs if you use more than 1 FontAwesome font in your app. I have raised an issue for this |
Hey Matt! This will be addressed in the next major version. I'm adding this to our project board now |
@DerekK19 Thanks for your input. FontAwesome Swift library surprisingly still has this issue.. Importing the 3 otf font files resolved the issue for me as well. |
@AkashlalBol there's some difficulty with resources in SPM SPM only recently added the ability to include resources with a package, and loading from those needs to be handled separately from CP and normally loaded bundles. All of this is being re-written |
Okay @MatrixSenpai, makes sense :) |
@AkashlalBol if you load the fonts yourself, there is no incompatibility. If there is, please post an error log. However, this code is responsible for pre-checking if the font has already been loaded by the system. To assist with this, I recommend using FontBlaster, which I use for more than just FontAwesome. |
SPM was updated last year to support Resources in swift 5.3, Xcode 12. This page https://developer.apple.com/documentation/swift_packages/bundling_resources_with_a_swift_package says that setting the swift tools version to 5.3 should make resources "just work." Any progress on this? |
I've made a PR with updated SPM support that includes copying the font files into your project. #272 I invite anyone that wants to use SPM to try the PR and then review it. You should remove the font files from your project if you do test it to make sure they're being copied by SPM. |
You can use our fork for the SPM crash fix -- https://github.com/BankofLoyal/FontAwesome.swift CC: @AkashlalBol |
I can confirm SPM works using @sandeepbol fork. Great job. Thanks! |
@MatrixSenpai Please close after creating the tag. |
Is there an issue w/ loading fonts when the package is installed via SPM for version |
Can this be used in Xcode as a Swift Package dependancy?
If so, Is this better than using CocoaPods?
If so, any other files needed?
The text was updated successfully, but these errors were encountered: