ios - cordova 3.0 plugin plist config -


part of 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 added .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> 

left side before install plugin, right side after:

difference

as can see before:

<key>nsmainnibfile</key> <string></string> <key>nsmainnibfile~ipad</key> <string></string> 

and after

<key>nsmainnibfile</key> <string>      </string> <key>nsmainnibfile~ipad</key> <string>      </string> 

what big difference! if delete whitespaces, don't know came don't have crash after startup!

ios 6 simulator output ( same on device too)

*** terminating app due 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)' 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 exception (lldb)  

i think bug in cordova / phonegap, doesn't make boss happy. how solve this? .plist re-generated each time @ launch command line, can't manually edit.

can't find documentation, this , don't know why added location 4 times, if wrote 1 time.

edit: after install plugin command line (but not compile or run) plist looks this:

<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: there row location added!

$ phonegap run ios [phonegap] detecting ios sdk environment... [phonegap] using local environment [phonegap] compiling ios... [phonegap] compiled ios app [phonegap] trying install app onto device [phonegap] no device found [phonegap] trying install app onto emulator [phonegap] installed onto emulator 

the plist cleared 2 times: cleared 2x, added again. plist looks this:

<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> 

edit2:

cordova prepare 

randomly clears <string></string> white spaces , add <string>location</string> uibackgroundmodes array !

yes, appear bug in cordova's handling of plugins' configuration settings plist files.

the duplicate array entries annoying, shouldn't break build or affect app. whitespace added nsmainnibfile* settings cause xcode fail build nsinternalinconsistencyexception error message saw.

until fixed working around using following hook script - placed in .cordova/hooks/after_platform_add/patch_plist.sh:

#!/bin/bash if pushd platforms/ios 2>/dev/null ;   # ios-specific actions...     # patch *-info.plist     projname=$(echo *.xcodeproj|sed -e 's/\..*//')     sed -i '' '/<key>nsmainnibfile<\/key>/,/<\/string>/d' $projname/*-info.plist     sed -i '' '/<key>nsmainnibfile~ipad<\/key>/,/<\/string>/d' $projname/*-info.plist     popd fi 

this removes settings plist completely, aren't needed. removing them prevents cordova adding them in broken state after prepare.

the script needs made executable:

chmod a+x .cordova/hooks/after_platform_add/patch_plist.sh 

this should run after each platform add command, when plist generated - need run following commands afterwards regenerate , apply patch:

cordova platform rm ios -d cordova platform add ios -d 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -