<?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 iOS -Thinker on Medium]]></title>
        <description><![CDATA[Stories by iOS -Thinker on Medium]]></description>
        <link>https://medium.com/@sinha18alok?source=rss-6c0df25c9929------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JWZ8mz4Y8EGMJQcqGMSImQ.png</url>
            <title>Stories by iOS -Thinker on Medium</title>
            <link>https://medium.com/@sinha18alok?source=rss-6c0df25c9929------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 06:08:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sinha18alok/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[Measure iOS Build-to-Launch Time and Send to Google Sheets with Bash]]></title>
            <link>https://medium.com/@sinha18alok/measure-ios-build-to-launch-time-and-send-to-google-sheets-with-bash-9e9a3540316c?source=rss-6c0df25c9929------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e9a3540316c</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[cicd-pipeline]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[iOS -Thinker]]></dc:creator>
            <pubDate>Sun, 06 Jul 2025 17:14:01 GMT</pubDate>
            <atom:updated>2025-07-09T21:00:11.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kgVlrlFXApI4azn0pV2ugg.png" /></figure><p>As iOS projects grow, build and launch times can become frustratingly long especially in CI environments or large teams. Wouldn’t it be useful to track this metric over time and visualize it in Google Sheets?</p><p>In this post, I’ll show you how to:</p><p>Use Xcode <strong>Pre-action</strong> and <strong>Post-action</strong> scripts</p><p>Measure <strong>build-to-launch duration</strong></p><p>Send the result to a <strong>Google Sheet via webhook</strong></p><h3>⚙️ Step 1: Create Pre-Action Script in Xcode</h3><p>In <strong>Xcode</strong>:</p><ul><li>Go to <strong>Product &gt; Scheme &gt; Edit Scheme…</strong></li><li>Choose the <strong>Run</strong> phase from the sidebar</li><li>Select <strong>Pre-actions</strong> and add a new <strong>Run Script Action</strong></li><li>Paste this script:</li></ul><pre>#!/bin/bash<br>echo $(date +%s) &gt; &quot;${PROJECT_DIR}/build_start_time.txt&quot;</pre><p>📌 This records the <strong>start time</strong> to a file before launching the app.</p><h3>✅ Step 2: Create Post-Action Script to Measure and Send</h3><p>Under <strong>Post-actions</strong>, add this Run Script:</p><pre>#!/bin/bash<br><br>START_TIME=$(cat &quot;${PROJECT_DIR}/build_start_time.txt&quot;)<br>END_TIME=$(date +%s)<br>DURATION=$((END_TIME - START_TIME))<br>MACHINE=$(hostname)<br>DATE=$(date +%Y-%m-%dT%H:%M:%S)<br><br>PAYLOAD=&quot;{\&quot;machine\&quot;:\&quot;$MACHINE\&quot;,\&quot;date\&quot;:\&quot;$DATE\&quot;,\&quot;duration\&quot;:$DURATION}&quot;<br><br># Replace with your Google Apps Script Webhook URL <br>curl -X POST -H &quot;Content-Type: application/json&quot; -d &quot;$PAYLOAD&quot; https://script.google.com/macros/s/YOUR_SCRIPT_ID/exec</pre><p>🔁 This:</p><ul><li>Reads the start time</li><li>Calculates duration</li><li>Formats a JSON payload</li><li>Sends it via curl to a webhook (e.g., Google Apps Script)</li></ul><h3>📊 Step 3: Create a Google Sheet Logger (Apps Script)</h3><p>To log data into Google Sheets:</p><ol><li>Open a Google Sheet</li><li>Go to <strong>Extensions &gt; Apps Script</strong></li><li>Paste the script below:</li></ol><pre>function doPost(e) {<br>  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();<br>  var data = JSON.parse(e.postData.contents);<br>  sheet.appendRow([new Date(), data.machine, data.date, data.duration]);<br>  return ContentService.createTextOutput(&quot;Success&quot;);<br>}</pre><p>4. Click <strong>Deploy &gt; Manage deployments</strong></p><p>5. Choose <strong>Web app</strong>, and make it accessible to “Anyone”</p><p>6. Copy the URL and replace it in your Bash script</p><h3>📈 Example Output in Google Sheets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYx7y0ebqT1d3jI2LHsLfQ.png" /></figure><h3>✅ Benefits of This Setup</h3><ul><li>📦 <strong>No app code</strong> — all handled in build scripts</li><li>📈 <strong>Track performance over time</strong></li><li>🌐 <strong>Send to any backend, not just Google Sheets</strong></li><li>🧪 <strong>Great for CI/CD and QA automation</strong></li></ul><h3>📌 Conclusion</h3><p>Using Xcode’s scripting capabilities, you can monitor and log build-to-launch durations in real time. With a simple Google Apps Script webhook, you now have a living dashboard inside Google Sheets to help track and reduce friction in your iOS workflow.</p><ul><li>Send the result to a <strong>Google Sheet via webhook</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F2ePlyM1c1DqKrD0ezXkEA.png" /></figure><p>Thanks 🤩</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e9a3540316c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scrollview in auto-layout (programmatically)]]></title>
            <link>https://medium.com/@sinha18alok/scrollview-in-auto-layout-programmatically-a39d78fb4c0f?source=rss-6c0df25c9929------2</link>
            <guid isPermaLink="false">https://medium.com/p/a39d78fb4c0f</guid>
            <dc:creator><![CDATA[iOS -Thinker]]></dc:creator>
            <pubDate>Sat, 23 Sep 2023 00:22:09 GMT</pubDate>
            <atom:updated>2023-09-23T00:47:17.091Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*qf8ir7jVhC3RF7xSdhvE6Q.png" /></figure><p>Scrollview is a widely used component in iOS. Scrollview is important to keep the screen’s content efficient and presentable.</p><p>Let’s see how it can be used correctly with minimum code in Swift. ⛷️</p><p>1. Create a scroll view object</p><pre>let scrollView = UIScrollView()<br>scrollView.translatesAutoresizingMaskIntoConstraints = false<br>view.addSubview(scrollView)</pre><p>2. Create ui objects or a custom view and add to scrollview. I am creating a stack view with some labels (to make it long enough to scroll), It can be any view object.</p><pre>let stackView = UIStackView()<br>stackView.axis = .vertical<br>stackView.alignment = .fill<br>stackView.translatesAutoresizingMaskIntoConstraints = false<br>        <br>for element in (1..&lt;25) {<br>     let label = UILabel()<br>     label.numberOfLines = 0<br>     label.translatesAutoresizingMaskIntoConstraints = false<br>     label.text = &quot;Number : \(element): This is label on stack view, which is being used to show a scroll view demo 🐰 \n \n&quot;<br>     stackView.addArrangedSubview(label)<br>}<br><br>scrollView.addSubview(stackView)</pre><p>3. Time to add constraints. <br>This is the most important segment. scroll view will have constraints with respect to view and the constraints of stack view have to be with respect to `<strong>scrollView.contentLayoutGuide`</strong></p><pre>// scrollview constraints<br> NSLayoutConstraint.activate([ scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),<br> scrollView.trailingAnchor.constraint(equalTo: view.trailingAnchor),<br> scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),<br> scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor)])<br>        <br>// stackview constraints<br>  let contentLayoutGuide = scrollView.contentLayoutGuide<br>          <br> NSLayoutConstraint.activate([<br>    stackView.widthAnchor.constraint(equalTo: view.widthAnchor),<br>    stackView.leadingAnchor.constraint(equalTo: contentLayoutGuide.leadingAnchor),<br>    stackView.trailingAnchor.constraint(equalTo:contentLayoutGuide.trailingAnchor),<br>    stackView.topAnchor.constraint(equalTo: contentLayoutGuide.topAnchor),<br>    stackView.bottomAnchor.constraint(equalTo: contentLayoutGuide.bottomAnchor)<br>  ])</pre><p>That’s mainly to make the scroll view work as expected, the content is scrollable 😃. <br>I hope it helps. Feel free to add your comments and feedback. 🙏</p><p>LINK: <a href="https://github.com/aloksinha18/CodeExamples/blob/main/Scrollview.playground/Contents.swift">code example (swift playground )</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*KsDxfOrelKLmPNqDdC9Fyw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a39d78fb4c0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing Auto layout (UIView-Encapsulated-Layout-Width)constraint ☞]]></title>
            <link>https://medium.com/@sinha18alok/fixing-auto-layout-uiview-encapsulated-layout-width-constraint-b5583356f80c?source=rss-6c0df25c9929------2</link>
            <guid isPermaLink="false">https://medium.com/p/b5583356f80c</guid>
            <category><![CDATA[swift-programming]]></category>
            <category><![CDATA[autolayout-constraints]]></category>
            <category><![CDATA[autolayout-ios]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[iOS -Thinker]]></dc:creator>
            <pubDate>Sat, 26 Sep 2020 21:04:41 GMT</pubDate>
            <atom:updated>2025-07-29T17:24:14.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*8ZPKQ4zbnYH-kQNzQeuOkQ.jpeg" /></figure><h3>🛠 Fixing “UIView‑Encapsulated‑Layout-Width ” Auto Layout Warnings</h3><p>When building UIs programmatically, you might encounter auto layout warnings like:</p><pre>UIView-Encapsulated-Layout-Width.constraint… width == 0<br>UILabel.trailing == mainView.trailing – 16</pre><p>These warnings often occur when UIKit-generated “encapsulated” constraints conflict with your own required ones.</p><h3>⚙️ Why This Happens</h3><p>System views — like UITableViewCell or UICollectionViewCell—internally add constraints such as UIView‑Encapsulated‑Layout‑Width/Height. These tell the cell its desired size.</p><p>🧠 Real Example</p><pre>&lt;NSLayoutConstraint: UIView‑Encapsulated‑Layout‑Width ... width == 0&gt;<br>&lt;NSLayoutConstraint: label.trailing == mainView.trailing – 16&gt;</pre><p>Here, UIKit may be forcing a zero width, conflicting with your trailing constraint.</p><p>✅ The Fix: Use a Lower Priority</p><p>Rather than required (1000), set your constraints to a slightly lower priority — like 999 — so UIKit’s layout can override when needed. Here’s a handy extension:</p><pre>extension NSLayoutConstraint {<br>  func setPriority(_ priority: UILayoutPriority) -&gt; NSLayoutConstraint {<br>    self.priority = priority<br>    return self<br>  }<br>}<br><br>extension UILayoutPriority {<br>  static var mainlyRequired: UILayoutPriority {<br>    .init(rawValue: 999)<br>  }<br>}</pre><p>You can then apply:</p><pre>NSLayoutConstraint.activate([<br>  termLabel.leadingAnchor<br>    .constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor, constant: 20)<br>    .setPriority(.mainlyRequired)<br>])</pre><h3>🌟 Result</h3><p>No more auto layout errors — the system gracefully handles conflicts, and your layout looks good.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5583356f80c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>