ios.html 8.7 KB

123456789101112131415161718192021222324252627
  1. <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, iOS, Mac, MacOS, deployment, platform"><title>ios</title><link rel="stylesheet" href="./asciidoctor.css">
  2. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  3. <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"><link rel="stylesheet" href="/home/travis/build/jMonkeyEngine/wiki/build/asciidoc/html5/jme3/twemoji-awesome.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/jme3/ios.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/jme3/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"></div><h1>ios</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#ios-deployment">iOS Deployment</a><ul class="sectlevel2"><li><a href="#enabling-ios-deployment">Enabling iOS deployment</a></li><li><a href="#building-the-ios-binaries">Building the iOS binaries</a></li><li><a href="#running-and-deploying-the-application">Running and deploying the application</a></li><li><a href="#creating-native-and-java-code-for-ios">Creating native and java code for iOS</a></li></ul></li></ul></div></div><div id="content"><div class="sect2"><h3 id="ios-deployment">iOS Deployment</h3><div class="paragraph"><p>To use iOS deployment you need a computer running MacOSX and a version of Xcode 4.0+ installed. To deploy to a device or the Apple App Store, you need an Apple developer account.</p></div>
  4. <div class="admonitionblock warning"><table><tr><td class="icon"><i class="fa icon-warning" title="Warning"></i></td><td class="content"><div class="paragraph"><p>Note that at the moment iOS deployment is in alpha state.</p></div></td></tr></table></div>
  5. <div class="paragraph"><p>iOS deployment works via cross-compilation to native iOS ARM code, there is no virtual machine running on the device. The Avian JVM supports this feature while maintaining general compatibility to OpenJDK and JNI for native access. The minimum compatible iOS deployment target is 4.3.</p></div>
  6. <div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>To install the iOS deployment plugin, go to Tools→Plugins and under “Available plugins select the “iOS Support plugin.</p></div></td></tr></table></div>
  7. <div class="sect2"><h3 id="enabling-ios-deployment">Enabling iOS deployment</h3><div class="paragraph"><p>To enable iOS deployment, go to the project settings and under “Application→iOS select the “Enable iOS deployment checkbox, adapt the application ID and then press OK.</p></div>
  8. <div class="paragraph"><p><span class="image"><img src="../jme3/ios-deployment.png" alt="ios-deployment.png" width="" height=""></span></p></div>
  9. <div class="paragraph"><p>After enabling deployment, a new <code>ios</code> directory is created in the project root that contains a <code>project</code> and a <code>src</code> folder. The <code>ios/project</code> folder contains an Xcode project that you will use to build and run the final iOS application for both iPhone and iOS. The <code>ios/src</code> folder contains java and native source files for bridging iOS and native code, you can add .java and .m files with your own iOS code here.</p></div>
  10. <div class="admonitionblock important"><table><tr><td class="icon"><i class="fa icon-important" title="Important"></i></td><td class="content"><div class="paragraph"><p>When you enable iOS deployment for the first time or any time that the Avian library and OpenJDK is updated, they will be extracted to your SDK settings folder, wait until it has been extracted before building an iOS-enabled project.</p></div></td></tr></table></div></div>
  11. <div class="sect2"><h3 id="building-the-ios-binaries">Building the iOS binaries</h3><div class="paragraph"><p>The iOS binaries are automatically built when you have iOS deployment enabled and build your project in the jME3 SDK.</p></div>
  12. <div class="paragraph"><p>When the iOS binaries are built, all needed classes, including a complete copy of the OpenJDK7 classes are run through a proguard process that strips out the unnecessary classes for the project and optimizes the code for the platform. This happens without changing the naming structure so that reflection etc. still works. If necessary, adapt the proguard options in the ios properties file.</p></div>
  13. <div class="paragraph"><p>After the iOS classpath has been created the avian compiler is used to create a native .o file from the classpath for both arm (device) and i386 (simulator). Furthermore the other needed avian .o files are extracted and a library list is compiled which is referenced in the Xcode project.</p></div>
  14. <div class="paragraph"><p>If an error occurs about jni.h not being found, either install the SDK for 10.9 in XCode or set the header search path in the XCode project settings, in the default project thats<br>
  15. <code>/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/</code><br>
  16. <code>SDKs/MacOSX10.9.sdk/System/Library/Frameworks/JavaVM.framework/Headers/</code></p></div></div>
  17. <div class="sect2"><h3 id="running-and-deploying-the-application">Running and deploying the application</h3><div class="paragraph"><p>To run the application, open the Xcode project under <code>ios/project</code> in Xcode and press the run button. You can make changes to the UI and native invocation classes in the Xcode project as well. From here you can also deploy the application to your devices or the App Store.</p></div>
  18. <div class="admonitionblock tip"><table><tr><td class="icon"><i class="fa icon-tip" title="Tip"></i></td><td class="content"><div class="paragraph"><p>Note that you should also adapt the project settings like application name and registration package in Xcode before deploying the final application.</p></div></td></tr></table></div></div>
  19. <div class="sect2"><h3 id="creating-native-and-java-code-for-ios">Creating native and java code for iOS</h3><div class="paragraph"><p>To bridge between native and java code, JNI is used like in a normal java application. The <code>ios/src</code> folder is for Java and C/Obj-C source files that are specific to your iOS application. In these java files you have access to the full project classpath as well as the iOS-specific jME3 classes.</p></div>
  20. <div class="paragraph"><p>The JmeAppHarness.java class is initialized and called from native code through the default project and you can extend it to perform other native operations. It has a simple native popup method. The JmeAppHarness.m file contains the native method needed for that popup.</p></div>
  21. <div class="paragraph"><p>Effectively native code can reside in both the Xcode project and in the <code>ios/src</code> folder. To keep the dependencies clean and make code reusable you should try to put generic native code that does not depend on the Xcode project in the <code>ios/src</code> folder. You can also mix and match ARC and non-ARC code through this by converting the main project to use ARC and putting code with manual memory management in the <code>ios/src</code> folder.</p></div>
  22. <div class="paragraph"><p>Java code for iOS should be in the <code>ios/src</code> folder as well for clean separation, its also the only place where they will be compiled with a reference to the iOS specific jME classes. For information on how to connect your application code and device specific code, see the <a href="../jme3/android.html#using_android_specific_functions">notes in the android deployment documentation</a>.</p></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2019-12-22 21:29:50 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
  23. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  24. indexName: 'jmonkeyengine',
  25. inputSelector: '#doc-search',
  26. debug: false // Set debug to true if you want to inspect the dropdown
  27. });</script></body></html>