{"id":401,"date":"2016-10-04T20:35:55","date_gmt":"2016-10-04T20:35:55","guid":{"rendered":"http:\/\/fluentreports.com\/blog\/?p=401"},"modified":"2016-10-04T20:40:08","modified_gmt":"2016-10-04T20:40:08","slug":"nativescript-ios-and-xcode-8-the-wonderful-world-of-breaking-changes","status":"publish","type":"post","link":"https:\/\/fluentreports.com\/blog\/?p=401","title":{"rendered":"NativeScript: iOS and xCode 8 the wonderful world of breaking changes"},"content":{"rendered":"<p><a href=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/10\/native8xcode.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-403 alignleft\" src=\"http:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/10\/native8xcode.png\" alt=\"native8xcode\" width=\"396\" height=\"361\" srcset=\"https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/10\/native8xcode.png 640w, https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/10\/native8xcode-300x274.png 300w, https:\/\/fluentreports.com\/blog\/wp-content\/uploads\/2016\/10\/native8xcode-624x569.png 624w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><\/a>For those who have upgraded to the all new xCode 8, you may have noticed some of the plugins breaking...\u00a0\u00a0\u00a0\u00a0 The biggest breaking change in NativeScript and xCode 8 is now things deep down in the ObjC runtime that used to be a function call are now a property.<\/p>\n<p>So, for example let say you needed to access <strong>UIScreen.mainScreen<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>In xCode 7 this was<br \/>\n<pre>var mainScreen = UIScreen.mainScreen();<\/pre><br \/>\nin xCode 8 this is now:<br \/>\n<pre>var mainScreen = UIScreen.mainScreen;<\/pre><br \/>\nNotice, it is no longer a <strong>FUNCTION<\/strong> call.\u00a0 It is a <strong>PROPERTY<\/strong>.\u00a0\u00a0 Now how do you make this compatible so your code can run with both xCode 7 and xCode 8.<\/p>\n<p>If you are developing an app; I recommend you use the helper function that Telerik added to NativeScript which they use throughout the core modules.<br \/>\n<pre>var utils = require(&#039;utils\/utils&#039;);\nvar mainScreen = utils.ios.getter(UIScreen, UIScreen.mainScreen);<\/pre><br \/>\nIf you have your own plugin, then I'm going to recommend you embed my code into your own plugin...\u00a0 The code is basically the same as Teleriks, but you eliminate the require call.<br \/>\n<pre>function iosProperty(theClass, theProperty) {\n&nbsp;&nbsp;&nbsp;&nbsp;if (typeof theProperty === &quot;function&quot;) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ xCode 7 and below\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return theProperty.call(theClass);\n&nbsp;&nbsp;&nbsp;&nbsp;} else {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\/\/ xCode 8+\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return theProperty;\n&nbsp;&nbsp;&nbsp;&nbsp;}\n}<\/pre><br \/>\nThen you use it the exact same way;<br \/>\n<pre>var mainScreen = iosProperty(UIScreen, UIScreen.mainScreen);<\/pre><br \/>\nHappy NativeScripting, and hopefully you can easily get all your plugins updated shortly to support both xCode 7 &amp; 8!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For those who have upgraded to the all new xCode 8, you may have noticed some of the plugins breaking...\u00a0\u00a0\u00a0\u00a0 The biggest breaking change in NativeScript and xCode 8 is now things deep down in the ObjC runtime that used to be a function call are now a property. So, for example let say you&hellip; <a class=\"more-link\" href=\"https:\/\/fluentreports.com\/blog\/?p=401\">Continue reading <span class=\"screen-reader-text\">NativeScript: iOS and xCode 8 the wonderful world of breaking changes<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[15,51,39],"tags":[],"class_list":["post-401","post","type-post","status-publish","format-standard","hentry","category-nativescript","category-plugins","category-tips","entry"],"_links":{"self":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401"}],"version-history":[{"count":3,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":405,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions\/405"}],"wp:attachment":[{"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentreports.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}