dpogue commented on code in PR #1498:
URL: https://github.com/apache/cordova-ios/pull/1498#discussion_r1800527751


##########
CordovaLib/CordovaLib.docc/upgrading-8.md:
##########
@@ -0,0 +1,189 @@
+# Upgrading Plugins to Cordova iOS 8.x
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+# http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
+
+A guide for plugin authors to understand the API changes in Cordova iOS 8.x.
+
+## Major Breaking Changes
+### Changes to the generated app project naming
+
+The generated app template is now consistently named `App`, including 
`App.xcodeproj` and `App.xcworkspace`. The Xcode build target for the app is 
also named `App`. If you are expecting the name of the Xcode project or target 
to match the name specified in config.xml, it will now fail to find the project.
+
+Use the cordova-ios nodeJS API to retrieve the Xcode project path and other 
project details:
+
+```js
+// Old code
+const projectRoot = context.opts.projectRoot;
+const platformPath = path.join(projectRoot, 'platforms', 'ios');
+
+const config = getConfigParser(context, path.join(projectRoot, 'config.xml'));
+const projectName = config.name();
+
+const pbxprojPath = path.join(platformPath, projectName + '.xcodeproj', 
'project.pbxproj');
+const xcodeProject = xcode.project(pbxprojPath);
+```
+
+```js
+// New code
+const projectRoot = context.opts.projectRoot;
+const platformPath = path.join(projectRoot, 'platforms', 'ios');
+
+const cordova_ios = require('cordova-ios');
+const iosProject = new cordova_ios('ios', platformPath);
+
+const xcodeProject = xcode.project(iosProject.locations.pbxproj);
+```
+
+This updated pattern is backwards compatible with existing versions of Cordova 
iOS 5.0.0 and newer.
+  
+### CDVAppDelegate window deprecation
+
+The generated app template now uses the `UIScene` API to support multiple 
windows, which means that it's no longer a safe assumption that an app has only 
a single window.
+
+The ``CDVAppDelegate/window`` property of ``CDVAppDelegate`` is deprecated due 
to moving to the `UIScene` API.  This property will always have a `nil` value.
+
+```objc
+// Old code
+// Include example here of how to get the root window
+```
+
+
+```objc
+// New code
+// Include example here of how to get the root window
+```
+
+### CDVAppDelegate viewController deprecation
+
+The ``CDVAppDelegate/viewController`` property of ``CDVAppDelegate`` is 
deprecated, and may return `nil` if a `CDVViewController` has not yet been 
initialized.
+
+Plugins should prefer accessing the view controller using their 
``CDVPlugin/viewController`` property (which is now typed as 
``CDVViewController``).
+  
+### UIView scrollView property deprecation
+
+The `scrollView` property added as a global category extension to `UIView` is 
now deprecated in Objective C code and **removed entirely in Swift code**. This 
is to prevent conflicts with other Swift classes that extend `UIView` and have 
their own `scrollView` properties.
+
+You can still access the `scrollView` property of the web view by dynamically 
invoking the method:
+
+```objc
+// Old code
+UIScrollView *scroller = self.webView.scrollView;
+```
+
+```objc
+// New code
+#import <objc/message.h>
+
+UIScrollView *scroller;
+SEL scrollViewSelector = NSSelectorFromString(@"scrollView");
+
+if ([self.webView respondsToSelector:scrollViewSelector]) {
+    scroller = ((id (*)(id, SEL))objc_msgSend)(self.webView, 
scrollViewSelector);
+}
+```

Review Comment:
   The helper method that we have now is monkeypatched onto the base `UIView` 
class as a public property in a category extension, and this causes errors for 
Swift classes that are subclasses of `UIView` with their own `scrollView` 
properties that declare `package`, `fileprivate`, or `internal` visibility 
(because our helper requires those override to be `public`). See 
https://github.com/apache/cordova-ios/issues/1399 for details.
   
   Removing the `UIView` category is the best way to prevent conflicts with 
other code, including system libraries.
   
   Unfortunately, when a plugin accesses the WebView in a Cordova app, it's 
typed as a `UIView` because we don't know the actual implementation type of the 
web view (`WKWebView`, `UIWebView`, or some 3rd party webview that's only 
allowed to exist in the EU). Hence the need to dynamically dispatch the 
selector.
   
   However, it is hopefully pretty rare for plugins to need to directly 
interface with the webview's internal scrolling implementation...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to