FlagPhoneNumber: Flags don't appear

Describe the bug The flags don’t appear. Also I tried changing the Bundle path, but it always return self.flag = UIImage(named: "unknown", in: Bundle.FlagIcons, compatibleWith: nil)

To Reproduce Steps to reproduce the behavior:

  1. Load the VC whose has the txf
  2. Run the app

Expected behavior Appear the flag in the scrolldown

Screenshots The flags don’t appear. simulator screen shot - iphone xs - 2019-02-21 at 16 10 27

Smartphone (please complete the following information): iPhone X, iPhone 5s

FlagPhoneNumber (please complete the following information):

  • Version from brunch: 4.2
  • Version from brunch: Master

Additional context I tried all the steps of the other related issues: #15 and #57.

Thank you so much in advance!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Very weird issue 😕 Some people have it and I don’t know how to fix it because I can’t reproduce it. Could you share me your project and I will investigate on it ?

I’ve exactly the same issue, we I run the project on Xcode, the flag appear, but when I upload the app on testFlight, the flag doesn’t appear anymore

Copying FlagKit.xcassets to the app itself and adding this line to the AppDelegate didFinishLaunchingWithOptions fixed it for me Bundle.FlagIcons = Bundle(for: type(of: self))

It’s the same, sometimes the flags appear, others do not 😦

I fixed it by replacing flag assets by get country flag from system with country code

func getFlag(country:String) -> String { 
        let base : UInt32 = 127397
        var s = ""
        for v in country.unicodeScalars {
            s.unicodeScalars.append(UnicodeScalar(base + v.value)!)
        }
        return String(s)
    }

and the flag now is from type String so I changed the UIImageView to be UILabel and bind .text property to the new flag string. you can check the changes in this fork https://github.com/AhmedMohamedAllam/FlagPhoneNumber

@dbeleza and everyone else. What worked for me is :

  1. Copying all the images in FlagKit.xcassets in my projects Assets and deleting all 1x and 3x files of all Flags. Just keep 2x Files.

  2. Changing the line 14 - 18 in FPNCountry.swift from

if let flag = UIImage(named: code, in: Bundle.FlagIcons, compatibleWith: nil) {
	self.flag = flag
} else {
	self.flag = UIImage(named: "unknown", in: Bundle.FlagIcons, compatibleWith: nil)
}

to

if let flag = UIImage(named: code) {
	self.flag = flag
} else {
	self.flag = UIImage(named: "unknown")
}

A workaround is like @Kriptite said:

Copying FlagKit.xcassets to the app itself and adding this line to the AppDelegate didFinishLaunchingWithOptions fixed it for me Bundle.FlagIcons = Bundle(for: type(of: self))

Hi @grifas! Sorry for the delay! I have finally created a repo and it works with the version 0.7.2 but without success in older versions.

Thank you so much for the support!

Of course! Allow me a few days to create a basic project to integrate it and share it with you. Thank you very much for the quick response.