plugin.xmlの一部
<!-- ios -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="MyPlugin">
<param name="ios-package" value="MyPlugin"/>
</feature>
</config-file>
<!--this need to be added to the .plist file-->
<config-file target="*-Info.plist" parent="UIBackgroundModes">
<array>
<string>location</string>
</array>
</config-file>
<header-file src="src/ios/MyPlugin.h" />
<source-file src="src/ios/MyPlugin.m" />
</platform>
左側はプラグインをインストールする前、右側はインストール後です:
前に見たように:
<key>NSMainNibFile</key>
<string></string>
<key>NSMainNibFile~ipad</key>
<string></string>
以降
<key>NSMainNibFile</key>
<string>
</string>
<key>NSMainNibFile~ipad</key>
<string>
</string>
なんと大きな違いでしょう!どこから来たのかわからない空白を削除すると、起動後にクラッシュすることはありません!
iOS 6 シミュレータ出力 (ただし、デバイスでも同じです)
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/myusername/Library/Application Support/iPhone Simulator/6.0/Applications/F4FDE3C4-D7A8-440F-866D-D0DECD79E2F5/My.app> (loaded)' with name '
''
*** First throw call stack:
(0xea012 0x2848e7e 0xe9deb 0x540fac 0x54298d 0x324ceb 0x325002 0x323ed6 0x335315 0x33624b 0x327cf8 0x367adf9 0x367aad0 0x5fbf5 0x5f962 0x90bb6 0x8ff44 0x8fe1b 0x3237da 0x32565c 0x1fe3c 0x1fd9d)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Cordova / Phonegap のバグだと思いますが、上司は喜んでいません。これを解決する方法は?.plist は、コマンド ラインから起動するたびに再生成されるため、手動で編集することはできません。
ドキュメントが見つかりません。これだけです。1回だけ書いたのに、なぜ自分の場所が4回追加されるのかわかりません。
編集:コマンドラインからプラグインをインストールした後(ただし、コンパイルまたは実行はしない)、plistは次のようになります。
<key>NSMainNibFile</key>
<string>
</string>
<key>NSMainNibFile~ipad</key>
<string>
</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
</array>
$ phonegap build ios
<key>NSMainNibFile</key>
<string>
</string>
<key>NSMainNibFile~ipad</key>
<string>
</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
<string>location</string>
</array>
-observe: 場所が追加された行があります!
$ phonegap run ios
[phonegap] detecting iOS SDK environment...
[phonegap] using the local environment
[phonegap] compiling iOS...
[phonegap] successfully compiled iOS app
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[phonegap] successfully installed onto emulator
plist は 2 回クリアされます。それらは 2 回クリアされ、最後に再度追加されます。plist は次のようになります。
<key>NSMainNibFile</key>
<string>
</string>
<key>NSMainNibFile~ipad</key>
<string>
</string>
<key>UIBackgroundModes</key>
<array>
<string>location</string>
<string>location</string>
<string>location</string>
<string>location</string>
<string>location</string>
</array>
編集2:
cordova prepare
ランダムに空白をクリアし、<string></string>
常に UIBackgroundModes 配列に追加し<string>location</string>
ます!