con*_*ile 9 javascript android ios cordova
我使用Cordova有两个平台ios和android.当我改变我的东西时
Project/config.xml
Run Code Online (Sandbox Code Playgroud)
它将被合并到
Project/platforms/android/res/xml/config.xml
Project/platforms/ios/Project/config.xml
Run Code Online (Sandbox Code Playgroud)
做完cordova之后.
如何设置平台特定的设置,不会被cordova构建覆盖?
CKK*_*CKK 10
在平台元素内定义特定于平台的配置.
<platform name="android">
<preference name="Fullscreen" value="true" />
...
</platform>
Run Code Online (Sandbox Code Playgroud)
请参阅底部:http://cordova.apache.org/docs/en/4.0.0/config_ref_index.md.html
如果您使用旧版本的Cordova,请考虑更新,因为修复了许多关键问题.
你需要一个cordova钩子.我强烈建议你看看这个链接:Cordova Hooks
进一步来说:
mkdir -p hooks/after_prepare
touch hooks/after_prepare/change_my_configxml.sh
chmod 755 hooks/after_prepare/change_my_configxml.sh
edit hooks/after_prepare_change_my_configxml.sh
Run Code Online (Sandbox Code Playgroud)
#!/bin/bash
echo ${CORDOVA_VERSION};
echo ${CORDOVA_PLATFORMS};
echo ${CORDOVA_PLUGINS};
echo ${CORDOVA_HOOK};
echo ${CORDOVA_CMDLINE};
# == put commands to make your config xml changes here ==
# == replace this statement with your own ==
sed "s/index\.html/http:\/\/my.example.com\?platform=ios\&cordova=3.4.0/" platforms/ios/www/config.xml > config.tmp && mv -f -v config.tmp platforms/ios/www/config.xml
Run Code Online (Sandbox Code Playgroud)
请注意,cordova挂钩最初放在.cordova/hooks/...中,但最近他们已经移动到顶级挂钩/文件夹.
这是一个完全有效的脚本,用于创建和运行两个略有不同的cordova应用程序.有趣的是,iOS平台文件夹的config.xml中的属性似乎被忽略,因此该脚本在处理iOS时更新顶级config.xml.
#!/bin/bash
# ==== Create cordova apps with different URLs for android and iOS
cordova create appFolder com.example.myApp "My App"
cd appFolder/
cordova platform add ios
cordova platform add android
# ==== make an after_prepare hook script
mkdir -p hooks/after_prepare
touch hooks/after_prepare/change_my_configxml.sh
chmod 755 hooks/after_prepare/change_my_configxml.sh
# ==== start of hook script content ====
echo '#!/bin/bash
echo "CORDOVA_VERSION: ${CORDOVA_VERSION}";
echo "CORDOVA_PLATFORMS: ${CORDOVA_PLATFORMS}";
echo "CORDOVA_PLUGINS: ${CORDOVA_PLUGINS}";
echo "CORDOVA_HOOK: ${CORDOVA_HOOK}";
echo "CORDOVA_CMDLINE: ${CORDOVA_CMDLINE}";
# == put commands to make your config xml changes here ==
# == replace these statement with your own ==
if [ ! -f platforms/android/res/xml/config.xml ]
then
cp -v -f config.xml platforms/android/res/xml/config.xml;
fi
if [[ ${CORDOVA_PLATFORMS} == android ]]; then
sed -E "s/<content src=\"[^\"]+\"/<content src=\"http:\/\/www.google.com\/search\?q=Google%20Nexus%205\&hl=xx-bork\"/" platforms/android/res/xml/config.xml > config.tmp && mv -f -v config.tmp platforms/android/res/xml/config.xml
fi
if [[ ${CORDOVA_PLATFORMS} == ios ]]; then
sed -E "s/<content src=\"[^\"]+\"/<content src=\"http:\/\/www.google.com\/search\?q=iPad%20Retina\&hl=xx-bork\"/" config.xml > config.tmp && mv -f -v config.tmp config.xml
fi
' > hooks/after_prepare/change_my_configxml.sh
# ==== end of hook script content ====
cordova prepare android
cordova build android
cordova emulate android
cordova prepare ios
cordova build ios
cordova emulate ios
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5971 次 |
| 最近记录: |