博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PhoneGap iOS Platform Guide(PhoneGap iOS 平台 交互文档)
阅读量:4032 次
发布时间:2019-05-24

本文共 6860 字,大约阅读时间需要 22 分钟。

This guide shows how to set up your SDK development environment to deploy Cordova apps for iOS devices such as iPhone and iPad. See the following for more detailed platform-specific information:

  • iOS Command-line Tools

The command-line tools above refer to versions prior to Cordova 3.0. See  for information about the current interface.

Apple® tools required to build iOS applications run only on the OS X operating system on Intel-based Macs. Xcode® 6.0 (the minimum required version) runs only on OS X version 10.9 (Mavericks) or greater, and includes the iOS 8 SDK (Software Development Kit). To submit apps to the Apple App Store℠ requires the latest versions of the Apple tools.

You can test many of the Cordova features using the iOS emulator installed with the iOS SDK and Xcode, but you need an actual device to fully test all of the app's device features before submitting to the App Store. The device must have at least iOS 6.x installed, the minimum iOS version supported as of Cordova 3.0. Supporting devices include all iPad® models, iPhone® 3GS and above, and iPod® Touch 3rd Generation or later. To install apps onto a device, you must also be a member of Apple's , which costs $99 per year. This guide shows how to deploy apps to the iOS emulator, for which you don't need to register with the developer program.

There are two ways to download Xcode:

  • from the , available by searching for "Xcode" in the App Store application.

  • from , which requires registration as an Apple Developer.

Once Xcode is installed, several command-line tools need to be enabled for Cordova to run. From the Xcode menu, selectPreferences, then the Downloads tab. From the Components panel, press the Install button next to the Command Line Toolslisting.

Use the cordova utility to set up a new project, as described in The Cordova . For example, in a source-code directory:

    $ cordova create hello com.example.hello "HelloWorld"    $ cd hello    $ cordova platform add ios    $ cordova prepare              # or "cordova build"

Once created, you can open it from within Xcode. Double-click to open the hello/platforms/ios/hello.xcodeproj file. The screen should look like this:

To preview the app in the iOS emulator:

  1. Make sure the .xcodeproj file is selected in the left panel.

  2. Select the hello app in the panel immediately to the right.

  3. Select the intended device from the toolbar's Scheme menu, such as the iPhone 6.0 Simulator as highlighted here:

  4. Press the Run button that appears in the same toolbar to the left of the Scheme. That builds, deploys and runs the application in the emulator. A separate emulator application opens to display the app:

    Only one emulator may run at a time, so if you want to test the app in a different emulator, you need to quit the emulator application and run a different target within Xcode.

Xcode comes bundled with emulators for the latest versions of iPhone and iPad. Older versions may be available from the Xcode → Preferences → Downloads → Components panel.

For details about various requirements to deploy to a device, refer to the Configuring Development and Distribution Assetssection of Apple's . Briefly, you need to do the following before deploying:

  1. Join the Apple iOS Developer Program.

  2. Create a Provisioning Profile within the . You can use its Development Provisioning Assistant to create and install the profile and certificate Xcode requires.

  3. Verify that the Code Signing section's Code Signing Identity within the project settings is set to your provisioning profile name.

To deploy to the device:

  1. Use the USB cable to plug the device into your Mac.

  2. Select the name of the project in the Xcode window's Scheme drop-down list.

  3. Select your device from the Device drop-down list. If it is plugged in via USB but still does not appear, press theOrganizer button to resolve any errors.

  4. Press the Run button to build, deploy and run the application on your device.

Deprecation Warnings: When an application programming interface (API) is changed or replaced by another API, it is marked asdeprecated. The API still works in the near term, but is eventually removed. Some of these deprecated interfaces are reflected in Apache Cordova, and Xcode issues warnings about them when you build and deploy an application.

Xcode's warning about the invokeString method concerns functionality that launches an app from a custom URL. While the mechanism to load from a custom URL has changed, this code is still present to provide backwards functionality for apps created with older versions of Cordova. The sample app does not use this functionality, so these warnings can be ignored. To prevent these warnings from appearing, remove the code that references the deprecated invokeString API:

  • Edit the Classes/MainViewController.m file, surround the following block of code with /* and */ comments as shown below, then type Command-s to save the file:

    (void)webViewDidFinishLoad:(UIWebView*)theWebView{
    // only valid if ___PROJECTNAME__-Info.plist specifies a protocol to handle/*if (self.invokeString) {  // this is passed before the event is fired, so you can access it in js when you receive   NSLog(@"DEPRECATED: window.invokeString - use the window.handleOpenURL(url) function instead, which is always called when the app is launched through a custom scheme url.");  NSString* jsString = [NSString stringWithFormat:@"var invokeString = \"%@\";", self.invokeString];  [theWebView stringByEvaluatingJavaScriptFromString:jsString];}*/// Black base color for background matches the native appstheWebView.backgroundColor = [UIColor blackColor];return [super webViewDidFinishLoad:theWebView];}
  • Edit the Classes/AppViewDelegate.m file, comment out the following line by inserting a double slash as shown below, then type Command-s to save the file:

    //self.viewController.invokeString = invokeString;
  • Press Command-b to rebuild the project and eliminate the warnings.

Missing Headers: Compilation errors relating to missing headers result from problems with the build location, and can be fixed via Xcode preferences:

  1. Select Xcode → Preferences → Locations.

  2. In the Derived Data section, press the Advanced button and select Unique as the Build Location as shown here:

This is the default setting for a new Xcode install, but it may be set differently following an upgrade from an older version of Xcode.

For further information, consult Apple's documentation:

  •  provides a quick overview of steps for developing iOS Apps.

  •  provides links to several iOS technical resources including technical resources, the provisioning portal, distribution guides and community forums.

  •  from the Apple World Wide Developer Conference 2012 (WWDC2012)

  • The , which helps specify the correct version of Xcode if more than one is installed.

(Mac®, OS X®, Apple®, Xcode®, App Store℠, iPad®, iPhone®, iPod® and Finder® are Trademarks of Apple Inc.)

转载地址:http://gtebi.baihongyu.com/

你可能感兴趣的文章
带WiringPi库的交叉笔译如何处理二之软链接概念
查看>>
Spring事务的七种传播行为
查看>>
ES写入找不到主节点问题排查
查看>>
Java8 HashMap集合解析
查看>>
ArrayList集合解析
查看>>
欢迎使用CSDN-markdown编辑器
查看>>
Android计算器实现源码分析
查看>>
Android系统构架
查看>>
Android 跨应用程序访问窗口知识点总结
查看>>
各种排序算法的分析及java实现
查看>>
SSH框架总结(框架分析+环境搭建+实例源码下载)
查看>>
js弹窗插件
查看>>
自定义 select 下拉框 多选插件
查看>>
js判断数组内是否有重复值
查看>>
js获取url链接携带的参数值
查看>>
gdb 调试core dump
查看>>
gdb debug tips
查看>>
arm linux 生成火焰图
查看>>
jtag dump内存数据
查看>>
linux和windows内存布局验证
查看>>