質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Facebook

Facebookは、実名登録制のSNS(ソーシャル・ネットワーキング・サービス)です。開発者用のデベロッパーサイトが存在し、一般ユーザーによるFacebook向けアプリケーション開発が可能です。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

Q&A

解決済

1回答

518閲覧

Can't form Range with upperBound < lowerBoundエラー

退会済みユーザー

退会済みユーザー

総合スコア0

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Facebook

Facebookは、実名登録制のSNS(ソーシャル・ネットワーキング・サービス)です。開発者用のデベロッパーサイトが存在し、一般ユーザーによるFacebook向けアプリケーション開発が可能です。

Xcode

Xcodeはソフトウェア開発のための、Appleの統合開発環境です。Mac OSXに付随するかたちで配布されています。

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Google

Googleは、アメリカ合衆国に位置する、インターネット関連のサービスや製品を提供している企業です。検索エンジンからアプリケーションの提供まで、多岐にわたるサービスを提供しています。

1グッド

1クリップ

投稿2018/01/12 10:06

編集2018/01/13 12:49

Facebook認証でログイン後に、
別ストーリーボードのビューに遷移したいのですが、
FBログインしてから1秒後にクラッシュして、タイトルのThread 1: Fatal error: Can't form Range with upperBound < lowerBound
エラーが発生します。

この場合、下記↓の遷移メソッドは使用できないという事ですか?
let storyboard: UIStoryboard = UIStoryboard(name: "遷移先のSB名", bundle: nil)
let nextView = storyboard.instantiateInitialViewController()
self.present(nextView!, animated: true, completion: nil)

(AppDelegateです) import UIKit import Firebase import FirebaseAuth import GoogleSignIn import FBSDKCoreKit import RAMAnimatedTabBarController @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { FirebaseApp.configure() GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID GIDSignIn.sharedInstance().delegate = self FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) return true } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { if let err = error { print("Failed to log into Google: ", err) return } print("Successfully logged into Google", user) guard let idToken = user.authentication.idToken else { return } guard let accessToken = user.authentication.accessToken else { return } let credentials = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: accessToken) Auth.auth().signIn(with: credentials, completion: { (user, error) in if let err = error { print("Failed to create a Firebase User with Google account: ", err) return } guard let uid = user?.uid else { return } print("Successfully logged into Firebase with Google", uid) }) } func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { let handled = FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String!, annotation: options[UIApplicationOpenURLOptionsKey.annotation]) GIDSignIn.sharedInstance().handle(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String!, annotation: options[UIApplicationOpenURLOptionsKey.annotation]) return handled } func applicationWillResignActive(_ application: UIApplication) { } func applicationDidEnterBackground(_ application: UIApplication) { } func applicationWillEnterForeground(_ application: UIApplication) { } func applicationDidBecomeActive(_ application: UIApplication) { } func applicationWillTerminate(_ application: UIApplication) { } }
(MainViewControllerです。このビューでログインします) import UIKit import Firebase import FirebaseAuth import GoogleSignIn import FBSDKCoreKit import FBSDKLoginKit import RAMAnimatedTabBarController class MainViewController: UIViewController, FBSDKLoginButtonDelegate, GIDSignInUIDelegate { override func viewDidLoad() { super.viewDidLoad() GIDSignIn.sharedInstance().uiDelegate = self setupFacebookButtons() setupGoogleButtons() } fileprivate func setupGoogleButtons() { //add google sign in button let googleButton = GIDSignInButton() googleButton.frame = CGRect(x: 16, y: 116 + 66, width: view.frame.width - 32, height: 50) view.addSubview(googleButton) } fileprivate func setupFacebookButtons() { let loginButton = FBSDKLoginButton() view.addSubview(loginButton) //frame's are obselete, please use constraints instead because its 2016 after all loginButton.frame = CGRect(x: 16, y: 50, width: view.frame.width - 32, height: 50) loginButton.delegate = self } func loginButtonDidLogOut(_ loginButton: FBSDKLoginButton!) { print("Did log out of facebook") } //Gogleログイン func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) { // ... if error != nil { // ... return } guard let authentication = user.authentication else { return } let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken, accessToken: authentication.accessToken) // ... Auth.auth().signIn(with: credential) { (user, error) in if error != nil { // ... return } let storyboard: UIStoryboard = UIStoryboard(name: "RAMAnimatedTabBar", bundle: nil) let nextView = storyboard.instantiateInitialViewController() self.present(nextView!, animated: true, completion: nil) } } //FBログイン func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) { if error != nil { print(error) return } let accessToken = FBSDKAccessToken.current() guard let accessTokenString = accessToken?.tokenString else { return } let credentials = FacebookAuthProvider.credential(withAccessToken: accessTokenString) Auth.auth().signIn(with: credentials) { (user, error) in if error != nil { // ... return } let storyboard: UIStoryboard = UIStoryboard(name: "RAMAnimatedTabBar", bundle: nil) let nextView = storyboard.instantiateInitialViewController() self.present(nextView!, animated: true, completion: nil) // User is signed in // ... } } //各サインアップ画面へ @IBAction func toSignUpVC(_ sender: Any) { let storyboard: UIStoryboard = UIStoryboard(name: "SignUpView", bundle: nil) let nextView = storyboard.instantiateInitialViewController() present(nextView!, animated: true, completion: nil) } /* StoryboadでMailSignUpToFirstViewを引くため(戻るため)に必要 ボタン 戻る際の処理が特に必要ないのでメソッドは空です*/ @IBAction func BackStartView(segue: UIStoryboardSegue) { } }
egg_plant👍を押しています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

エラー文にも書いてある通りRangeの扱いが間違っているのではないでしょうか。
過去の質問にも fatal error: Can't form Range with end < startの解消法 のような、今回のエラー内容と近いものがありました。

提示されたソースコードにRangeを使用しているところは見受けられませんがSwift 3のRange徹底解説などを参考にRangeの扱いを見直してみてはいかがでしょうか。

投稿2018/01/13 17:02

nakasho_dev

総合スコア2655

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/01/14 03:45

nakasho_dev様 私自身まだ知識が足りないので、まずおすすめ頂いた上記のサイトを参考に勉強します。 ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問