<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stephen Goldberg on Medium]]></title>
        <description><![CDATA[Stories by Stephen Goldberg on Medium]]></description>
        <link>https://medium.com/@agoldberg_23007?source=rss-f3e37bedf4f6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*G7cQBKfO929nC5AIErG4ag.png</url>
            <title>Stories by Stephen Goldberg on Medium</title>
            <link>https://medium.com/@agoldberg_23007?source=rss-f3e37bedf4f6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:18:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@agoldberg_23007/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Scaling cross-team contributions to a native mobile app]]></title>
            <link>https://medium.com/salesforce-engineering/scaling-cross-team-contributions-to-a-native-mobile-app-79c4ec9669e5?source=rss-f3e37bedf4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c4ec9669e5</guid>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[collaboration]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Stephen Goldberg]]></dc:creator>
            <pubDate>Tue, 25 Jan 2022 16:07:16 GMT</pubDate>
            <atom:updated>2022-01-25T16:07:16.214Z</atom:updated>
            <content:encoded><![CDATA[<h3>By Stephen Goldberg, Alex Sikora, and Jean Bovet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aC0NfCtvMgj8qJTigr2DdQ.jpeg" /></figure><p>Flagship applications are home to myriad functionalities that serve different parts of your userbase. Often, adding a new feature unintentionally causes reduced velocity, single points of failure, and monoliths that are hard to navigate. Such flagship apps are built from contributions from multiple teams each with varying degrees of familiarity with the codebase.</p><p>Onboarding a new team to such a codebase is expensive and usually prohibited for reasons like:</p><ul><li><strong>Onboarding costs</strong> — It simply takes too long to bring someone up to speed with the codebase such that they can contribute. The cost of training and mentoring someone to do so is often as high if not more significant than implementing the feature would have been. This investment does not make sense for someone who will develop one feature and then move back to their team.</li><li><strong>Maintenance cost</strong> — Who will maintain this feature once the temporary developer has returned to their original team?</li><li><strong>Quality</strong> — What risk does the new feature, developed by someone without a strong understanding of the architecture and codebase pose to the main application?</li></ul><p>We’ve seen this play out before with many enterprise apps, including the Salesforce Mobile app. But there’s a way to enable contributions from other teams while addressing the above challenges. This blog outlines the strategy we used within Salesforce to make it happen: an approach we call our “Plug-in Architecture.”</p><h3>Plug-in architecture</h3><h4>What is a plug-in architecture?</h4><p>In a traditional plug-in architecture, third-party developers create plug-ins that are installed separately from the host application. These plug-ins extend the capability of the host application by adding new features. Typically, the architecture works like this:</p><ol><li>The host application defines a set of interfaces that the plug-in must implement.</li><li>The host application injects a set of interfaces into the plug-in, which it may use.</li><li>The plug-in registers itself when it installs, then the host application loads it.</li></ol><figure><img alt="Diagram showing the dependencies between plugins and implementations" src="https://cdn-images-1.medium.com/max/628/1*60jBvEW0VktmhBwMwOlS0w.png" /><figcaption>Diagram showing the dependencies between plugins and implementations</figcaption></figure><p>Keep in mind when using this architecture:</p><ul><li>The host application shouldn’t depend on a particular plug-in, since users might not install it.</li><li>The host application isn’t aware of a plug-in’s details, it only implements the necessary interface.</li></ul><h3>Plug-in architecture and mobile</h3><p>Engineers create, install, and distribute software packages differently for mobile and desktop environments. In light of these differences, let’s discuss what characteristics of plug-in architecture apply to a mobile app development environment.</p><p>Plug-ins are the perfect example of modular architecture. They don’t have any critical dependencies because the host application can run without them. In many cases, the host application doesn’t know what the plug-in does, only that it supports the prescribed interface. Modularity is inherent to most recommended architectures, so your application is probably already structured like this.</p><p>Plug-ins implement an interface defined by the host app. This interface is an abstraction of what the app needs from the plug-in, and it’s the only dependency between the app and a plug-in. Correctly defining this interface is the most challenging aspect of plug-in architecture. But because all plug-ins conform to this interface, app developers don’t need to write code for integrating a specific plug-in. As mentioned earlier, the app may not even be aware of all the potential plug-ins that a user might install.</p><p>The app provides an interface to the plug-in. This interface lets the plug-in interact with the host application. The plug-in developers only need to learn this interface and can ignore any other complexity of the host application. This greatly simplifies the learning curve for developers, since the interface is only an abstraction of functionalities a plug-in might need from the application, like sending network requests, storing data, or presenting a UX.</p><p>Some restrictions of the plug-in architecture, enforced by necessity in a desktop environment, may seem like they could be ignored or relaxed in a mobile application. But it’s best to develop as if these restrictions were still in place.</p><p>In desktop app development, the host app must run without a particular plug-in, since there’s no guarantee a user will install it. But, in mobile development, the app developer bundles the plug-in’s framework or Android Archive (AAR) with the main app. Plug-ins have to be included at build time and deployed with the main app bundle; you can’t install plug-ins independently of the main application. Since the host application is aware of all available plug-ins at build time, you might think mobile apps don’t need to support graceful degradation without the plug-in, but that’s not the case.</p><p>For example, suppose that a developer builds the application to depend directly on a plug-in, since the plug-in is “already there.” This dependency breaks the abstraction and makes the application rely on specific versions of the plug-in, which forces the app team to be involved in any maintenance decisions for it. The dependency also implies integration work beyond adding the plug-in to the application, as some code in the app references the specific plug-in. A direct reference extends the work required for a plug-in beyond the interface boundaries.</p><p>This is why it’s best practice to gate features, allowing the developer to toggle them on or off if required. If the application cannot gracefully handle the absence of a plug-in, then there is no real opportunity to disable it via a feature toggle.</p><h3>Implementing a plug-in like architecture</h3><p>So how can we replicate the benefits of a plug-in architecture in a mobile app? Most experienced developers are familiar with the values of modularity, loose coupling, and high cohesion. For this article, we won’t focus on these specifically, since they’re primarily achieved automatically by the following two characteristics:</p><ul><li><em>Service Provider Interface,</em> which exposes services to the plug-in.</li><li><em>Feature Provider Interface, </em>which extends feature implementations from the plug-in to the host app.</li></ul><h3>The Service Provider Interface (SPI)</h3><p>The Service Provider Interface (SPI) is an abstraction that encapsulates all the services the application makes available to the plug-in. This interface allows a plug-in to treat the app as a platform. It helps avoid duplicating common services such as logging, network requests, instrumentation, and others within the plug-in. The application injects the SPI into the plug-in at initialization.</p><p>Although Apple and Google both provide network request libraries, most enterprise-class apps have a higher-level network layer responsible for supplying appropriate cookies, request parameters, or other domain-specific overheads. Rather than recreate this in each plug-in, a host application can expose an interface as part of the SPI. Let’s consider this example, and see how we might implement such an SPI.</p><pre>public protocol NetworkRequests {<br>    func send(request: POSTRequest, to server: Server)<br>}</pre><p>The following code snippet is a simplistic example of how a host application might implement this abstraction.</p><pre>class PluginNetwork: NetworkRequests {<br>    func send(request: POSTRequest, to server: Server) {<br>        let networkEngine = NetworkService.getEngineForUser(user: user)<br>        networkEngine.send(request: request, to: server)<br>    }<br>}</pre><h3>The Feature Provider Interface (FPI)</h3><p>While the SPI abstracts the application’s services to the plug-in, the Feature Provider Interface (FPI) is its counterpart, abstracting the services exposed by the plug-in. The SPI allows the plug-ins to run on top of the host application and avoid bloating the plug-in with redundant service implementations. The FPI, on the other hand, is how the plug-in extends the host application.</p><p>A new feature might consist of a root viewController (iOS) or fragment (Android) from which further interaction occurs. The following code snippet demonstrates what an FPI might look like for obtaining the view controller from the plug-in.</p><pre>protocol PluginFeatureProvider {<br>    func pluginCanNavigate(to destination: Destination)<br>    func controller(for destination: Destination) -&gt; UIViewController<br>}</pre><p>The plug-in will implement this to respond affirmatively if the destination is one the plug-in handles, and likewise returns the appropriate view controller when requested.</p><pre>class MyPlugin {<br>    func pluginCanNavigate(to destination: Destination) {<br>        if destination.type == .MyPluginType {<br>            return true<br>        }<br>        return false<br>    }<br>    <br>    func controller(for destination: Destination) -&gt; UIViewController? {<br>        if destination.type == .MyPluginType {<br>            return myPluginViewControllerFactory.createRootViewController<br>                                                 (for: destination)<br>        }<br>        return nil<br>    }    <br>}</pre><h3>Our experience with plug-in architecture</h3><p>In late 2018, another team at Salesforce reached out to us with a simple question: “How can we get our feature included in the Salesforce mobile app?” Typically, such a question has an easy answer. “File a request, and we’ll get back to you once it’s prioritized.” But as more and more teams had similar requests, it became apparent that limiting feature contributions to the Salesforce app development team was not going to scale. So we started asking a new question: “How can we get these features included in the Salesforce app despite prioritization conflicts?” This is what led to the plug-in architecture discussed in this article.</p><p>One obvious solution to the feature request was asking the requesting team to spend some time in our mobile development team to do the integration themselves. But as described above: who would maintain it after integration? Who would train their team on the intricacies of our flagship application code? How could we ensure the changes maintain the high quality that our customers expect from us?</p><p>By introducing a plug-in-like architecture, we could reshape how external teams contribute native features to our mobile app. Both the Salesforce App and the other team sat down to define the shape of the plug-in architecture and its APIs. A few months later, the initial adopter had successfully integrated their feature into the Salesforce app. But more importantly, we had established a successful model in which teams can push new updates to their feature anytime they want with no involvement from the Salesforce app team while maintaining the same level of quality.</p><p>In late 2019, a company recently acquired by Salesforce wanted to do the same thing. This team didn’t have any inside knowledge of our flagship application nor the intricacies of the Salesforce Platform. Nevertheless, the plug-in architecture let them integrate their product into the Salesforce app in record time. They achieved this because they could focus on a finite and straightforward set of APIs.</p><p>While these external integrations were happening, we decided to adopt the same plug-in model for features of the flagship application developed by the Salesforce app team members. The idea was to treat features of the Salesforce app the same as external integrations. The architecture enforced a clear boundary for the new feature code, which let developers focus on the value-added by the new feature instead of the main application code. The first internal feature written using the plug-in architecture was for calendar integration and management. The developer worked on the feature for a few days and came back delighted by the simplifications from the plug-in architecture. For example, a secure persistence SPI trivialized storing encrypted data, because the plug-in SPI provided an interface for doing just that. It was up to the host app layer to worry about the implementation. By developing her feature as a plug-in, she could also isolate it to an independent module, making it more easily tested and maintained.</p><p>The team is reaping the benefits, with several features in development using this architecture across iOS and Android platforms. The plug-in architecture transforms the Salesforce app into a native development platform with numerous plug-ins running on top of it. This transformation reduces the time it takes to bring features to our users.</p><p>Additionally, all the plug-ins developed on this architecture can easily be ported, without changes, to another application if needed, provided the other application implements the required plug-in APIs. This portability brings tremendous flexibility for our teams, who can simultaneously deploy their features in their application and the Salesforce app.</p><h3>Revisiting external contributions</h3><p>At the outset of this post, we discussed a scenario where other teams had feature requests for a flagship application, even offering resources to develop them. The app team rejected this offer for the following reasons: onboarding costs, maintenance costs, and quality concerns from letting an external entity modify the codebase. Let’s look at how the above architectural proposal addresses each of these in turn.</p><h3>Onboarding Costs</h3><p>The plug-in architecture significantly reduces onboarding costs by shrinking the surface space of required knowledge down to the SPI and FPI. In our case, although we offer office-hours-type support, most of the education on the SPI and FPI is done through simple interface documentation.</p><h3>Maintenance Costs</h3><p>Since plug-ins are modular and exposed as binary modules (frameworks, AARs), the development team that creates them also owns and maintains them. The host app team doesn’t incur any of the maintenance costs.</p><h3>Quality Concerns</h3><p>As the external team is not modifying the host app code, they pose little risk to the quality of the host app. The plug-in’s impact on the host app is constrained by what the host app exposes via the SPI. The plug-in itself must meet quality standards, as consumers will not distinguish between a plug-in-provided feature and a feature built by the app team. However, the concern here was not the quality of the plug-in feature but the risk of an external contributor modifying the host app code. Plus, due to the modular nature of plug-ins, if coupled with a feature toggle solution, a plug-in can be entirely disabled if there are quality issues.</p><h3>Conclusion</h3><p>Despite initial concerns that this approach would be overly restrictive, developers were surprised when, rather than creating friction and slowing down development, plug-in architecture accelerated it. Developing features as plug-ins shortened the timeframe for integrating features provided by external teams, and made features easier to develop and integrate for internal developers by developing them as plug-ins. We find once developers create a feature with the plug-in architecture, they have an “Aha!” moment and become true believers. If your team is looking for ways to enable scalable cross-team contributions to your mobile app, we recommend following a similar approach.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c4ec9669e5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/salesforce-engineering/scaling-cross-team-contributions-to-a-native-mobile-app-79c4ec9669e5">Scaling cross-team contributions to a native mobile app</a> was originally published in <a href="https://medium.com/salesforce-engineering">Salesforce Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging WebKit in Hybrid Mobile Apps]]></title>
            <link>https://medium.com/salesforce-engineering/debugging-webkit-in-hybrid-mobile-apps-2eee63a4c922?source=rss-f3e37bedf4f6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2eee63a4c922</guid>
            <category><![CDATA[general-engineering]]></category>
            <category><![CDATA[hybrid-app-development]]></category>
            <category><![CDATA[webkit]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Stephen Goldberg]]></dc:creator>
            <pubDate>Tue, 14 Jul 2020 15:36:00 GMT</pubDate>
            <atom:updated>2020-07-27T23:12:04.459Z</atom:updated>
            <content:encoded><![CDATA[<p>At WWDC 2018, Apple <a href="https://developer.apple.com/videos/play/wwdc2018/234/">announced</a> it was deprecating its original webview framework (UIWebView) in favor of a WebKit-based framework. WebKit is an open-source project used by both browsers and webviews, including Safari. The overall architecture of WKWebView is quite different than UIWebView, and this dramatically impacts what we can do when debugging hybrid apps, such as our own <a href="https://www.salesforce.com/solutions/mobile/overview/">Salesforce App</a>.<br> <br>The Salesforce App is full of powerful native features, but the incredible flexibility of the app is due to its Hybrid nature. Hybrid apps allow for the benefits of native apps while using WebViews to deliver experiences built on web technologies. In the case of the Salesforce App, this includes <a href="https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_intro.htm">Visualforce</a>, <a href="https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/intro_framework.htm">Lightning (Aura)</a>, and <a href="https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.get_started_introduction">Lightning Web Components</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Da2w6eKi_5n7_gz6g4AjOw.png" /></figure><h3>WebKit Architecture</h3><p>The first major shift from UIWebView to WebKit was moving from an in-process framework to a multi-process architecture. WebKit splits functionality into multiple processes, multiple copies of which may be running at a single time.</p><ul><li>UIProcess — This is your app. The WKWebview code and WebKit framework is loaded in your process space</li><li>WebContent, aka WebProcess — This is where JS and DOM memory allocations reside</li><li>Network Process — This process is responsible for making the underlying network requests associated with web requests</li><li>Storage Process — This process is used for database and service worker storage.</li></ul><p>Because WebKit now splits responsibility across multiple processes, not everything occurs in your own process space. As a consequence, debugging hybrid issues may require attaching to multiple processes. Unfortunately, attaching a debugger to a process requires that the process is built with specific entitlements, which is not the case for the WebKit processes deployed on iOS devices or in the Simulator runtime environments. But, there IS a way!</p><h3>Get the WebKit Source</h3><p>The first step for debugging hybrid app behavior under WebKit is to get the WebKit source code. The WebKit source is quite large; at the time of this article, it takes up 10.4Gb of storage.</p><p>You can pull the source using Git or SVN. Although the WebKit team prefers SVN, we prefer Git, so we will write from that perspective. Clone the WebKit repo as follows: <br> <br> git clone git://git.webkit.org/WebKit.git WebKit<br> <br>The Git repo does not track all of the branches that the SVN repository does. For most debugging, you can use master; however, if you are trying to troubleshoot a specific behavior tied to a particular iOS release, you will have more work to do. The iOS release branches are not present in the Git repo, so you will have to set up tracking of the SVN branches from Git. If this is a requirement, follow the steps at the WebKit blog <a href="https://trac.webkit.org/wiki/UsingGitWithWebKit">here</a>. This will use considerably more space, so be prepared. Also, expect some challenges getting git-svn up and working on Catalina, so only attempt this if necessary.</p><h3>Build WebKit for the iOS Simulator</h3><p>I find that staying on the latest GA version of Xcode will minimize any compilation issues you have with WebKit source, but your mileage may vary. Keep in mind that you can have multiple versions of Xcode installed and can build WebKit with one version and your app in another. <br> <br>The WebKit team has included some Perl5 and Python3 scripts which automate much of the work. If any one of these scripts fails, a first step might be to ensure you are running a current version of Python3 and Perl5.<br> <br>The first thing we do is prepare our Xcode environment for building WebKit using the script:<br> <br> sudo Tools/Scripts/configure-xcode-for-embedded-development<br> <br>This script will copy a few files from the Mac OSX SDK to the iOS SDK folders, generate a stub header, and other goodies that are required before we can build and run WebKit on iOS.<br> <br>Next, we build the frameworks using another script provided by the WebKit team:<br> <br> Tools/Scripts/build-webkit --ios-simulator<br> <br>You can run build-webkit without any params to see additional options, including --debug. This will build and place the WebKit frameworks in the WebKitBuild subdirectory of where you cloned the Git repo. Go get something to drink, read a book, watch a movie; this will take a while.</p><h3>Using development build WebKit with hybrid apps</h3><p>Now we have some fancy new frameworks and xpc files in our WebKitBuild folder, but that does us no good if we cannot get the iOS simulator to use these frameworks instead of the standard WebKit frameworks. This can be done in one of two ways: via the command-line using the WebKit team’s scripts, or through Xcode.</p><h3>Command Line — Run-WebKit-App</h3><p>This method relies on another Perl Script provided by the WebKit team. To use it, you must build your app bundle and know the path to it. Typically your app will get built under derived data. <br> <br>Launch your app using the following command:<br> <br> Tools/Scripts/run-webkit-app <em>&lt;Path to your .App File&gt;</em> --ios-simulator<br> <br>This command</p><ul><li>Creates a new simulator image</li><li>Installs your app bundle</li><li>Executes your app in a runtime environment, which uses the previously built WebKit frameworks instead of the standard WebKit frameworks.</li></ul><p>Once your app is up and running, you can use Xcode to attach to your process and the WebKit processes. The WebKit processes built locally will have the suffix “.Development,” for example, com.apple.WebKit.WebContent.Development.</p><h3>Xcode</h3><p>Another method for launching your app with debug versions of WebKit is from the WebKit Xcode project. This approach has an advantage that the debugger will attach to all WebKit spawned processes. The command line method will launch the app in the simulator, but the debugger must be attached independently. If WebKit has spawned multiple processes, it may be challenging to find the specific one you want to attach. Also, if you’re going to break at a very early point in the lifecycle of WebKit, you may not be able to accurately time the attach operation. <br> <br>Open the WebKit workspace in Xcode, and then under File → Workspace Settings, select the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*Hl_VUWa0HWR1huYCDj0BYg.png" /></figure><ul><li>Change the Derived Data selection to “Workspace-relative Location”.</li><li>Type WebKitBuild in the text box.</li><li>Click Advanced</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*vIgAwlIRnj3UYIravoZrQg.png" /></figure><ul><li>Select Custom</li><li>Change the drop down list to Relative to Workspace.</li><li>Type WebKitBuild in the text boxes for Products and Intermediates.</li></ul><p>The next step is to point Xcode to our app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*elG9-c4bwLAp1OpwDr5oCw.png" /></figure><ul><li>Select WebKit as the active scheme under the Product → Scheme</li><li>Select Product → Scheme → Edit Scheme</li><li>Select the Run action, and you will see that there is no executable defined when we run WebKit</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*kFk9Vt-zDKO2o9ZKyBw3gQ.png" /></figure><ul><li>In the drop-down list for Executable, select Other and then locate the. App file for your app.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*wV01n2Opbjf7QJz3qX4Qng.png" /></figure><p>Now we are good to go!</p><ul><li>Select Product → Perform Action → Run Without Building to launch your app with the local versions of WebKit.</li><li>You will see the debugger auto-attach not only to your app, but also to the WebKit processes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*rJgPAFI8JE32p4wVQkvrRw.png" /></figure><p>Happy Debugging!</p><h3>Conclusion</h3><p>Hopefully this article lets you explore a bit deeper into your Hybrid stack and better understand how the WebKit layer on which you rely works. You may now debug into WebKit source code, or run Instruments to profile the WebKit processes when running your web apps. The WebKit team frequently posts helpful information to their blog at <a href="https://webkit.org/blog/">https://webkit.org/blog/</a>, which is where much of this information came from.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2eee63a4c922" width="1" height="1" alt=""><hr><p><a href="https://medium.com/salesforce-engineering/debugging-webkit-in-hybrid-mobile-apps-2eee63a4c922">Debugging WebKit in Hybrid Mobile Apps</a> was originally published in <a href="https://medium.com/salesforce-engineering">Salesforce Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>