darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

FacebookAuth.swift:138:46: error: value of type 'AccessToken' has no member 'permissions' #97

Closed hw20101101 closed 3 years ago

hw20101101 commented 3 years ago

Describe the bug Error when running the project:FacebookAuth.swift:138:46: error: value of type 'AccessToken' has no member 'permissions'

Thank you

Environment Add your flutter doctor -v

[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale zh-Hans-CN)
    • Flutter version 1.22.6 at /Users/ios/Documents/8_multi_platform/flutter
    • Framework revision 9b2d32b605 (4 months ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/ios/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/ios/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (1 available)            
    • iPhone 8 (mobile) • D0DDCF47-211C-485E-B393-71D792DA4BF2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

Add your pubspec.yaml

name: aa_example 
description: Demonstrates how to use the thrio plugin.
version: 0.5.0  
publish_to: "none"

environment:
  sdk: ">=2.6.0 <3.0.0"

dependencies:  
  flutter:
    sdk: flutter
 flutter_facebook_auth: ^2.0.2+1

dev_dependencies:  
  flutter_test:
    sdk: flutter
  pedantic: ^1.8.0

Add your Info.plist Add your AndroidManifest.xml Add your /app/res/values/strings.xml

To Reproduce Please add your code to reproduce the issue

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots or videos to help explain your problem.

Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    2 warnings generated.
    1 warning generated.
    /Users/ios/.pub-cache/hosted/pub.flutter-io.cn/flutter_facebook_auth-2.0.2+1/ios/Classes/FacebookAuth.swift:138:46: error: value of type 'AccessToken' has no member 'permissions'
                "grantedPermissions":accessToken.permissions.map {item in item.name},
                                     ~~~~~~~~~~~ ^~~~~~~~~~~
    /Users/ios/.pub-cache/hosted/pub.flutter-io.cn/flutter_facebook_auth-2.0.2+1/ios/Classes/FacebookAuth.swift:139:47: error: value of type 'AccessToken' has no member 'declinedPermissions'
                "declinedPermissions":accessToken.declinedPermissions.map {item in item.name},
                                      ~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
darwin-morocho commented 3 years ago

Describe the bug Error when running the project:FacebookAuth.swift:138:46: error: value of type 'AccessToken' has no member 'permissions'

Thank you

Environment Add your flutter doctor -v

[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale zh-Hans-CN)
    • Flutter version 1.22.6 at /Users/houwei_ios/Documents/8_multi_platform/flutter
    • Framework revision 9b2d32b605 (4 months ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/houwei_ios/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/houwei_ios/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 12.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[!] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.56.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (1 available)            
    • iPhone 8 (mobile) • D0DDCF47-211C-485E-B393-71D792DA4BF2 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-4 (simulator)

Add your pubspec.yaml

name: aa_example 
description: Demonstrates how to use the thrio plugin.
version: 0.5.0  
publish_to: "none"

environment:
  sdk: ">=2.6.0 <3.0.0"

dependencies:  
  flutter:
    sdk: flutter
 flutter_facebook_auth: ^2.0.2+1

dev_dependencies:  
  flutter_test:
    sdk: flutter
  pedantic: ^1.8.0

Add your Info.plist Add your AndroidManifest.xml Add your /app/res/values/strings.xml

To Reproduce Please add your code to reproduce the issue

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots or videos to help explain your problem.

Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **
Xcode's output:
↳
    2 warnings generated.
    1 warning generated.
    /Users/houwei_ios/.pub-cache/hosted/pub.flutter-io.cn/flutter_facebook_auth-2.0.2+1/ios/Classes/FacebookAuth.swift:138:46: error: value of type 'AccessToken' has no member 'permissions'
                "grantedPermissions":accessToken.permissions.map {item in item.name},
                                     ~~~~~~~~~~~ ^~~~~~~~~~~
    /Users/houwei_ios/.pub-cache/hosted/pub.flutter-io.cn/flutter_facebook_auth-2.0.2+1/ios/Classes/FacebookAuth.swift:139:47: error: value of type 'AccessToken' has no member 'declinedPermissions'
                "declinedPermissions":accessToken.declinedPermissions.map {item in item.name},
                                      ~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description

Hi @hw20101101 , the problem is because your project uses objective-c as a default language and this plugin works with swift. You can change the default language to swift deleting the ios folder and create it again https://github.com/darwin-morocho/flutter-facebook-auth/issues/69#issuecomment-803476340

hw20101101 commented 3 years ago

Thank you, but how should I change the default language to swift?

darwin-morocho commented 3 years ago

Thank you, but how should I change the default language to swift?

https://github.com/darwin-morocho/flutter-facebook-auth/issues/41#issuecomment-761702248

hw20101101 commented 3 years ago

@darwin-morocho This is my project structure

31620870200_ pic_hd2

darwin-morocho commented 3 years ago

@darwin-morocho This is my project structure

31620870200_ pic_hd2

please follow the link above to see how to change your default language on ios

hw20101101 commented 3 years ago

@darwin-morocho thank you

I saw this: running the command flutter create -i swift

Do you have to execute this command? Is there any other way?

darwin-morocho commented 3 years ago

@darwin-morocho thank you

I saw this: running the command flutter create -i swift

Do you have to execute this command? Is there any other way?

Go to your root project folder and delete the ios folder now open a terminal in your root project folder ande run the command

flutter create -i swift .

Dont forget to add . at the end

hw20101101 commented 3 years ago

thank you,But I run the command and report an error:

WX20210513-100810@2x

This is my project directory:

WX20210513-100653@2x
darwin-morocho commented 3 years ago

thank you,But I run the command and report an error:

WX20210513-100810@2x

This is my project directory:

WX20210513-100653@2x

don't forget to add . at the end of the command

hw20101101 commented 3 years ago

Oh my goodness, thank you so much. But my project needs to execute commands in the example directory instead of the root directory.