2016-05-22 9 views
0

私のアプリにロードする必要があるプラグインバンドルがあります。 私はiOSのシミュレータでアプリを実行すると、バンドルが正しくセットされているが、私は私の本当のデバイス上でアプリケーションを実行するために、プロジェクトを再コンパイルするとき、私は次のエラーを取得する:実際のデバイスにiOSバンドルをロードしています

Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter): no suitable image found. Did find: 
/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter: mmap() error 1 at address=0x022CF000, size=0x00008000 segment=__TEXT in Segment::map() mapping /var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter" UserInfo={NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter, NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedDescription=The bundle “grandmaAdapter” couldn’t be loaded because it is damaged or missing necessary resources., NSDebugDescription=dlopen_preflight(/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter): no suitable image found. Did find: 
/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter: mmap() error 1 at address=0x022CF000, size=0x00008000 segment=__TEXT in Segment::map() mapping /var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle/grandmaAdapter, NSBundlePath=/var/mobile/Containers/Data/Application/35F71C99-1072-4772-8BFB-3CB8C034A935/Documents/grandmaAdapter.bundle} 

基本的に私は何をすべきか次のとおりです。その後、ドキュメントディレクトリ内のファイルパスを-Defining

NSString *bundleName = [NSString stringWithFormat:@"%@.bundle", bundle]; 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [paths objectAtIndex:0]; 
filePath = [documentsDirectory stringByAppendingPathComponent:bundleName]; 

- およびバンドルに

NSBundle *plugin = [[NSBundle alloc] initWithPath:filePath]; 

NSError *err; 
if(![plugin loadAndReturnError:&err]) { 
    // err contains error info 
} else { 
    // bundle loaded properly 

} 
をロードします

ここに私は上記のエラーがあります

誰かが私を助けることができますか?おかげ

はエラーがコード署名の欠如に関連していた

を解決しました。この記事で報告されているように :http://ddeville.me/2014/04/dynamic-linking/ プラグインは、次のコマンドを使用して、実際のデバイスにロードするために署名する必要があります

codesign --sign "iPhone Developer" --force --verbose=4 myPluginName.plugin 
+2

バンドルをSimulatorにどのようにロードしましたか?プログラム的には、コードを表示してください。 – Sheamus

+0

自分のコードを編集しました – davideb

+0

問題はディレクトリアクセス権の問題に関連する可能性がありますか(実際のデバイス上)。メッセージには破損したデータや不足しているデータが含まれているとレポートされていますが、 – davideb

答えて

0

あなたのバンドルローディングコードはloadAndReturnError:まで、よさそうです。バンドルをロードする方法を考え出すとき、私はこの同じエラーに遭遇しました。

私はこれが直感的ではないと思いますが、そのメソッドを呼び出す必要はありません。代わりに、以下のアプローチを試してみてください。

こちらがお役に立てば幸いです。それでもエラーが発生した場合は、バンドルを作成した方法に問題がある可能性があります。注意

UIView *resourceView = nil; 

NSBundle *resourceBundle = [NSBundle bundleWithPath:resourcePath]; 

@try { 
    //Try to load the NIB from the given bundle 
    resourceView = [[resourceBundle loadNibNamed:nibName owner:owner options:nil] lastObject]; 
} 
@catch (NSException *exception) { 
    //do nothing - will search in main bundle 
} 

//If loading from the given bundle failed, try loading from the main bundle 
if (!resourceView) { 
    NSBundle *resourceBundle = [NSBundle mainBundle]; 

    @try { 
     resourceView = [[resourceBundle loadNibNamed:nibName owner:owner options:nil] lastObject]; 
    } 
    @catch (NSException *exception) { 
     //do nothing - will return nil, indicating an error occurred 
    } 
} 

return resourceView; 

Wordのこの道を下って行く前に、あなたが本当にバンドルを作成する必要がある唯一の理由は、XIBファイルを追加することであることに注意することが重要です。イメージ、オーディオ、ビデオファイルなどのその他の資産については、ファイルを単に圧縮してサーバーの場所からダウンロードして、ドキュメントディレクトリに解凍するだけで十分です(さらには簡単です)。

XIBで使用されるアセットを更新する必要がある場合は、XIBで(またはXIBでデフォルトを設定することに加えて)これらのアセットをプログラムで読み込むのが最適です。こうすることで、バンドル手法を使用せずに、上記のようにzipアーカイブを使用することができます。

+0

Sheamusに感謝しますが、これは私が必要とするものではありません..私はリモートサーバーからプラグインをダウンロードしてコードをロードするアプリケーションを開発しています実行時に.. – davideb

+0

@davidebどのようにバンドルを作成しましたか? – Sheamus

+0

バンドルプロジェクト(拡張子.plugin)を作成し、ベースSDKを最新のiOSに変更する – davideb

関連する問題