yoonjaepark / flutter_naver_login

A Flutter plugin for Naver Sign In.
BSD 2-Clause "Simplified" License
47 stars 70 forks source link

android package 설정 및 ios AppDelegate.swift 파일 crush #20

Closed nerdrun closed 4 years ago

nerdrun commented 4 years ago

먼저 멋진 플러그인 제작해주셔서 감사합니다.

두 가지 이슈 사항이 발생했는데

Android

네이버 어플리케이션 설정(안드로이드 패키지 명 등) 후에

AndroidManifest.xml

<meta-data
  android:name="com.naver.sdk.clientId"
  android:value="@string/client_id" />
<meta-data
  android:name="com.naver.sdk.clientSecret"
  android:value="@string/client_secret" />
<meta-data
  android:name="com.naver.sdk.clientName"
  android:value="@string/client_name" />

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="client_id">client id 입력</string>
    <string name="client_secret">client secret 입력</string>
    <string name="client_name">서비스 명 입력</string>
</resources>

설정을 완료 한 뒤에

NaverLoginResult res = await FlutterNaverLogin.logIn();

이슈발생

메소드 호출 시, 관리자 설정을 다시 해달라는 페이지가 웹뷰로 보입니다. 분명 안드로이드 패키지명은 동일하게 한 상태인데도 불구하고 이러한 에러가 지속됩니다.

iOS

pod install

(Development target 10이상만 허용되므로, 설정을 10으로 타겟설정했습니다.)

<key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>URLScheme명</string>
        </array>
      </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
      <array>
        <string>naversearchapp</string>
        <string>naversearchthirdlogin</string>
      </array>
      <key>kServiceAppUrlScheme</key>
      <string>URLScheme명</string>
      <key>kConsumerKey</key>
      <string>client id 입력</string>
      <key>kConsumerSecret</key>
      <string>client secret 입력</string>
      <key>kServiceAppName</key>
      <string>서비스명 입력</string>
        <!-- http allows configurations -->
      <key>NSAppTransportSecurity</key>
      <dict>
         <key>NSAllowsArbitraryLoads</key>
         <true/>
         <key>NSExceptionDomains</key>
         <dict>
           <key>naver.com</key>
           <dict>
             <key>NSExceptionAllowsInsecureHTTPLoads</key>
             <true/>
             <key>NSExceptionRequiresForwardSecrecy</key>
             <false/>
             <key>NSIncludesSubdomains</key>
             <true/>
           </dict>
           <key>naver.net</key>
           <dict>
             <key>NSExceptionAllowsInsecureHTTPLoads</key>
             <true/>
             <key>NSExceptionRequiresForwardSecrecy</key>
             <false/>
             <key>NSIncludesSubdomains</key>
             <true/>
           </dict>
         </dict>
      </dict
 override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
        return NaverThirdPartyLoginConnection.getSharedInstance().application(app, open: url, options: options)
    }

그리고 난 후

NaverLoginResult res = await FlutterNaverLogin.logIn();

이슈발생

/Users/nerdrun/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_naver_login-1.2.0/ios/Classes/FlutterNaverLoginPlugin.m:24:39: warning: assigning to 'id<NaverThirdPartyLoginConnectionDelegate>' from incompatible type 'FlutterNaverLoginPlugin *__strong'
        _thirdPartyLoginConn.delegate = self;
                                      ^ ~~~~
/Users/nerdrun/Documents/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_naver_login-1.2.0/ios/Classes/FlutterNaverLoginPlugin.m:86:87: warning: incompatible pointer to integer conversion sending 'void *' to parameter of type 'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions') [-Wint-conversion]
        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:nil error:&e];
                                                                                      ^~~
In module 'UIKit' imported from /Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Pods/Target Support Files/flutter_naver_login/flutter_naver_login-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Dispatch' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:20:
In module 'os_object' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/usr/include/dispatch/dispatch.h:59:
In module 'ObjectiveC' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/usr/include/os/object.h:102:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/usr/include/objc/objc.h:108:16: note: expanded from macro 'nil'
#   define nil __DARWIN_NULL
               ^~~~~~~~~~~~~
