【发布时间】:2020-04-10 08:49:53
【问题描述】:
我已按照本教程在我的 Windows 机器上构建应用程序。
https://www.npmjs.com/package/vue-cli-plugin-cordova
我安装了 android studio、java jdk 1.8、gradle 和 android sdk 来为 android 构建。然后我运行以下命令:
npm run cordova-build-android
我得到了我想要的 apk。 现在我想使用以下命令构建一个 iOS 应用程序:
npm run cordova-build-ios
我必须安装什么?我需要安装虚拟机、mac os 和 xcode 吗?我可以用我的源代码维护我现有的项目结构吗?
我必须在我的 config.xml 中添加什么?我用axios,想用http访问xampp服务器。
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.demo.app"
version="1.0.0"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:android="http://schemas.android.com/apk/res/android">
<name>VueExampleAppName</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- this hook will point your config.xml to the DevServer on Serve -->
<hook type="after_prepare" src="../node_modules/vue-cli-plugin-cordova/serve-config-hook.js" />
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="electron">
<preference name="ElectronSettingsFilePath" value="res/electron/settings.json" />
<icon src="res/icon/electron/foreground.png" />
</platform>
<platform name="android">
<allow-intent href="market:*" />
<icon background="res/icon/android/background.png" density="ldpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="mdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="hdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxhdpi" foreground="res/icon/android/foreground.png" />
<icon background="res/icon/android/background.png" density="xxxhdpi" foreground="res/icon/android/foreground.png" />
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera2" />
</config-file>
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
另一个问题:我可以在mac机器上为android构建apk吗?
这样更好:
Allow Phone Call android; npm run cordova-build-ios; npm run cordova-build-android; whatsapp
【问题讨论】:
标签: android ios cordova npm build