官术网_书友最值得收藏!

Setting up the iOS-based development environment

This recipe outlines the steps to set up the environment for the iOS-based (for example, iPhone, iPad, iPod) development.

Getting ready

JDK is installed and the following environment variables are set correctly:

  • JAVA_HOME
  • PATH

You should have created the ch01_01.js file as mentioned in the previous recipe.

How to do it...

Carry out the following steps:

  1. Download and install Xcode from Apple Developer Portal (http://developer.apple.com). This requires you to have membership of the iOS and Mac developer programs.
  2. Download the copy of PhoneGap-1.0.0 and extract its contents. Navigate to the iOS directory and run the installer until completion.
  3. Launch Xcode, and under the File menu, select New and then New Project. Name the new project SenchaTouch.
  4. Select PhoneGap-based Application from the list of templates.
  5. Click on the Next button. Fill in the Product Name and Company Identifier for your application.
  6. Choose a directory in which to store your application.
  7. You should see your project in Xcode 4 now. Click on the Run button at the top-left corner. Your build should succeed and launch in the simulator.
  8. You should see an error in your simulator informing you that index.html was not found.
  9. In order to fix this, we need to copy the www directory into the project. Right-click on the project in the left navigation window and click on Show in finder.
  10. In Finder, you should see the www directory beside your project.
  11. Drag the www folder into Xcode 4.
  12. Move the C:\sencha-touch folder to www.
  13. After you drag, you should see a prompt with a few options. Make sure to select Create folder references for any added folders and click on Finish.
  14. Add the ch01 folder to www and copy the ch01_01.js file, which was created in the previous recipe, inside it.
  15. Open the folder named www and paste the following code in index.html:
    <!DOCTYPE HTML>
    <html>
      <head>
        <title>Yapps! - Your daily applications!</title>
        <link rel="stylesheet" href="sencha-touch/resources/css/sencha-touch.css" type="text/css">
        <script type="text/javascript" charset="utf-8" src="phonegap.1.0.0.js"></script>
        <script type="text/javascript" charset="utf-8" src="sencha-touch/sencha-touch-debug.js"></script>
        <script type="text/javascript" charset="utf-8" src="ch01/ch01_01.js"></script>
      </head>
      <body></body>
    </html>
  16. Deploy to Simulator:
    • Make sure to change the Active SDK in the top-left menu to Simulator+version#
    • Click on Run in your project window header
  17. Deploy to Device:
    • Open SenchaTouch-Info.plist and change BundleIdentifier to the identifier provided by Apple. If you have a developer license, then you can access and run the Assistant at http://developer.apple.com/iphone/manage/overview/index.action and register your App.
    • Make sure to change the Active SDK in the top left menu to Device+version#.
    • Click on Run in your project window header.

How it works...

In steps 1 and 2, we downloaded and installed XCode and other required tools and libraries. XCode is the IDE provided by Apple for the iOS-based application development.

In steps 3 through 6, we created a PhoneGap-based iOS project, using XCode.

In steps 7 through 14, we prepared the www folder for the application. Its contents are described in the Setting up the Android-based development environment recipe.

In step 15, we included the Sencha Touch related files and the application specific JS file—ch01_01.js—in index.html.

In steps 16 and 17, we deployed and tested the application in the simulator, as well as a real iOS device, such as iPhone.

See also

The recipe named Setting up the Android-based development environment in this chapter.

主站蜘蛛池模板: 文水县| 宣汉县| 定南县| 松江区| 壤塘县| 新安县| 台山市| 灵川县| 会泽县| 增城市| 宜黄县| 海宁市| 奈曼旗| 额济纳旗| 渭源县| 宜宾县| 克拉玛依市| 通化县| 墨脱县| 来安县| 万山特区| 常州市| 昌都县| 通化县| 鄢陵县| 唐河县| 宁国市| 汨罗市| 茌平县| 昆山市| 兖州市| 新昌县| 海盐县| 拜泉县| 资中县| 仁布县| 磴口县| 茂名市| 延吉市| 尼勒克县| 页游|