In module 'UIKit' imported from /Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Pods/Target Support Files/flutter_naver_login/flutter_naver_login-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
In module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:
In module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:16:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/usr/include/sys/_types.h:52:23: note: expanded from macro '__DARWIN_NULL'
#define __DARWIN_NULL ((void *)0)
                      ^~~~~~~~~~~
In module 'UIKit' imported from /Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Pods/Target Support Files/flutter_naver_login/flutter_naver_login-prefix.pch:2:
In module 'Foundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.6.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSJSONSerialization.h:59:80: note: passing argument to parameter 'opt' here
+ (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error;
                                                                               ^
2 warnings generated.
1 warning generated.
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:3: error: expected 'func' keyword in operator function declaration
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  ^
  func 
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:6: error: unnamed parameters must be written with the empty name '_'
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
     ^
     _: 
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:11: error: consecutive declarations on a line must be separated by ';'
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
          ^
          ;
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:11: error: expected declaration
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
          ^
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:5:13: note: in declaration of 'AppDelegate'
@objc class AppDelegate: FlutterAppDelegate {
            ^
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:6: error: use of undeclared type 'BOOL'; did you mean to use 'ObjCBool'?
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
     ^~~~
     ObjCBool
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:3: error: operator '-' declared in type 'AppDelegate' must be 'static'
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  ^
  static 
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:3: error: prefix unary operator missing 'prefix' modifier
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  ^
  prefix 
Swift.:1:17: note: prefix operator found here
prefix operator - : SignedNumeric
                ^
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:3: error: expected '{' in body of function declaration
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  ^
/Users/nerdrun/Documents/workspaces/gaekju/gaekju/ios/Runner/AppDelegate.swift:14:3: error: member operator '-' must have at least one argument of type 'AppDelegate'
  - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options {
  ^
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description

처럼 컴파일러가 AppDelegate.swift의 코드를 이해하지 못 하고 있습니다.

플러그인 제작자님의 Android, iOS의 플러그인 내부 코드를 살펴본 결과 크게 이상은 없어보였으나, 해당 이슈가 발생합니다.

지금까지 시도해본 상황

  1. 새로운 flutter 프로젝트를 만들어 테스트
  2. 새로운 네이버 어플리케이션을 만들어 테스트
  3. 네이버 api 콘솔에서 package 명 수정

어떠한 연유에서 발생되는 지 알 수 있을까요?

yoonjaepark commented 4 years ago

네이버 클라우드 쪽 설정이 잘못된거 같은데 확인 부탁드립니다 네이버 로그인 링크

nerdrun commented 4 years ago

@yoonjaepark 2가지의 이슈 모두 네이버 클라우드 쪽 설정에 문제라는 말씀이신가요?

yoonjaepark commented 4 years ago

@yoonjaepark 2가지의 이슈 모두 네이버 클라우드 쪽 설정에 문제라는 말씀이신가요?

@nerdrun 안드로이드는 클라우드 설정쪽 문제가 맞는거같은데 ios쪽은 저도 확실하게는 모르겠네요. 설정이 안잡혔으면 둘다 오류날꺼같기때문에 안드로이드쪽 오류 잡으시고 아이폰쪽 다시 확인해주시면 감사하겠습니다. 그래도 안되시면 새로운 flutter 프로젝트를 만들어 테스트해보신 깃 레파지토리 공유 가능하실까요?

nerdrun commented 4 years ago

@yoonjaepark 말씀하신 대로 안드로이드 경우, 클라우드 설정의 패키지 명 실수로 인한 게 맞습니다. app/build.gradle 가 아닌 AndroidManifest.xml 의 패키지명을 입력했었네요.

다만, iOS에서는 해당 문제가 지속적으로 발생합니다. naver_login_test 테스트 github 레파지토리 공유드립니다.

yoonjaepark commented 4 years ago

해당 코드 추가하시면 될꺼같습니다. 기본적으로 네이버 모듈이다 보니 네이버 공홈에서 문서를 읽어보시고 이슈에 대응하시면 좋을꺼같습니다. 크로스플랫폼이다보니 네이티브쪽 기본지식은 있어야 프로젝트 진행에 이슈가 없을꺼같습니다. 이슈 등록 감사합니다.

/// AppDelegate.swift
import NaverThirdPartyLogin // import 안되있음
// as-is
override func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
}
// to-be 스위프트 버전 변경되면서 수정된거같습니다.
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
}