Comments (16)
Are you sure you're not using any Beta software? Xcode and iOS?
from phonenumberkit.
Yep. Xcode 15 release version and iOS 17 and 16 simulators that it downloaded from scratch.
from phonenumberkit.
Again, this happens only on iOS 17 simulator. iOS 16 simulator or iOS 17 on device works correctly.
from phonenumberkit.
Command line tools set on Xcode to 15 release?
Asking that because I am not able to reproduce this issue.
from phonenumberkit.
Correct. I am testing it with the following simple code.
let phoneNumberKit = PhoneNumberKit()
let phoneNumber = try? phoneNumberKit.parse("+908504801234")
if phoneNumber != nil {
let internationalNumber = phoneNumberKit.format(phoneNumber!, toType: .international)
print(internationalNumber)
}
else {
print("Phone number nil")
}
The number is valid. I tried it in 3 different projects to see if it has something to do with the project settings. All fail on iOS 17 simulator and work correctly on 16 simulator and 17 device.
from phonenumberkit.
Can you check the build number of your iOS 17 simulator?
from phonenumberkit.
It is exactly the same with yours. Do you use an Apple silicon or Intel Mac? Perhaps the problem comes from the architecture of the Mac. I am on a MacBook Pro with an M2 Max.
from phonenumberkit.
M1 Pro here.
Well, I don't really know how to proceed. Maybe add a check for the simulator, since there is not way to simulate a SIM card on it anyway.
from phonenumberkit.
Can you check if it works for you?
from phonenumberkit.
No, does not work. because somehow
let currentLocale = Locale.current
if let countryCode = (currentLocale as NSLocale).object(forKey: .countryCode) as? String {
return countryCode.uppercased()
}
Still returns "001". But if I override that with "US" for example and return that, it works correctly. So, the following works:
#if !targetEnvironment(simulator)
#if canImport(Contacts)
if #available(iOS 12.0, macOS 10.13, macCatalyst 13.1, watchOS 4.0, *) {
// macCatalyst OS bug if language is set to Korean
// CNContactsUserDefaults.shared().countryCode will return ko instead of kr
// Failed parsing any phone number.
let countryCode = CNContactsUserDefaults.shared().countryCode.uppercased()
#if targetEnvironment(macCatalyst)
if "ko".caseInsensitiveCompare(countryCode) == .orderedSame {
return "KR"
}
#endif
return countryCode
}
#endif
let currentLocale = Locale.current
if let countryCode = (currentLocale as NSLocale).object(forKey: .countryCode) as? String {
return countryCode.uppercased()
}
#endif
from phonenumberkit.
I believe it would make much more sense to check using regex, if the country code is a two letter string instead of this hack though. If it is not a 2 letter code, returning default would be the best course of action.
from phonenumberkit.
countryCode
is deprecated: https://developer.apple.com/documentation/foundation/nslocale/1643060-countrycode
Using regionCode
now: https://developer.apple.com/documentation/foundation/nslocale/4172868-regioncode
Since the code was using object(forKey:)
, there was no deprecation warning.
from phonenumberkit.
Well, I only suggested what I got in the first pull request. :)
By the way, I looked at the latest pull request and believe that if somehow the region code returns "01" instead of "001" (could happen in a future simulator), we could encounter the same bug. Checking if its length is 2 characters would not be enough in my opinion, also making sure it is letters only would make it better future-proof.
from phonenumberkit.
By the way, I believe this is indeed some bug within my Xcode installation now. I am unable to launch "Settings" app on iOS 17 simulator. I'll try to reinstall it.
from phonenumberkit.
After reinstalling the simulator, the problem disappeared. I still cannot launch "Settings" app on iPhone 15 Pro/Pro Max though, so the simulator definitely has some bugs that need to be fixed by Apple (iPhone 15 and 15 Plus does not have that problem). In any case, your latest pull request that includes regex checks will eliminate any problems about this issue.
from phonenumberkit.
After trying fastlane snapshot for screenshots, the issue appeared again. Looks like fastlane is partially responsible for this bug.
from phonenumberkit.
Related Issues (20)
- Invalid phoneNumber if no prefix (+, 00) HOT 2
- Build fails with default target library linking configuration HOT 2
- How to use in objective - c? HOT 1
- How can i make static mask to one country code? HOT 1
- Invalid Number is getting parsed: +5763252999 HOT 8
- V3.7.6 Compilation error : value of optional type 'NSRegularExpression?' must be unwrapped to refer to member 'firstMatch' of wrapped base type 'NSRegularExpression' HOT 1
- Bug Value of optional type 'NSRegularExpression?' must be unwrapped HOT 2
- How can I detect a change in the selected country code using PhoneNumberKit in Swift? HOT 1
- Some French numbers 0694* (French Guiana) are not considered as Valid HOT 3
- Default region code is incorrect on real devices HOT 2
- How can I parse a number from a region different than the device? HOT 1
- visionOS Support HOT 1
- PhoneNumberKit is not recognised phone number until it is completed HOT 1
- Clear button not working. HOT 1
- `No such file or directory: '~/DerivedData` HOT 9
- Add privacy manifest HOT 2
- Does not validate 983 area code numbers properly. HOT 2
- Patch for Kazakhstan phone numbers breaks region resolution in PartialFormatter HOT 4
- Swift emits an invalid module interface when a public type has the same name as a module HOT 2
- Formatter.swift adding an extra 0 for Bangladesh numbers HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phonenumberkit.