2016-07-08 9 views
2

AppleのWWDCビデオのチュートリアルを使用してiMessage拡張機能を開発していて、奇妙なエラーが発生しました。私は空のプロジェクトから始めました。しかし、私はMSStickerBrowserViewControllerのファイルを追加しました。コードは構築されましたが、シミュレータの拡張機能を開くとクラッシュしました。奇妙なことは、私は決してブラウザのインス​​タンスを作ったです。実行されていないコードがクラッシュするのはなぜですか?Swift 3のコードが実行時にエラーを起こしたことがないのはなぜですか?

はここでエラーです:dyldの:ライブラリがロードされていません:/ユーザ/ alextyshka /ライブラリ/開発/ CoreSimulator /デバイス/ BF34F16D-3CEF-4C7D-8D9A-D3D4B463F293 /データ/コンテナ:RPATH/libswiftSwiftOnoneSupport.dylib @から参照さ/Bundle/Application/75E2E14B-E76B-4EC7-9528-7CE38864B55D/BlankMessages.app/PlugIns/MessagesExtension.appex/MessagesExtension 理由:私は気づいた場合

import UIKit 
import Messages 

class MyStickerBrowserViewController: MSStickerBrowserViewController { 
    var stickers = [MSSticker]() 
    func changeBrowserViewBackgroundColor(color: UIColor) { 
     stickerBrowserView.backgroundColor = color 
    } 
    func loadStickers() { 
     createSticker(asset: "forest", localizedDescription: "forest sticker") 
    } 
    func createSticker(asset: String, localizedDescription: String) { 
     guard let stickerPath = Bundle.main().pathForResource(asset, ofType: "png") else { 
      print("couldn't create the sticker path for", asset) 
      return 
     } 
     let stickerURL = URL(fileURLWithPath: stickerPath) //This is the line that seems to be causing the error. 
     let sticker: MSSticker 
     do { 
      try sticker = MSSticker(contentsOfFileURL: stickerURL, localizedDescription: localizedDescription) 
      stickers.append(sticker) 
      } catch { 
       print(error) 
      return 
     } 
    } 
    /* 
    override func numberOfStickers(in stickerBrowserView: MSStickerBrowserView) -> Int { 

    } 

    override func stickerBrowserView(_ stickerBrowserView: MSStickerBrowserView, stickerAt index: Int) -> MSSticker { 

    }*/ 
} 

:ここ を発見していない画像はエラーをトリガするコードです私はURLを作る行16を取り出し、エラーはスローされません。

Hereは、私が従ったWWDCビデオへのリンクです。私は二重チェックをしてビデオを正確に辿っていることを確認しました

+0

例外ブレークポイントを追加して、問題の正確な箇所を確認して、エラーの内容を把握してください。 – vigneshv

+0

ブレークポイントを使用しました。エラーは 'willBecomeActive'または' viewDidLoad'の前に早くスローされています –

+0

[this](http://stackoverflow.com/questions/37820755/running-spritekit-game-in-watchos-on-apple-watch)のユーザー-simulator-xcode-8-swift-3-io)質問はApple Watchアプリケーションで同じエラーが発生しましたが、その解決策は私のためには機能しませんでした。 –

答えて

0

Xcodeを再インストールしても機能しました。奇妙な。誰もが助言してくれてありがとう!

関連する問題