You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 3 години
преди 3 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
преди 5 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <link rel="stylesheet" href="../../style.css">
  6. </head>
  7. <body>
  8. <script data-goatcounter="https://services.opengamestudio.org:443/count" async src="//services.opengamestudio.org:443/count.js"></script>
  9. <div id="header">
  10. <div>
  11. <strong id="title">Open Game Studio</strong>
  12. <div id="lang">
  13. <a href="../../en/news/ios-tutorial.html">EN</a>
  14. <a href="../../ru/news/ios-tutorial.html">RU</a>
  15. </div>
  16. </div>
  17. <div class="header2">
  18. <div class="menu">
  19. <a href="../../en/news/index.html">News</a>
  20. <a href="../../en/game/index.html">Games</a>
  21. <a href="../../en/tool/index.html">Tools</a>
  22. <a href="../../en/page/about.html">About</a>
  23. </div>
  24. <a class="discord" href="https://discord.gg/3A6THQabNf">
  25. <img src="../../images/discord.png"></img>
  26. </a>
  27. <div class="clear"></div>
  28. </div>
  29. </div>
  30. <h3 class="left_item_title">In the news...</h3>
  31. <center>
  32. <div class="news_item">
  33. <h2 class="news_item_title">
  34. <a href="ios-tutorial.html">iOS tutorial</a>
  35. </h2>
  36. <p class="news_item_date">
  37. 2017-06-08 10:00
  38. </p>
  39. <div class="news_item_contents">
  40. <p><img src="../../images/2017-06-08-ios-refactoring.png" alt="Earth and a rocket" /></p>
  41. <p>This article describes problems we faced during the creation of iOS tutorial in May 2017.</p>
  42. <p><a href="https://twitter.com/OpenGameStudio/status/826816343433498627">This February</a> we managed to get simple model rendered under iOS in just a few days. We expected to finish iOS tutorial in no time. However, the reality reminded us: it's easy to come up with a hackish demo that works for one person, but it's hard to create a concise example that works for everyone.</p>
  43. <p><strong>Native library</strong></p>
  44. <p>The first question we had to answer was: should the sample application be part of Xcode project or be a separately built library?</p>
  45. <p>We had to consider the following facts:</p>
  46. <ol>
  47. <li>Xcode project can use C++ directly (thanks to Objective-C++) without stuff like JNI<ul>
  48. <li>There's no need for a separate library (+ application)</li>
  49. <li>Creating a separate library is an additional work (- library)</li></ul></li>
  50. <li>OpenSceneGraph builds libraries<ul>
  51. <li>It's easier to use standard build process (+ library)</li>
  52. <li>It's harder to create custom build process just for a single platform (- application)</li></ul></li>
  53. <li>OpenSceneGraph uses CMake build system, which is not supported by Xcode<ul>
  54. <li>Xcode project can't include CMake files (- application)</li>
  55. <li>It's easy to create custom CMake file that includes OpenSceneGraph CMake file to build a single library (+ library)</li></ul></li>
  56. <li>CMake can generate Xcode project<ul>
  57. <li>It's possible to create a CMake file that builds both OpenSceneGraph and the sample application (+ application)</li>
  58. <li>Xcode is the de-facto tool to create Xcode projects; it's easier to use standard build process (+ library)</li></ul></li>
  59. </ol>
  60. <p>After evaluating the pros and cons of each approach, we decided to turn the sample application into a library and include it in Xcode project. The downside of this approach is that simulator and real device builds need separate library builds.</p>
  61. <p><strong>Refactoring</strong></p>
  62. <p>The second question we had to answer was: should there be a single source code base for all platforms or several ones, one for each platform?</p>
  63. <p>While doing Android tutorial we used single source code base because it worked fine for desktop and Android. As we started to work through iOS tutorial, it became apparent that particular features may or may not work on some platforms. For example, one feature may work on desktop and iOS, but not Android. Another feature may work on iOS and Android, but not desktop. Since we didn't want to pollute the code with #ifdefs, we started to put each platform combination into a separate file. The number of files grew rapidly. The files were reusable, but it became extremely hard to see the whole picture.</p>
  64. <p>At this point, we realized there's the second question. We reminded ourselves that the main purpose of the sample source code is to teach how to do basic OpenSceneGraph things, not create a reusable library with API that is stable across several years.</p>
  65. <p>That's when our home grown feature tool came into play. With its help, we separated the code into several parts, which in the end produce just two files for each platform:</p>
  66. <ol>
  67. <li>functions.h - contains reusable classless functions</li>
  68. <li>main.h - contains the rest of the sample application code</li>
  69. </ol>
  70. <p>Their contents differ slightly for each platform, but it's easy to see the whole picture now.</p>
  71. <p>That's it for describing problems we faced during the creation of iOS tutorial in May 2017.</p>
  72. </div>
  73. </div>
  74. <div id="disqus_thread"></div>
  75. <script>
  76. var disqus_config = function () {
  77. this.page.url = "https://opengamestudio.org/en/news/ios-tutorial.html";
  78. this.page.identifier = "ios-tutorial.html";
  79. };
  80. (function() { // DON'T EDIT BELOW THIS LINE
  81. var d = document, s = d.createElement('script');
  82. s.src = 'https://opengamestudio.disqus.com/embed.js';
  83. s.setAttribute('data-timestamp', +new Date());
  84. (d.head || d.body).appendChild(s);
  85. })();
  86. </script>
  87. <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  88. <div id="footer">
  89. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  90. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  91. </div>
  92. </center>
  93. </body>
  94. </html>