Tôi đang cố gắng biên dịch ứng dụng Ionic của mình bằng Phonegap Build (Tôi đang làm việc với máy Mac nên tôi không thể biên dịch sang iOS nếu không).Ionic Framework + Phonegap Xây dựng: quy trình làm việc
Quy trình làm việc tốt nhất là gì?
Cảm ơn
Tôi đang cố gắng biên dịch ứng dụng Ionic của mình bằng Phonegap Build (Tôi đang làm việc với máy Mac nên tôi không thể biên dịch sang iOS nếu không).Ionic Framework + Phonegap Xây dựng: quy trình làm việc
Quy trình làm việc tốt nhất là gì?
Cảm ơn
Đây là nỗ lực của riêng tôi để trả lời câu này (hãy giúp tôi cập nhật này để mọi người có thể được hưởng lợi):
Xây dựng ứng dụng của bạn với Ionic:
ionic start myApp sidemenu
etc...
Trong một Ionic mặc định ứng dụng tệp config.xml nằm trong thư mục gốc, phía trên thư mục www/
, vì vậy hãy di chuyển nó vào thư mục www/
để Phonegap Build tìm thấy nó.
mv config.xml www/
Sau đó zip
các www/
thư mục hoặc git push
nó từ máy tính cục bộ của bạn để repo git từ xa mà bạn đã liên kết với PhoneGap Build. Chỉ nén hoặc đẩy thư mục này, bởi vì nếu bạn để các thư mục khác có trong thư mục gốc Ionic, như node_modules, ứng dụng của bạn sẽ quá lớn để biên dịch trên Phonegap Build.
Sau đó, biên dịch trên Phonegap Build.
Sau khi chiến đấu suốt đêm và cả buổi sáng, tôi đã nghĩ ra một giải pháp tấn công.
Hy vọng nó sẽ giúp ai đó.
Tính đến v1.0 ion, ít nhất là cho dự án đơn giản của tôi, sự khác biệt lớn nhất là chỉ
Những gì tôi đã làm:
config.xml thay đổi:
ngụm bổ sung:
Điều này có nghĩa là xây dựng quy trình làm việc của tôi (cho đến khi tôi cần phải thay đổi điều gì đó trong config.xml) bây giờ trông như thế này:
gulp phonegap
Rõ ràng là rất nhiều khu vực để cải thiện ở đây nhưng tôi cần một thứ tôi có thể sử dụng để xuất bản ngay bây giờ. Trước khi chỉ tạo một tệp config_phonegap.xml tĩnh, tôi đã khám phá một vài ý tưởng như phân tích xml trong JS hoặc tạo một tệp XSLT. Đối với số tiền của nỗ lực, nó có vẻ như trở lại thấp vào thời điểm này vì vậy tôi đã không làm theo thông qua.
Dưới đây là bit mã có liên quan để tham khảo
Regex:
### icon regex
# android
<icon src="([\.\w\\-]+)" density="([\w-]+)"/>
<icon src="$1" gap:platform="android" gap:qualifier="$2"/>
# ios
<icon src="([@\.\w\\-]+)" width="([\d]+)" height="([\d]+)"/>
<icon src="$1" gap:platform="ios" width="$2" height="$3" />
### splash regex
# android
<splash src="([\.\w\\-]+)" density="([\w-]+)"/>
<gap:splash src="$1" gap:platform="android" gap:qualifier="$2" />
#ios
<splash src="([[email protected]\.\w\\-]+)" width="([\d]+)" height="([\d]+)"/>
<gap:splash src="$1" gap:platform="ios" width="$2" height="$3" />
mẫu PhoneGap tương thích config.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.yadda.yadda" version="2.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>my app name</name>
<description>
la di da desc
</description>
<author email="[email protected]" href="https://harhar.com/">w--</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="1500"/>
<icon src="resources/android/icon/drawable-ldpi-icon.png" gap:platform="android" gap:qualifier="ldpi"/>
<icon src="resources/android/icon/drawable-mdpi-icon.png" gap:platform="android" gap:qualifier="mdpi"/>
<icon src="resources/android/icon/drawable-hdpi-icon.png" gap:platform="android" gap:qualifier="hdpi"/>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" gap:platform="android" gap:qualifier="xhdpi"/>
<icon src="resources/android/icon/drawable-xxhdpi-icon.png" gap:platform="android" gap:qualifier="xxhdpi"/>
<icon src="resources/android/icon/drawable-xxxhdpi-icon.png" gap:platform="android" gap:qualifier="xxxhdpi"/>
<gap:splash src="resources/android/splash/drawable-land-ldpi-screen.png" gap:platform="android" gap:qualifier="land-ldpi" />
<gap:splash src="resources/android/splash/drawable-land-mdpi-screen.png" gap:platform="android" gap:qualifier="land-mdpi" />
<gap:splash src="resources/android/splash/drawable-land-hdpi-screen.png" gap:platform="android" gap:qualifier="land-hdpi" />
<gap:splash src="resources/android/splash/drawable-land-xhdpi-screen.png" gap:platform="android" gap:qualifier="land-xhdpi" />
<gap:splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" gap:platform="android" gap:qualifier="land-xxhdpi" />
<gap:splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" gap:platform="android" gap:qualifier="land-xxxhdpi" />
<gap:splash src="resources/android/splash/drawable-port-ldpi-screen.png" gap:platform="android" gap:qualifier="port-ldpi" />
<gap:splash src="resources/android/splash/drawable-port-mdpi-screen.png" gap:platform="android" gap:qualifier="port-mdpi" />
<gap:splash src="resources/android/splash/drawable-port-hdpi-screen.png" gap:platform="android" gap:qualifier="port-hdpi" />
<gap:splash src="resources/android/splash/drawable-port-xhdpi-screen.png" gap:platform="android" gap:qualifier="port-xhdpi" />
<gap:splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" gap:platform="android" gap:qualifier="port-xxhdpi" />
<gap:splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" gap:platform="android" gap:qualifier="port-xxxhdpi" />
<icon src="resources/ios/icon/icon.png" gap:platform="ios" width="57" height="57" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="114" height="114" />
<icon src="resources/ios/icon/icon-40.png" gap:platform="ios" width="40" height="40" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="80" height="80" />
<icon src="resources/ios/icon/icon-50.png" gap:platform="ios" width="50" height="50" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="100" height="100" />
<icon src="resources/ios/icon/icon-60.png" gap:platform="ios" width="60" height="60" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="120" height="120" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="180" height="180" />
<icon src="resources/ios/icon/icon-72.png" gap:platform="ios" width="72" height="72" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="144" height="144" />
<icon src="resources/ios/icon/icon-76.png" gap:platform="ios" width="76" height="76" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="152" height="152" />
<icon src="resources/ios/icon/icon-small.png" gap:platform="ios" width="29" height="29" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="58" height="58" />
<icon src="resources/ios/icon/[email protected]" gap:platform="ios" width="87" height="87" />
<gap:splash src="resources/ios/splash/[email protected]~iphone.png" gap:platform="ios" width="640" height="1136" />
<gap:splash src="resources/ios/splash/Default-667h.png" gap:platform="ios" width="750" height="1334" />
<gap:splash src="resources/ios/splash/Default-736h.png" gap:platform="ios" width="1242" height="2208" />
<gap:splash src="resources/ios/splash/Default-Landscape-736h.png" gap:platform="ios" width="2208" height="1242" />
<gap:splash src="resources/ios/splash/[email protected]~ipad.png" gap:platform="ios" width="2048" height="1536" />
<gap:splash src="resources/ios/splash/Default-Landscape~ipad.png" gap:platform="ios" width="1024" height="768" />
<gap:splash src="resources/ios/splash/[email protected]~ipad.png" gap:platform="ios" width="1536" height="2048" />
<gap:splash src="resources/ios/splash/Default-Portrait~ipad.png" gap:platform="ios" width="768" height="1024" />
<gap:splash src="resources/ios/splash/[email protected]~iphone.png" gap:platform="ios" width="640" height="960" />
<gap:splash src="resources/ios/splash/Default~iphone.png" gap:platform="ios" width="320" height="480" />
<icon src="icon.png"/>
<gap:splash src="splash.png" />
<!-- so android doesnt' go bat shit crazy -->
<preference name="permissions" value="none"/>
<!-- plugins -->
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<gap:plugin name="cordova-plugin-statusbar" source="npm" version="1.0.0">
<param name="onload" value="true" />
</gap:plugin>
<gap:plugin name="cordova-plugin-splashscreen" source="npm" version="2.0.0" />
</widget>
nhiệm vụ ngụm:
// **** Build phonegap *****/
var PHONEGAP_BUILD_FOLDER = '../phonegap',
PHONEGAP_RAW_FOLDER = 'www',
IONIC_SOURCE_FOLDER = './www',
IONIC_RESOURCE_FOLDER = './resources'
PHONEGAP_ZIP_FILE = 'phonegap_build.zip';
gulp.task('phonegap', function(cb){
runSequence('clean_phonegap',
'copy_www',
'copy_resources',
'copy_phonegap_config_xml',
'copy_default_icon',
'copy_default_splash',
'zip_phonegap',
cb);
});
gulp.task('clean_phonegap', function(cb){
// clean our folder first
var phonegap_del_pattern = PHONEGAP_BUILD_FOLDER + '/*';
del([phonegap_del_pattern], {force: true}, cb);
})
gulp.task('copy_www', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER
return gulp.src([IONIC_SOURCE_FOLDER + '/**'])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder))
})
gulp.task('copy_phonegap_config_xml', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER
return gulp.src(['config_phonegap.xml'])
.on('error', swallowError)
.pipe(rename('config.xml'))
.pipe(gulp.dest(target_phonegap_folder));
})
gulp.task('copy_resources', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER + '/resources',
exclude_pattern = '!' + IONIC_RESOURCE_FOLDER + '/_source_assets{,/**}'
// exclude pattern needs to go first. mother fucker.
return gulp.src([exclude_pattern, IONIC_RESOURCE_FOLDER + '/**'])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})
gulp.task('copy_default_icon', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER + '/ios/icon.png' ])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})
gulp.task('copy_default_splash', function(){
var target_phonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER;
return gulp.src([IONIC_RESOURCE_FOLDER + '/splash.png' ])
.on('error', swallowError)
.pipe(gulp.dest(target_phonegap_folder));
})
gulp.task('zip_phonegap', function(){
var sourcephonegap_folder = PHONEGAP_BUILD_FOLDER + '/' + PHONEGAP_RAW_FOLDER
return gulp.src(sourcephonegap_folder + '/**')
.pipe(zip('phonegap.zip'))
.on('error', swallowError)
.pipe(gulp.dest(PHONEGAP_BUILD_FOLDER));
})
Bài đăng của w-- hữu ích, nhưng tôi thực sự không cần nhiều giai đoạn đó cho công việc của mình. Ngoài ra, config.xml của tôi có vẻ hoạt động tốt với PhoneGap Build. Vì vậy, nhiệm vụ ngụm đơn này sẽ zip lên www và config.xml vào một tập tin .zip:
gulp.task('phonegap_zip', function(){
return gulp.src(['./www/**', './config.xml'])
.pipe(zip('phonegap.zip'))
.pipe(gulp.dest('./phonegap/'));
});
Nếu bạn muốn tự động tạo ra các tập tin cấu hình cho PhoneGap xây dựng, sử dụng này:
npm install pgb-config-maker --save
./make-config-xml.sh
Lệnh tiếp theo:
phonegap remote build ios
Bạn có thể làm điều đó với Gói Ionic. Họ cung cấp 100 bản dựng/tháng.
Các tài liệu cho nó có sẵn ở đây: http://docs.ionic.io/services/package/#summary
Nếu bạn cần phải gửi nó vào iTunes Connect, bạn có thể sử dụng này: https://software.intel.com/en-us/forums/intel-xdk/topic/670364#comment-1895468
tôi không thể tin rằng việc thiếu sự chú ý câu hỏi này là nhận được. –