intl_phone_number_input icon indicating copy to clipboard operation
intl_phone_number_input copied to clipboard

Swift Compiler Error (Xcode): Cannot find type 'PhoneNumberKit' in scope

Open mashegoindustries opened this issue 1 year ago • 20 comments

Cannot compile

Swift Compiler Error (Xcode): Cannot find type 'PhoneNumberKit' in scope /Users/xxxxx/.pub-cache/hosted/pub.dev/libphonenumber_plugin-0.3.3/ios/Classes/SwiftLibphonenumberPlugin.swift:6:24

Swift Compiler Error (Xcode): Extra argument 'phoneNumberKit' in call /Users/xxxxx/.pub-cache/hosted/pub.dev/libphonenumber_plugin-0.3.3/ios/Classes/SwiftLibphonenumberPlugin.swift:127:82

Uncategorized (Xcode): Command SwiftCompile failed with a nonzero exit code

Encountered error while building for device.

mashegoindustries avatar Aug 20 '24 19:08 mashegoindustries

Same here, any updates?

emanuel-braz avatar Aug 20 '24 21:08 emanuel-braz

You can lock the PhoneNumberKit version to 3.8.0 in your Podfile because the PhoneNumberKit package just released new version 4.0. It has a breaking change by renaming PhoneNumberKit to PhoneNumberUtility https://github.com/marmelroy/PhoneNumberKit/pull/798

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # This is just a temporary solution to fix the iOS build issue. We need to remove this line after the author fixes this [issue](https://github.com/natintosh/plugin_libphonenumber/issues/35)
  pod 'PhoneNumberKit', '3.8.0'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

chungxon avatar Aug 21 '24 02:08 chungxon

Same issue here. I'm using flutterflow to develop my app. I cant fix the issue locally and deploy from an specific branch but this must be resolved else I should consider using another lib.

How can we help?

juandps avatar Aug 23 '24 03:08 juandps

@natintosh Can you update PhoneNumberKit version please?

juandps avatar Aug 26 '24 17:08 juandps

Same issue here, Cannot find type 'PhoneNumberKit' in scope @natintosh I would really appreciate it if you could fix and update the package.

ravid007 avatar Sep 02 '24 07:09 ravid007

i am applying fix and will create Pull request

Shahidbangash avatar Sep 02 '24 14:09 Shahidbangash

Following...

zivrozz avatar Sep 02 '24 15:09 zivrozz

Hey , After debugging Package , i realised this error is coming from Another package plugin_libphonenumber and this package then uses another package called PhoneNumberKit.

During debugging of plugin_libphonenumber , i found that version 3.8.0 and 4.0.0 is causing this Cannot find type 'PhoneNumberKit' in scope. Although i could not find the exact reason of this but i was able to make a build on version 3.7.8

This was the context and i hope this will be helpful for author or people working on this plugin .

--- Now to solve this problem for your flutter app replace code in pubspec.yaml to this Replace this

intl_phone_number_input: your pub version of package

with

  intl_phone_number_input:
    git:
      url: https://github.com/Shahidbangash/intl_phone_number_input.git
      ref: develop 
then you need to do flutter clean
also delete pubspec.lock file and pod.lock to get rid of old version.

do flutter pub get 
and then cd ios 
pod install 

Now this should work
 
 
 

Shahidbangash avatar Sep 03 '24 00:09 Shahidbangash

@natintosh Could you please help? I can buy you a coffee :)

juandps avatar Sep 04 '24 15:09 juandps

Subscribing to this thread as we are also experiencing the exact same issue.

simply-alliv avatar Sep 05 '24 08:09 simply-alliv

You can lock the PhoneNumberKit version to 3.8.0 in your Podfile because the PhoneNumberKit package just released new version 4.0. It has a breaking change by renaming PhoneNumberKit to PhoneNumberUtility marmelroy/PhoneNumberKit#798

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  # This is just a temporary solution to fix the iOS build issue. We need to remove this line after the author fixes this [issue](https://github.com/natintosh/plugin_libphonenumber/issues/35)
  pod 'PhoneNumberKit', '3.8.0'

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Perfect solutions. It worked for me. If anyone needs help you can mail me I will fix the issue for you. Thank you [email protected]

arsarsars1 avatar Sep 05 '24 11:09 arsarsars1

The tactical solution is fine but we might need a permanent solution, I am not familiar with the lib whatsoever else I would do it myself.

juandps avatar Sep 05 '24 13:09 juandps

But if someone can guide me on how to do it I will do it

juandps avatar Sep 05 '24 13:09 juandps

I hadn't seen this issue, so the solution I used to get round this error was to add the package flutter_libphonenumber. It works, but it's not a clean, definitive solution

Gurvan2 avatar Sep 23 '24 13:09 Gurvan2

Hi, The issue is actually fixed at the current develop branch targeting v0.7.5 but it is not yet deployed.

At Perci Health we simply forked the repo and published to intl_phone_number_input_perci under the MIT license.

It is possible to use as a temporary workaround.

  1. Install intl_phone_number_input_perci: ^0.7.5.
  2. Import packages
    import 'package:flutter/material.dart';
    import 'package:intl_phone_number_input_perci/intl_phone_number_input_perci.dart';
    

The rest of the code should be compatible with intl_phone_number_input.

In Flutterflow add intl_phone_number_input_perci: ^0.7.5 to the pubspec dependancies in any custom function.

paddyrehill avatar Oct 01 '24 19:10 paddyrehill

Hi, The issue is actually fixed at the current develop branch targeting v0.7.5 but it is not yet deployed.

At Perci Health we simply forked the repo and published to intl_phone_number_input_perci under the MIT license.

It is possible to use as a temporary workaround.

  1. Install intl_phone_number_input_perci: ^0.7.5.
  2. Import packages
    import 'package:flutter/material.dart';
    import 'package:intl_phone_number_input_perci/intl_phone_number_input_perci.dart';
    

The rest of the code should be compatible with intl_phone_number_input.

In Flutterflow add intl_phone_number_input_perci: ^0.7.5 to the pubspec dependancies in any custom function.

worked for me, thanks a lot.

gorkemhacioglu avatar Oct 01 '24 20:10 gorkemhacioglu

@natintosh Waiting for your updates.

naderhezzy avatar Oct 07 '24 15:10 naderhezzy

@natintosh Please provide contributor access for the pub lib and I will deploy the changes myself. Thank youuuu

juandps avatar Oct 22 '24 13:10 juandps

To fix this issue, follow these steps to integrate the updated SwiftLibphonenumberPlugin.swift and automate the process using intl_phone_number_input.sh: Files.zip

  1. Update SwiftLibphonenumberPlugin.swift
  • Replace the existing SwiftLibphonenumberPlugin.swift with the updated file.
  • Place the updated SwiftLibphonenumberPlugin.swift in your project root directory.
  1. Add intl_phone_number_input.sh
  • Create a script file named intl_phone_number_input.sh (or use the one provided).
  • Place intl_phone_number_input.sh in your project root directory.
  1. Modify Your Podfile
  • Open your Podfile.
  • Locate the post_install section.
  • Add the following line to execute the script during the post-installation phase: post_install do |installer| // Your existing post_install configurations // Execute the intl_phone_number_input.sh script system('bash ../intl_phone_number_input.sh') if File.exist?('../intl_phone_number_input.sh') end

The script ensures any necessary updates or configurations are applied automatically during pod install.

imuhammadnadeem avatar Jan 01 '25 13:01 imuhammadnadeem

Following!

abhirakshit avatar Jul 09 '25 04:07 abhirakshit