<?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 Alexander Pan on Medium]]></title>
        <description><![CDATA[Stories by Alexander Pan on Medium]]></description>
        <link>https://medium.com/@alexanderpan?source=rss-389d66d46ea5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gu8QVppOIXB285cT4s8_Cg@2x.jpeg</url>
            <title>Stories by Alexander Pan on Medium</title>
            <link>https://medium.com/@alexanderpan?source=rss-389d66d46ea5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:44:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexanderpan/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[iOS Tuist Project 現有專案導入 KMP]]></title>
            <link>https://medium.com/@alexanderpan/ios-tuist-project-%E7%8F%BE%E6%9C%89%E5%B0%88%E6%A1%88%E5%B0%8E%E5%85%A5-kmp-5329699ba364?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5329699ba364</guid>
            <category><![CDATA[kmp]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Fri, 27 Jun 2025 08:14:36 GMT</pubDate>
            <atom:updated>2025-06-27T08:14:36.447Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qYoY-pddRMU416VV.png" /></figure><p>距離公司導入已經將近一年了</p><p>近一年發生很多事情 💒、🫄、👶</p><p>最近才有空閒時間來寫。</p><p>初衷：</p><p>公司內部使用 KMP 撰寫一套核心程式碼共用邏輯在 iOS / Android，先使用串接後端 ABTesting 做為實驗，來驗證 KMP 是否在開發流程上是否會遇到問題，如果可以排除所有問題預計可以提高 iOS/Android 的開發效率，另外團隊成員中已經有熟悉 Android Studio, Kotlin 的團隊成員，預計可以花較短的時間熟悉 Kotlin 寫出高品質程式碼。</p><p>另外我們初步預計不直接拿 KMP 來寫 UI、特殊元件 …，因為可能會因為平台的不同元件，反而造成要處理更多問題，反而沒有解省我們的時間，只專注處理在永恆不變的邏輯與 RESTful API、GraphQL API …，既可以達到雙平台邏輯、Model 一致且又不用處理一些跨平台要處理的繁瑣事項。</p><p>這次做了很多事情：</p><ol><li>共用 ABTesting 邏輯</li><li>iOS : XCFramework + SPM</li><li>Android: Upload aar to <a href="https://docs.repsy.io/getting-started/what-is-repsy/">Repsy</a></li><li>Github Actions 自動化測試與部署</li></ol><p>實際導入後遇到哪些問題？</p><p>接下來就列出一些我認為重要的事情與遇到的問題與簡單的筆記。</p><p>因為公司內現有專案是使用 Tuist + µFeatures (The Modular Architecture)，因此在導入後遇到模組化的問題：</p><p>發現在同一個 KMP Project 之下就算有兩個獨立的 module ，打包後在 iOS 使用會遇到 Kotlin 的 primitive type 會是獨立寫在各自的 module 中，會變成每個 Module 都有一個獨立的 Kotlin 造成資料傳遞的困難，如圖一所示 atABTestingAppSDK 與 atABTestingAppSDKInterface 會出現兩個不同類型的 Kotlin。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*pKEhR1a1DADRWYUeQaO-Nw.png" /><figcaption>圖一</figcaption></figure><p>官方有一個文件是針對 Module 去做講解 C<a href="https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-project-configuration.html">hoosing a configuration for your Kotlin Multiplatform projec</a>t 這邊有完整比較各種不同的架構的 Pros &amp; Cons 針對</p><ol><li>Single shared module</li><li>Several shared modules</li><li>Monorepo: everything in one repository</li><li>Two repositories: Android + shared | iOS</li><li>Three repositories: Android | iOS | shared</li><li>Many repositories: Android | iOS | multiple libraries</li></ol><p>最後我們考量了 XCFramework 的大小，以及讓 primitive type 可以統一，所以最後採用 Umbrella module：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7tB3bE4kLhHwtuoy" /><figcaption>圖二</figcaption></figure><p>如果要實作 Umbrella module 就需要實作 <a href="https://kotlinlang.org/docs/native-spm.html#exporting-multiple-modules-as-an-xcframework">Exporting multiple modules as an XCFramework</a>，但還是測試看看實際的差異比較了一下，將兩個 Module 分開包 XCFramework vs 將兩個 Module 壓成一個 XCFramework，包出來的大小差異，你可以看到分開就是 4.1MB+4.1MB，如果是壓在一起後就是 4.2MB 大小會差非常多，如圖三所示。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/0*gbtPTXiqpf7WiYAU" /><figcaption>圖三</figcaption></figure><p>如何在哪邊搜尋有好用的 Libraries 可以使用？<a href="https://libs.kmp.icerock.dev/">https://libs.kmp.icerock.dev/</a></p><p>分享一下我們這次用到的套件：</p><pre>[libraries]<br>kotlin-test = { module = &quot;org.jetbrains.kotlin:kotlin-test&quot;, version.ref = &quot;kotlin&quot; }<br>androidx-activity-compose = { module = &quot;androidx.activity:activity-compose&quot;, version.ref = &quot;androidx-activityCompose&quot; }<br>compose-ui = { module = &quot;androidx.compose.ui:ui&quot;, version.ref = &quot;compose&quot; }<br>compose-ui-tooling = { module = &quot;androidx.compose.ui:ui-tooling&quot;, version.ref = &quot;compose&quot; }<br>compose-ui-tooling-preview = { module = &quot;androidx.compose.ui:ui-tooling-preview&quot;, version.ref = &quot;compose&quot; }<br>compose-foundation = { module = &quot;androidx.compose.foundation:foundation&quot;, version.ref = &quot;compose&quot; }<br>compose-material3 = { module = &quot;androidx.compose.material3:material3&quot;, version.ref = &quot;compose-material3&quot; }<br>ktor-client-core = { module = &quot;io.ktor:ktor-client-core&quot;, version.ref = &quot;ktor&quot; }<br>ktor-client-okhttp = { module = &quot;io.ktor:ktor-client-okhttp&quot;, version.ref = &quot;ktor&quot; }<br>ktor-client-darwin = { module = &quot;io.ktor:ktor-client-darwin&quot;, version.ref = &quot;ktor&quot; }<br>ktor-client-logging = { module = &quot;io.ktor:ktor-client-logging&quot;, version.ref = &quot;ktor&quot; }<br>ktor-client-content-negotiation = { module = &quot;io.ktor:ktor-client-content-negotiation&quot;, version.ref = &quot;ktor&quot; }<br>ktor-client-serialization-json = { module = &quot;io.ktor:ktor-serialization-kotlinx-json&quot;, version.ref = &quot;ktor&quot; }<br>kotlinx-coroutines-core = { module = &quot;org.jetbrains.kotlinx:kotlinx-coroutines-core&quot;, version.ref = &quot;coroutines&quot; }<br>kotlinx-coroutines-android = { module = &quot;org.jetbrains.kotlinx:kotlinx-coroutines-android&quot;, version.ref = &quot;coroutines&quot; }<br>kotlinx-coroutines-test = { module = &quot;org.jetbrains.kotlinx:kotlinx-coroutines-test&quot;, version.ref = &quot;coroutines&quot; }<br>napier-logging = { module = &quot;io.github.aakira:napier&quot;, version.ref = &quot;napier&quot; }<br>multiplatform-settings = { module = &quot;com.russhwolf:multiplatform-settings-no-arg&quot;, version.ref = &quot;settings&quot; }<br>apollographql = { module = &quot;com.apollographql.apollo3:apollo-runtime&quot;, version.ref = &quot;apollographql&quot; }<br><br>[plugins]<br>androidApplication = { id = &quot;com.android.application&quot;, version.ref = &quot;agp&quot; }<br>androidLibrary = { id = &quot;com.android.library&quot;, version.ref = &quot;agp&quot; }<br>kotlinAndroid = { id = &quot;org.jetbrains.kotlin.android&quot;, version.ref = &quot;kotlin&quot; }<br>kotlinMultiplatform = { id = &quot;org.jetbrains.kotlin.multiplatform&quot;, version.ref = &quot;kotlin&quot; }<br>skie = { id = &quot;co.touchlab.skie&quot;, version.ref = &quot;skie&quot; }<br>kotlin-serialization = { id = &quot;org.jetbrains.kotlin.plugin.serialization&quot;, version.ref = &quot;kotlin&quot; }<br>compose-compiler = { id = &quot;org.jetbrains.kotlin.plugin.compose&quot;, version.ref = &quot;kotlin&quot; }<br>apollographql = { id = &quot;com.apollographql.apollo3&quot;, version.ref = &quot;apollographql&quot; }</pre><p>還有一個很重要的 SDK 必用 <a href="https://github.com/touchlab/SKIE">SKIE</a></p><ol><li>使用原先 KMM 的 Kotlin enum 會變成 Objective C 的 class，改用 SKIE 後可以產出來 swift 的 enum。另外在 enum 的問題上 SKIE 還有解決 Kotlin 的 sealed class 轉成 Swift enum 的問題，在 Kotlin 中 sealed class 是類似 enum 的存在，但有其限制是 value 只能有一個，但 value 可以是 data class 所以 property 也可以帶多個不影響使用。</li><li>支援 Suspend Functions, Generic Classes, Overriding Suspend Functions</li></ol><p>好處有點太多，就不贅述可以參考直接去參考：<a href="https://skie.touchlab.co/features/">https://skie.touchlab.co/features/</a></p><p>另外在使用上一定會遇到很多型別轉換的問題，可以直接參考：</p><p><a href="https://kotlinlang.org/docs/native-objc-interop.html#mappings">https://kotlinlang.org/docs/native-objc-interop.html#mappings</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5329699ba364" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[從 0 到 1，導入 Tuist 並持續解耦與模組化]]></title>
            <link>https://medium.com/@alexanderpan/%E5%BE%9E-0-%E5%88%B0-1-%E5%B0%87%E6%97%A2%E6%9C%89%E5%B0%88%E6%A1%88%E5%B0%8E%E5%85%A5-tuist-%E4%B8%A6%E6%8C%81%E7%BA%8C%E8%A7%A3%E8%80%A6%E8%88%87%E6%A8%A1%E7%B5%84%E5%8C%96-837ca7a22513?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/837ca7a22513</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[decoupling]]></category>
            <category><![CDATA[tuist]]></category>
            <category><![CDATA[modularization]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Sat, 08 Apr 2023 17:39:38 GMT</pubDate>
            <atom:updated>2025-05-22T09:24:43.204Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*__GDhdsiVDY-xmBkLXpCLw.png" /><figcaption>Tuist</figcaption></figure><p><strong>一、初衷</strong></p><p>在新公司希望找尋一個專案管理工具在模組化的路上更順遂，可以針對以下幾點做優化：</p><ol><li>.xcodeproj 衝突問題，也可以減少一些上傳 .xcworkspace 與 .xcodeproj 到 git repo 的大小。</li><li>在推動模組化的過程中可以有一個好的專案管理工具，方便在每次變動時可以在 git diff 上更容易看出新增、刪除、修改的模組有哪些，在推動模組化的過程中會有大量的解耦工作，在管理上也會比較方便，在各個模組的依賴上也可以使用「人」看的懂的程式碼方便管理。</li><li>隨著專案越來越大，人員變多的狀況下希望在合作上不再使用 Single Module 的方式去開發，在模組化後也可以在開發上也可以大幅縮短 Build 的時間大幅縮短。</li></ol><p><strong>二、分析與選擇</strong></p><figure><img alt="評分表" src="https://cdn-images-1.medium.com/max/1024/1*u6Gj-DwK6dvNWBV4HHa7eg.png" /><figcaption>評分表</figcaption></figure><p>導入時需要考量哪個方案比較適合目前的公司所以針對 Tuist 、Xcodegen、Bazel 優劣，途中也實際使用過一次，分別建立出 Demo 專案和成員討論後最終選擇了 Tuist。</p><p>Git Repo 星數：星數其實都不低，看起來跟出來的時間以有差異，以及使用上的廣泛程度，像 Bazel 使用場景就很廣泛不一定只有 iOS 開發者會使用，Andriod, C++, Java, Go … 都可以使用它來管理。</p><p>文件友善程度：Xcodegen、Tuist 文件放置都很集中且好找。Bazel 的則是散落各地，文件撰寫風格也都不太一樣，每個 Git Repo 都有不同的風格，放置位置都需要花滿多找的。</p><p>新手上手速度與維護成本：如果考量新手上手速度的面向看 Tuist 本身就是 Swift 也是用 Xcode 開發，對新手來說上手速度自然也會比較快，不需要再重新學習一個新的語法，也可以用比較低的維護時間成本。</p><p><strong>三、實作</strong></p><p>需要做的事情非常多但大致分為以下階段：調整資料夾結構、刪除 xcodeproj 與 xcworkspace 使用 Tuist 管理、將 CocoaPods 轉移至 SPM、CI/CD 調整、持續解耦並模組化</p><ol><li>調整資料夾結構：因為過往的 Module 或 Target 資料夾都是直接攤平並沒有做整理，所以改為第一層只會有 entitlements、Info.plist、Resources、Sources、Tests，先調整的原因是因為到時候在寫Project.swift 時可以減少撰寫路徑的程式碼會非常的乾淨，因為設定 Project.swift 需要針對 Target 設定 Resources、Sources 去設定路徑。其中 Resources 中包含 i18n、Assets、各類非程式碼檔案。Sources 則是 Module 程式碼，Tests 與 UITests 是各類測試。</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*44vNxgg8C2TnYG28C-sNmQ.png" /></figure><p>2. 刪除 xcodeproj 與 xcworkspace 使用 Tuist 管理：</p><p>接下就要進行最困難的部分要將 xcodeproj 與 xcworkspace 刪除並且使用 Tuist 來做管理，大致上會遇到以下問題（遇到的問題與細節非常多，這邊只是大概描述有遇到哪些比較麻煩的問題）：</p><p><strong>超重要補充：因為每間公司專案複雜程度都不太一樣，遇到的狀況也不太一樣，所以語法上使用上有不知道的可以先到這邊去翻翻看，有各式各樣的範例可以參考，這個些範例可以使你大大加快理解 Tuist 的設定方式！附上</strong><a href="https://github.com/tuist/tuist/tree/main/projects/tuist/fixtures"><strong>範例連結</strong></a><strong>，使用上如果需要下載可以透過 </strong><a href="https://chrome.google.com/webstore/detail/gitzip-for-github/ffabmkklhbepgcgfonabamgnfafbdlkn?hl=en"><strong>GitZip for github</strong></a><strong> 下載範例</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6JuHCCxpGwCP1mq0L3-4EQ.png" /><figcaption>超多實用的範例</figcaption></figure><p>(1) 主要使用 Project.swift、Workspace.swift、Dependencies.swift、Config.swift、.xcconfig 去設定專案結構。而在設定上述檔案時需要使用 <a href="https://docs.tuist.io/commands/edit">tuist edit</a> 開起來 Xcode 方便編輯在撰寫時也需要考量擴充性可以寫出 extension/enum/class/struct … 在 ProjectDescriptionHelpers 中方便所有檔案使用。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*ppE9NEIqCWxiH7N63foGHQ.png" /></figure><p>(2) 需要將所有 Build Settings 轉移成 Tuist 的管理方式，而 Tuist 有一個 command line tool 一定要使用會大大加快你的進度！就是 <a href="https://docs.tuist.io/commands/migration">tuist migration</a> 將所有 Build Settings 轉換成 .xcconfig 後你可以比較輕鬆的分辨出 .xcconfig 中可以需要寫在 Project.swift 中避免有遺漏，這邊需要注意的是通常都會有 Release、Staging、Debug 環境設定時需要注意沒有遺漏，至於要使用 xcconfig 還是寫在 Project.swift 或 Workspace.swift 可以自行取捨，其實都可以達到一樣的效果。</p><p>在設定 Build Settings 時有不知道的 key value 可以到這邊翻<a href="https://developer.apple.com/documentation/xcode/build-settings-reference?changes=_9">官方文件</a>。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*e7Fc0uloE3_RpDtzL8B1rQ.png" /></figure><p>(3) Profiles &amp; Certificates 這塊也稍微比較麻煩一點，因為需要放在指定路徑下以及指定名稱。 Profiles 的部分需要將名稱稍做修改，格式為 <a href="https://docs.tuist.io/commands/signing">Target.Configuration.mobileprovision</a> ，因此需要使用到 fastlane 的<a href="https://docs.fastlane.tools/actions/get_provisioning_profile/">get_provisioning_profile</a> 即可達成我需要的目的，可以針對我需要的 profile 修改成相對應的名稱。接下如果是 Certificates 使用 fastlane 的 <a href="https://docs.fastlane.tools/actions/match/">match</a> 即可。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*DLs1Hf2GhH3nY3Vwop4oew.png" /></figure><p>(4) 轉移 Build Phases 至 Project.swift</p><p>(5) 保留 Info.plist 提供 Project.swift</p><p>3. 將 CocoaPods 轉移至 SPM：</p><p>雖然 Tuist 其實提供 CocoaPods ＆ SPM ＆ Carthage 同時並存，如果沒有轉移到 SPM 或 Carthage 就沒辦法完整享用到 <a href="https://docs.tuist.io/building-at-scale/caching/">Caching</a> 的功能，目前公司的專案都是使用 CocoaPods 所以這邊將有辦法轉移的套件都轉移到 SPM ，畢竟 SPM 也是 Apple 爸爸出的，先轉移過去疑慮相對來說就比較少。可惜的是有一些問題依賴沒辦法一次性的將所有 CocoaPods 轉移至 SPM，但往後是可以達到的！轉移完之後就可以開心的使用 <a href="https://docs.tuist.io/building-at-scale/caching/#warming-the-cache">tuist cache warm</a> 與 <a href="https://docs.tuist.io/commands/dependencies/">tuist fetch</a> 再透過 <a href="https://docs.tuist.io/commands/generate">tuist generate</a> 與 pod install 將專案產生出來了</p><p><em>額外小補充：tuist cache warm — xcframeworks 與 tuist generate -n — xcframeworks ，在加上 — xcframeworks 後可以同時支援模擬器與實機。</em></p><p>4. CI/CD 調整：因為目前公司是使用 Macbook 自建 TeamCity 來跑 CI/CD，調整完上面的部分後，需要再來全盤確認有沒有問題。</p><p>做完上述繁雜的工作後大約 Git Repo 減少了約一萬行！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*TCARUDiHwZvBqoJR18AqSg.png" /><figcaption>刪除 xcodeproj 與 xcworkspace 減少的行數</figcaption></figure><p>5. 可以設定 <a href="https://docs.tuist.io/guides/version-management">.tuist-version</a> 方便讓團隊成員都使用同一個 Tuist 版本進行開發。</p><p>6. 持續解耦並模組化：</p><p>對於一個 Single Target App，模組化是一個漫長且持久的過程，但慢慢做之後對專案的健康程度與耦合度會大幅轉好。在模組化後可以慢慢提高開發時專案 Build 的時間（接下來將持續探索這塊更深入優化），這項投資在未來將會慢慢的收成。</p><p><strong>額外補充：針對 static framework vs dynamic framework 到底該選什麼，以及有什麼差異，推薦</strong><a href="https://www.jianshu.com/p/e414032f5671"><strong>這篇文章</strong></a><strong>，看完之後可以功力大增。</strong></p><p>在 Tuist 有支援一個功能是 graph 轉換的過程中，可以使用看到 <a href="https://docs.tuist.io/commands/graph">tuist graph command line</a> 看到漂亮的結構圖（如下示意圖）。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*FdeotZ0aK0PS7HE5boevWQ.png" /><figcaption>專案結構示意圖</figcaption></figure><p>總結：這篇文章其實沒有講的非常詳細一步一步講解，只有大概依照實作步驟描述一下我覺得較為困難與複雜的部分（因為實際做起來每個專案遇到的狀況應該會大不相同ＸＤ），在做完轉移到 Tuist 後可以讓我更大幅提升對新公司專案結構的了解很有幫助。以及自己本身對模組化也很有興趣，所以希望透過這樣的專案管理工具對後續解耦模組化的過程中更加順利。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=837ca7a22513" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[發票存摺 iOS App 2020開發點滴]]></title>
            <link>https://medium.com/@alexanderpan/%E7%99%BC%E7%A5%A8%E5%AD%98%E6%91%BA-ios-app-2020%E9%96%8B%E7%99%BC%E9%BB%9E%E6%BB%B4-4f559721c3a3?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f559721c3a3</guid>
            <category><![CDATA[app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Thu, 08 Oct 2020 10:56:49 GMT</pubDate>
            <atom:updated>2020-10-08T11:38:30.975Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5vFV2HN674BPsa0PzGTsyQ.png" /></figure><h3>關於</h3><p>發票存摺 iOS App，產品自 2017/9 年上線以來也來到了第三年，保持著4.8顆星（超過13萬評分），且雙系統總下載量也突破 400 萬，要保持快速的開發步調同時兼具高品質的實在不容易，今年也有夥伴加入太 Cool 了，接下來聊聊今年專案做了哪些小改變吧～也希望這些改變能讓未來合作更加順暢！<br>P.S. 還沒有經歷過多人合作的環境，接下來陸陸續續一定會遇到各種問題，就各個突破吧！</p><h3>1.CI/CD</h3><p>自從去年開始導入 CI/CD（circleci） 真的對開發幫助很大，從穩定度來說每次上版前都一定會跑到 Unit Test 增加穩定度，以及終於可以不用在 Local 上傳 IPA，再加上今年公司導入 ISO 27001 有一些例行工作要做（例如：使用 <a href="https://github.com/MobSF/Mobile-Security-Framework-MobSF"><em>MobSF</em></a> 掃描 IPA 並自動將報告儲存到 Google Doc），都可以自動化處理，近期 Fastlane 終於支援 API Key 上傳 IPA了，前兩天也搞定了，環境變數終於不用設定 Apple ID了（<a href="https://docs.fastlane.tools/app-store-connect-api/#app-store-connect-api"><em>appstore-connect-api</em></a><em>）</em>！ 🎉🎉🎉🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*7uIR9buy9Vp57_HCVzhQBA.png" /><figcaption>還是有些小問題需要修復ＱＱ</figcaption></figure><h3>2.Unit Test &amp; UI Test</h3><p>目前專案使用 MVVM+RxSwift , Unit Test &amp; UI Test 總體涵蓋率突破了新高來到了<strong>76.2%</strong>！🎉🎉🎉🎉<br>就繼續堅持下去吧！<br>小抱怨：最近 Xcode12 跑 UI Test 常常卡住或是怪怪的問題（<a href="https://developer.apple.com/forums/thread/658350">issue</a>）</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AoCswh9FFk_sj1jhrecLqw.png" /></figure><h3>3.Objective C 轉換 Swift</h3><p>目前專案 Objective C vs Swift 比例來到新低：2成 vs 8成</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VO3nUmHBn6vRkXS2FgGh8w.png" /></figure><h3>4.Push Notification Example 總整理</h3><p>整理了 App 內所有的推播格式檔案：方便測試 ＆ 當作文件</p><pre>{<br> “Simulator Target Bundle”: “xxxx.xxxx.xxxx”,<br> “aps”: {<br> “alert”: “Push Notifications Test”,<br> “sound”: “default”,<br> “badge”: 0<br> },</pre><pre>}</pre><h3>5.Firebase Dynamic Link, Deep Link Example 總整理</h3><p>整理了 App 內所有的 Firebase Dynamic Link, Deep Link，方便測試 ＆ 當作文件。</p><pre>#!/bin/bash</pre><pre>read -p “Press enter to continue”<br>xcrun simctl openurl booted “Dynamic Link&quot;</pre><h3>6.iOS 14 Widget</h3><p>因為被其他案子卡住 ＆ 解決 Xcode12 的問題，再加上是第一次接觸 SwiftUI，讓這次開發 Widget 真的非常趕 🤢！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*J1hhOpYp034tatFO66IcMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*uEZ1f5piDrxaXkQQTUNKUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*ImFtuoVZYTllTakurqXYtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*5OfTw_uxodhEd8hjkc901g.png" /></figure><h3>7.文件</h3><p>文件補齊：git commit style、coding style、DB結構、開發環境配置…。相信接下來會陸陸續續加上更多。</p><h3>8.踩坑</h3><p>Realm:果斷放棄 Realm一坨的 Xcode12<em> </em><a href="https://github.com/realm/realm-cocoa/issues?page=1&amp;q=xcode+12+is%3Aopen"><em>issue</em></a></p><p>IGListKit:原來坑這麼大 <a href="https://medium.com/r?url=https%3A%2F%2Fgithub.com%2FInstagram%2FIGListKit%2Fissues%2F516"><em>issue</em></a></p><h3>未來要做的事情：</h3><ol><li><strong>Pod 轉移 SPM。先</strong>前專案是 Pod+Carthage 混用，但 Carthage 在這次 Xcode12 的改版下出現了滿多問題的，已經先全數轉為使用 Pod，看來 SPM 已經是趨勢了：<a href="https://github.com/Carthage/Carthage/issues/3019#issuecomment-693324360"><em> issues連結</em></a></li><li><strong>SPM CI cache：</strong><a href="https://medium.com/uptech-team/swift-package-manager-and-how-to-cache-it-with-ci-14968cd58c5f"><strong><em>參考連結</em></strong></a></li><li>導入 <strong>Code review</strong></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f559721c3a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS Build 加速x2｜CocoaPods 轉移 Carthage]]></title>
            <link>https://medium.com/@alexanderpan/ios-build-%E5%8A%A0%E9%80%9Fx2-cocoapods-%E8%BD%89%E7%A7%BB-carthage-de3f2526d5ae?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/de3f2526d5ae</guid>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[carthage]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[build]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 07:56:56 GMT</pubDate>
            <atom:updated>2019-11-15T01:10:54.194Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zmSday3mMD1or8qKiVcTAg.png" /></figure><h3>前言</h3><p>首先先講一下為什麼這次會把專案 Library 從 CocoaPods 轉移到 Carthage。目前專案 CICD 的部分是使用 CircleCI ，目前 CircleCI 的收費是採月費制，但將來會改為依照 Build 的時間收費。</p><p>所以這次優化的目的除了可以幫公司<strong>省錢</strong>之外，也可以讓平常開發的時間加速，<strong>減少每一次等待 Build 的時間</strong>，再加上我平常開發都沒有在用 storyboard 或是 xib 更需要加速 Build 的時間來看畫面是不是正常。</p><h3>優化項目</h3><p>接下來附上這次轉移到 Carthage 的 Library 總共 26 個。</p><pre>github “Alamofire/Alamofire”<br>github “AliSoftware/Reusable”<br>github “CocoaLumberjack/CocoaLumberjack”<br>github “Flipboard/FLAnimatedImage”<br>github “Juanpe/SkeletonView”<br>github “ReactiveCocoa/ReactiveObjC”<br>github “ReactiveX/RxSwift”<br>github “SDWebImage/SDWebImage”<br>github “SVGKit/SVGKit”<br>github “SVProgressHUD/SVProgressHUD”<br>github “SnapKit/Masonry”<br>github “SnapKit/SnapKit”<br>github “SwiftyJSON/SwiftyJSON”<br>github “TheLevelUp/ZXingObjC”<br>github “ZipArchive/ZipArchive”<br>github “airbnb/lottie-ios” <br>github “cbpowell/MarqueeLabel”<br>github “ccgus/fmdb”<br>github “danielgindi/Charts”<br>github “hackiftekhar/IQKeyboardManager”<br>github “mikebuss/MTBBarcodeScanner”<br>github “onevcat/Kingfisher”<br>github “realm/realm-cocoa”<br>github “rechsteiner/Parchment”<br>github “ruslanskorb/RSKImageCropper”</pre><h3>成果</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ubU8Zagb7_-JWwNS7q8kLg.png" /><figcaption>develop branch — 單元測試 + Build 時間變化</figcaption></figure><p>從上圖可以看到優化前每次時間約 <strong>25–30 分鐘</strong>，優化後約<strong>12–13分鐘，</strong>Build的時間真的差非常多！直接砍半！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPieQlKgbZN-8mvdbV5Xbw.png" /><figcaption>master branch — 打包 + 上傳到 TestFlight 時間變化圖</figcaption></figure><p>不過打包&amp;上傳到 TestFlight 就沒有太大的變化了。</p><h3>結論</h3><p>這次 Build 加速的優化 CocoaPods 轉移至 Carthage，過程雖然麻煩，但成效非常好，覺得開心（灑花）。再這次優化前也參考過這篇文章：<a href="https://medium.com/@joshgare/8-tips-to-speed-up-your-swift-build-and-compile-times-in-xcode-73081e1d84ba"><em>8 tips to speed up your Swift build and compile times in Xcode</em></a>，除了第六項 CocoaPods 轉移 Carthage 沒做之外，其他能做的都做了，但 Build 的時間都沒有太大的變化。因為轉移這件事情影響範圍比較大所以擺在最後一項來做優化。不過轉移到 Carthage 也有缺點，可能會造成 App <a href="https://www.jianshu.com/p/3263009e9228"><strong><em>啟動緩慢</em></strong></a><strong>，</strong>因為是 dynamic framework，這個缺點就要看各個專案的狀況來評估了，我自己實測還感受不到 App 啟動時間太久，也需要觀察一段時間。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de3f2526d5ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[iOS 自己的CI/CD自己架 CircleCI + Fastlane vs AppCenter]]></title>
            <link>https://medium.com/@alexanderpan/ios-%E8%87%AA%E5%B7%B1%E7%9A%84ci-cd%E8%87%AA%E5%B7%B1%E6%9E%B6-circleci-fastlane-vs-appcenter-cef34e63868f?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cef34e63868f</guid>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[appcenter]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[circleci]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Sat, 08 Jun 2019 09:19:20 GMT</pubDate>
            <atom:updated>2019-06-08T09:48:36.303Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sqw5kYeALLC7TXQHYCMXhw.png" /><figcaption>測試 Pass !</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2h_MBGftCrtrFvWzcy6q9Q.png" /><figcaption>上傳至 <a href="https://www.google.com/search?q=Testflight&amp;spell=1&amp;sa=X&amp;ved=0ahUKEwiZ6uCTw9niAhWMV7wKHR6hC10QkeECCCsoAA">Testflight</a> 成功！</figcaption></figure><p>隨著時間的推進，iOS App 「發票存摺」的專案中的測試數量漸漸變多，每當上版前都要在 Local 端跑一次，Build、Unit Test、UI Test、Archive、Upload，算下來起碼也要一個小時以上，不想每次都經歷這樣漫長的等待，於是就挽起了袖子再架一次 CI/CD。</p><p>一年多前曾經有使用 Bitbucket pipeline + Jenkins +Fastlane＋Mac mini 在其中專案中架過一次，但使用一段時間後覺得維護成本太大，常常遇到 Xcode更新、系統更新、網路出問題、不小心踢到線 Mac mini 關機總之各種狀況，每次修浪費更多時間。</p><p>所以想嘗試測試看其他方案這次花了大約兩個禮拜零碎的時間研究了 <a href="https://circleci.com/">CircleCI</a> 和 <a href="https://docs.microsoft.com/en-us/appcenter/build/ios/">AppCenter</a>，<strong>最後選擇了 CircleCI 也成功完成</strong>。</p><p>這篇文章不會講述過程是怎麼實作，會花一些時間講解為什麼最後選擇了 CircleCI。</p><p>首先來講講 AppCenter 設置的部分</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJBCkQSHcpCtrcqVZ_IO9w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9UIwkMRzJCSwLVaVFUlog.png" /><figcaption>App Center 針對 Branch 的設定</figcaption></figure><p>AppCenter 設定的方式主要是透過設定單一 Branch 綁定專案的 Scheme ，專案中 Scheme 設置來實現測試＋發布，單一的Branch也只能上傳單一種的 Certificates、Provisioning Profiles，而免費額度的單次 Build 上限時間為30分鐘、付費後最多可提升至60分鐘。</p><p>接下來就我們的專案來說說他的優劣吧…</p><ol><li>就我們目前專案來說 Build + UI Tests + Unit Tests 就需要約 40 分鐘，Archive＋Upload也需要大約30分鐘，而這也只是現在未來可能會更久，時間上的問題對我來說是的大問題。</li><li>免費的測試額度沒辦法讓我測好完整的情境給公司提案，單次Build 30分鐘實在不夠用。</li><li>事件觸發只能綁定單一Branch設定 Scheme、Certificates、Provisioning Profiles 這件事情，讓我覺得彈性太小(雖然有其他種方式可以繞過去但非常麻煩)，假設未來想要每個Feature/*的Branch都觸發特定的事件怎麼辦QQ？</li><li>但撇除上述的缺點，Build 的時間無上限這件事情滿棒的！</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Wj-0bPxm5b5SPjFiev5AA.png" /></figure><p>相對來說 CircleCI 彈性就大多了 ，不論從透過設定 <strong>config.yml</strong> 中的 Branch、Job、Workflow、專案中的Scheme、Fastlane 的 Fastfile、去改變流程都非常容易。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MoyB8CCqFioQ0cagyEkb9g.png" /><figcaption>計費方案表</figcaption></figure><p>CircleCI 在對macOS首次測試的額度也給得相當大方，前兩個禮拜可以享有249/mo的方案的額度，測試起來也不會綁手綁腳！</p><p>這次架CI/CD的過程中也是困難重重～</p><ol><li>Apple ID 兩階段驗證</li><li>透過 Match 管理 Certificates、Provisioning Profiles</li><li>重新熟悉一次Fastlane用法</li><li>CircleCI 設置</li><li>規劃CI/CD流程（掙扎了很久呢）</li></ol><p>還有很多不過細節就不多講了…XD</p><p>結論：</p><p>如果是小專案來說其實 AppCenter 非常適合，Total build time 無上限、單次 Build 30mins，簡單的幾步設定很快就可以完成。</p><p>但如果對已經有一定規模的專案中要使用 AppCenter 可以說是綁手綁腳，各種限制。所以最後才選擇了彈性較大的 CircleCI。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cef34e63868f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxSwift UnitTest x UITest]]></title>
            <link>https://medium.com/@alexanderpan/rxswift-unittest-x-uitest-941725c90d35?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/941725c90d35</guid>
            <category><![CDATA[ui測試]]></category>
            <category><![CDATA[uitest]]></category>
            <category><![CDATA[unittest]]></category>
            <category><![CDATA[rxswift]]></category>
            <category><![CDATA[單元測試]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Fri, 26 Apr 2019 15:41:31 GMT</pubDate>
            <atom:updated>2019-04-27T02:56:49.153Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*tRhAkkCmC0NdPqMniFQZOA.png" /><figcaption>新的 Launch Screen …</figcaption></figure><p>終於在 2019 年二月份鼓起勇氣開始將 「<strong>發票存摺</strong>」 iOS App 開始了脫胎換骨的混編旅程 …</p><p>1.Objective-C → Swift</p><p>2.Reactive Cocoa → RxSwift</p><p>3.AFNetworking → Alamofire</p><p>4.Masonry →SnapKit</p><p>5.SDWebImage → Kingfisher</p><p>但 … 發現原本 Reactive Cocoa ＋ OCMock 的測試方法已經不管用了<br>那就好好來設計架構吧！讓每一段 Code 都可以測好測滿！</p><p>記錄一下目前的里程碑</p><p>單元測試 Test Case：<strong>914個</strong>（跑完約2分鐘）</p><p>UI測試 Test Case：<strong>49個</strong>（跑完約16分鐘）</p><p>接下來寫了一個簡單的 Demo 來講解一下我是怎麼撰寫 UITest 及 UnitTest</p><p>先在這邊附上Github連結：<a href="https://github.com/AlexanderPan/AlexanderTestsDemo?fbclid=IwAR0FYboqXBEBvztGxjOZI0V1f-truga8oymYhocmD1WPeMXmMeAfjHaHndU">https://github.com/AlexanderPan/AlexanderTestsDemo?fbclid=IwAR0FYboqXBEBvztGxjOZI0V1f-truga8oymYhocmD1WPeMXmMeAfjHaHndU</a></p><p>壹、架構設計</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6r_Ft5oCa_mzVRm91hLkww.png" /><figcaption>依賴注入</figcaption></figure><p>目前專案架構使用 MVVM + Repository Pattern 透過 Dependency injection 的方式來解偶，使 ViewModel 及 Repository 更容易撰寫單元測試。也更容易做到 <strong>Function 的複用</strong>，假設Ａ、Ｂ兩個畫面同時需要透過 ViewModel 來呼叫同一隻 API 邏輯也相同，可以直接把 ViewModel 中的 Function 移至 Repository 就可以輕鬆地讓兩個 ViewModel 共享同一個 Function ，單元測試也只需要複製貼上，輕鬆搞定！</p><p>貳、單元測試</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-r0x9p0Cn0gEZbf2culMxQ.png" /><figcaption>單元測試程式碼</figcaption></figure><p>簡單的兩步驟～</p><p>第一步：將要餵的假資料的 Repository 的實作傳入給 ViewModel</p><p>第二步：驗證邏輯是否正確</p><p>參、UI測試</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLbfZTL0uNdP9kOympvI6w.png" /></figure><p>因為 iOS UI 測試的限制只能夠透過 LaunchEnvironment、LaunchArguments 傳遞字串來傳給 Product，所以我想了一個流程方便喂資料給 Product。</p><p>我要怎麼喂假資料給UI測試呢？</p><p>第一步：先在 UI 測試寫出假資料的格式 Array&lt;Dictionary&gt;/Dictionary</p><p>第二步：將 Array&lt;Dictionary&gt;/Dictionary 轉成 Data</p><p>第三步：將 Data 轉成 String</p><p>第四步：透過 LaunchEnvironment 傳給 Product</p><p>（Key: Repository 需要假資料的 Function Name Value:剛剛轉好的String）</p><p>第五步：在 Repository 中每個 Function 檢查是否有假資料喂給我，透過 Key來檢查，如果有接著往第六步</p><p>第六步：String 轉成 Data</p><p>第七步：透過 JSONDecoder 將 Data 轉為 Model</p><p>附上片段的程式碼：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rya5FONG0vTbTz4TQqXRbg.png" /><figcaption>UI 測試片段程式碼</figcaption></figure><ol><li>塞入假資料</li><li>驗證畫面是否正常顯示</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1G5qdGmPU34ZgFniCkx41g.png" /><figcaption>Repository 片段程式碼</figcaption></figure><ol><li>透過設定 Active Compilation Conditions 來判斷是否需要檢查有資料從UI測試送來</li><li>如果有 Key 跟 Function Name 一樣就將 Value 取出轉為 Data 並放入 JSONDecoder 轉為 Model 往下丟</li></ol><p>心得：</p><ol><li>UI 測試沒辦法 Assert Color 好討厭啊！</li><li>[UIView setAnimationsEnabled:NO]; 因為這行 UITest跑的快多了（感謝 iOS Taipei 的大大提供的意見）</li><li>OC 轉 Swift 真的不痛但需要時間熟悉一下語法就是了</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=941725c90d35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[漫長的單元測試之路…涵蓋率45.5%!]]></title>
            <link>https://medium.com/@alexanderpan/%E6%BC%AB%E9%95%B7%E7%9A%84%E5%96%AE%E5%85%83%E6%B8%AC%E8%A9%A6%E4%B9%8B%E8%B7%AF-%E6%B6%B5%E8%93%8B%E7%8E%8745-5-6e2493be0bcf?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e2493be0bcf</guid>
            <category><![CDATA[objective-c]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Tue, 22 Jan 2019 16:53:19 GMT</pubDate>
            <atom:updated>2019-01-22T16:53:19.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C2QZ_N7_ZQFDKgiv.jpg" /></figure><p>距離上寫了「<a href="https://medium.com/@alexanderpan/%E8%8F%9C%E9%B3%A5%E5%B7%A5%E7%A8%8B%E5%B8%AB%E7%9A%8410%E5%80%8B%E6%9C%88%E7%99%BE%E8%90%AC%E4%B8%8B%E8%BC%89app%E9%96%8B%E7%99%BC%E5%BF%83%E5%BE%97-cb8172958713"> <strong>菜鳥工程師的10個月百萬下載App開發心得</strong></a>」的文章，時光飛逝很快的又過了半年。</p><p>這邊想整理一下，我最近寫的單元測試的方式及心得。</p><p>最近半年用了零碎的開發時間，漸漸的將單元測試補上。終於 「<strong>單元測試涵蓋率45.5%</strong>」 以及 「<strong>Test Case 680個</strong>」，整個很感動！因為整個專案使用 ReactiveCocoa + MVVM 的架構進行開發，再搭配上 <a href="http://ocmock.org/"><strong>OCMock</strong></a> 測試變得相當容易，但測試的路上也不是這麼的順遂，開始寫單元測試後才發現之前的一些設計跟寫法會讓程式非常的難測，很多頁面也經歷了不少改動才測的動啊（好痛r）！</p><p>這邊來講解我大概寫了哪些測試吧：</p><ol><li>發票對獎：後三碼對獎，掃描對獎，整個APP最不能出錯的部分優先補上測試！</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h76t5TGeon93oUkY" /><figcaption><strong>圖.1</strong></figcaption></figure><p>2.ViewController 畫面測試（非UI測試）：這邊只測例如：Label、Button顯示文案或狀態（從 ViewModel 打給 ViewController 假資料以便測試），如<strong>圖.1</strong>所示。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_t31wExFmt1KExnk" /><figcaption><strong>圖.2</strong></figcaption></figure><p>3.ViewModel API or DB 測試：透過 OCMock 可以輕易的模擬 API 或 DB 回傳的假資料，因此可以輕鬆的測試各個頁面主要邏輯，如<strong>圖.2</strong>所示。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YAjvdydGs7uravkb" /><figcaption><strong>圖.3</strong></figcaption></figure><p>4.DB 的升級測試：例如：v1 -&gt; v2 新增了三個欄位，驗證升級後是否正確新增欄位，如<strong>圖.3</strong>所示。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hX9e0hH9SedVq9Jz5-K6mQ.png" /><figcaption><strong>圖.4</strong></figcaption></figure><p>5.主題包測試：為什麼會優先挑選這個作為測試項目之一呢？因為如果下載了一個壞掉的主題包，使用者套用了！後果不堪設想…。這個測試寫完很有成就感！怎麼測呢？（示意圖:如<strong>圖.4</strong>）</p><p>1 -&gt; 在測試路徑放了一個主題包</p><p>2 -&gt; 透過刪除或修改某些檔案</p><p>3 -&gt; 再由原本的 Function 進行測試是否符合我的預期。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Pn7NixIIrqu_cESx" /><figcaption><strong>圖.5</strong></figcaption></figure><p>6.推播測試：模擬收到推播時，驗證正確導至相對應的頁面，如<strong>圖.5</strong>所示。</p><p>7.各類工具測試</p><p>經過這幾個月的寫測試，才知道我之前寫的 Code 是多爛不能測，哈哈哈！（又進步了一點了呢），又可以朝下一個目標前進了！CI/CD 嘿嘿！</p><p>雖然內心有悸動想轉Swift？！…但還是先寫好測試再說吧！考慮到現在產品使用者非常多先把產品穩定顧好再說！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*Sb6TYdu08b81h7WElRbItQ.png" /></figure><p>APP名稱：統一發票對獎機+雲端發票存摺</p><p>iOS : <a href="https://goo.gl/EyQX4B">https://goo.gl/EyQX4B</a><br>Android : <a href="https://goo.gl/P4i7Sb">https://goo.gl/P4i7Sb</a></p><p>這邊還是要偷偷打一下廣告 哈哈哈！<br>來支持一下我們吧！也可以給我們意見喔！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e2493be0bcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[菜鳥工程師的10個月百萬下載App開發心得]]></title>
            <link>https://medium.com/@alexanderpan/%E8%8F%9C%E9%B3%A5%E5%B7%A5%E7%A8%8B%E5%B8%AB%E7%9A%8410%E5%80%8B%E6%9C%88%E7%99%BE%E8%90%AC%E4%B8%8B%E8%BC%89app%E9%96%8B%E7%99%BC%E5%BF%83%E5%BE%97-cb8172958713?source=rss-389d66d46ea5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb8172958713</guid>
            <category><![CDATA[統一發票對獎機]]></category>
            <category><![CDATA[雲端發票存摺]]></category>
            <category><![CDATA[工程師]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Alexander Pan]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 03:11:02 GMT</pubDate>
            <atom:updated>2018-07-31T03:14:17.118Z</atom:updated>
            <content:encoded><![CDATA[<p>小小菜鳥工程師在2017年8月份收到公司的開發計畫：開發發票 App 以Scrum 進行專案開發。</p><p>主要成員為 ：</p><ol><li>Product Owner</li><li>PM</li><li>後端</li><li>設計</li><li>iOS &amp; Android 工程師(就是我)</li><li>系統工程師</li><li>行銷</li></ol><p>第一版主要功能：掃描對獎、後三碼對獎、發票紀錄、中獎號碼，而給使用者的感受目標設定是掃得凖、掃得快和流暢的使用體驗。準備搶在兩個禮拜後的2017/9/25號開獎前上線。</p><p>附上初版設計圖：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/0*FdUBi34WGAejpfuN" /><figcaption>掃描發票記錄頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/0*Tm-NeKqmw51Yb1B_" /><figcaption>掃描頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*srFnqZ3Gs1abOkHh" /><figcaption>後三碼對獎頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*qUwknogRmMz54q7GjEsIxQ.png" /><figcaption>中獎號碼頁</figcaption></figure><p>雙版本預計開獎後，目標『一個月1萬』的下載量，在公司投入行銷資源和PM與行銷的努力下，沒想到短短幾天就已突破。兩個月後，下載量高達10萬，使用者的反饋完全符合當初的設定。<br>當然，一切不是如此順遂，特別是Android版本，因手機種類太多，測試了十幾支手機還是有些手機使用上會有問題。還有些手機太舊導致使用掃描和對焦的速度太慢而產生負評。<br>開獎後，更發現對獎邏輯有點小問題， 某些特殊狀況的號碼會被誤判為中獎，趕緊在數小時內緊急修正並上架，止住負評。</p><p>緊接著10、11月主要開發『會員系統』，並串接財政部的 API。財政部的電子發票及載具非常複雜，但團隊極力想優化這部分，因為我們非常確定這是使用者的一個痛點。大部分的使用者都很難理解載具，只有優化申請流程，才能讓使用者簡單快速理解。整個團隊，從進入開發並發現問題接著討論並解決（因為 PM 開來的文件不可能一次到位，畢竟工程師也不可能寫出沒有 Bug 的程式），經多次的會議後，產出註冊及登入會員既流暢又簡單的載具功能。</p><p>然而驗證這次開發的好壞，最好的方式就是上架，並收集使用者的回饋。經歷過數次的改版優化，最後成果很快反映在會員數量並直線上升。</p><p>附上這次改版的幾張設計稿：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*YuyPqxPOzLUHA4zv" /><figcaption>會員頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*OOBSluNPNIWgOmdR" /><figcaption>登入頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*0qXa_svgAxR8_vfH" /><figcaption>會員驗證手機號碼頁</figcaption></figure><p>每個公司都有自己獨有的 Scrum 的運作方式，下方的圖表我們運作方式。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*81GvgTXV3iNPuiVm4D732A.png" /><figcaption>Scrum運作圖</figcaption></figure><p>我們的 Scrum 每個 Sprint 預計兩個禮拜，因此一個月雙版本需要推出一次新的改版或優化，在如此快速的開發中難免會有技術債，再加上又是一位菜鳥工程師…。如果不及早治療，嚴重將造成難以維護、疊加新功能困難，將付出很高的代價來償還。</p><p>手邊除了發票App ( iOS &amp; Android )的專案外，還有新的專案需要開發，所以有點分身乏術&gt;&lt;！終於在2017年12月跟新進同事(資深Android工程師)，一起將整個專案轉換成使用 MVVM 的架構進行開發，率先用於改善整個專案的主要的頁面及核心，在改善的過程中因為我熟悉兩個系統，因此可以與較資深 Android 工程師討論一起改善目前的專案，在這一段時間內進步了非常多，並在短短兩個月內了解及熟悉下方這些Library（當然也踩了不少坑呀）。</p><p>主要使用：</p><p>Android(Java)：Rxjava、Gson、Retrofit、ButterKnife、ViewModel、LiveData、SQLite to Room。</p><p>iOS(Objective C)：AFNetworking、FMDB、Masonry、Realm、ReactiveCocoa，整個專案堅持 Code 寫 View！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DnzOZU8Klh8nPR2q" /><figcaption>簡單的架構圖</figcaption></figure><p>2018年1月又快到了開獎的時刻了，因為整個 App 經歷過一次脫胎換骨，難免會出問題呀！不論我們已經測過了無數次了，上線後依然發現問題，又花了一個禮拜解決陸續發現問題，並搶在開獎前修復完畢。</p><p>到了2018年2月準備過好年！但 iOS 發生一個問題，閃退率大幅飆升！但一直找不到問題啊！在過年的凌晨我跟 PM 內心焦急的想盡快找出問題，終於經歷過幾小時的努力找到蛛絲馬跡並解決，火速送審（手殘沒宣告好ＱoＱ）。</p><p>很感謝有團隊中不論任何人出問題，都不會找「戰犯」因為誰不會犯錯呢…？只需要找到問題趕緊解決！</p><p>2018年3~6月根據使用者的反饋，持續開發出各項功能：</p><ol><li>載具條碼 Widget</li><li>會員卡系統及 Widget：雙系統完成整整花了四週，因為不論是 iOS 或是 Android 的 UI 的複雜度非常高，再加上 Android 的 Widget 一堆坑要踩。緊接著在大量使用者反饋下，也花了約兩個禮拜些時間加上會員卡拍照功能及排序功能，這兩個需求只是冰山一角，只能先挑出最需要的先做呀 &gt;&lt;！</li><li>載具條碼 Apple Watch：身為 iOS 工程師一定要寫寫看啊！</li><li>指紋、臉部識別認證：約花了一週時間完成，Android 及 iOS 幾乎同步推出（感謝 Android 工程師的幫忙順利推出）！</li><li>Launch Screen：讓使用者更容易記得我們的 App，知道我們有用『心』做。</li><li>期間也持續優化系統，也持續將單元測試補上，為了確保所有 User 對獎邏輯絕不出現問題！希望可以將對獎邏輯部分全部補齊！</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*VB15dlqzp5dINL5W" /><figcaption>會員卡條碼＆載具條碼 Widget</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*G6ViMMc0pREwanVV" /><figcaption>會員卡頁面</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*WWqTruEJQeAyY2i4" /><figcaption>美美的 Launch Screen</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/1*h7Wy35Y2iErP1ltI01-QFQ.png" /><figcaption>Apple Watch</figcaption></figure><p>正好有一個空檔，等待 PM 規劃功能，團隊中成員提出舊版的會員頁面不適合後續功能的疊加，果斷的將舊的頁面打掉重寫（正好可以用新架構重寫），所以又花了一個禮拜將這個頁面重新改寫。而後面的改版也明顯感受到後續增加功能比較容易。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/0*EeHw43-tn1jlbrIn" /><figcaption>舊版會員頁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*1cuOltuw6OOKZXQy" /><figcaption>脫胎換骨後的會員頁面！</figcaption></figure><p>接著有一次在擴增 Android 的 Widget 功能時，移動了原本 Widget 的 Package 的位子，上線後，結果發現會直接影響到線上版啊。和同事花了整整一天才找到問題，但是最後束手無策直接放棄，因為沒有任何解決方案，只好請User重新拉一個新的 Widget。</p><p>Android Widget 太瞎拉！換個 Package Name 或路徑也不行！覺得鳥鳥的。（希望不要有人在踩到這個坑）</p><blockquote>2018年7月下載量破百萬，走在台灣的街頭上每遇到23個人就有1個人用過我們團隊寫的App（好浪漫）。</blockquote><p>我們也推出全新頁面，花了兩個禮拜寫出發票動態時報、台灣發票制縣！希望可以藉由這兩個功能讓使用者感受到我們有用心做好App，進而主動分享給朋友。</p><p>P.S iPhone X 我們也有顧好你們喔 ～</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*K1QOfh6dyNjAfAhS" /><figcaption>動態時報頁#1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/0*bG93pAYwJ_EdWRtT" /><figcaption>動態時報頁#2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/0*DTqnjt3d0q78L3Ba" /><figcaption>台灣發票制縣！</figcaption></figure><p>一群身手不凡的成員：</p><ol><li>Product Owner：確保產品絕不走偏，給予產品方向及定位。</li><li>PM：規劃出的開發文件，不斷跟團隊中所有團員討論。掌握App端、後端系統的規劃，在遇到任何問題總是可以快速的找出問題可能在哪裡。了解使用者需要什麼，不斷收集使用者反饋持續與團隊成員討論。</li><li>後端：我們的資深後端工程師非常特別，她也寫過 iOS App 所以瞭解一些細節該如何規劃系統才方便串接及使用，以及有大量的產品開發經驗，因此遇到任何問題時跟她一起討論，都可以有一個很棒的解決方案。</li><li>Android &amp; iOS工程師：我們除了寫好Code，我們也常常給予PM功能上的建議，因為我們會知道哪些新的技術可以應用在目前的App上，及挑戰PM的規劃。</li><li>設計：設計美美der畫面，和PM一起討論流程及畫面的設計。（好難刻啊&gt;&lt;!）</li><li>系統工程師：開獎時持續監控Server，維持穩定！</li><li>行銷Support：沒有妳不能啊（抱腿）。</li></ol><p>然而團隊中難免會有意見分歧的時候通常我們會使用：</p><ol><li>數據證明。</li><li>提出過往類似案例，以作參考。</li><li>溝通，各退一步到雙方都可以接受的範圍內。</li></ol><p>短短10個月成長非常多，也感謝團隊中所有成員各司其職，一起讓App越來越好。</p><p>整個團隊中每個人都發揮他最好的一面！期待接下來的開發計畫可以帶給使用者更好的體驗。</p><p>待續…</p><p>如果覺得我們有用『心』做App可以下載看看，有任何意見都可以給我們喔！</p><p>附上下載連結及icon：</p><p>APP名稱：統一發票對獎機+雲端發票存摺</p><p>iOS : <a href="https://goo.gl/EyQX4B">https://goo.gl/EyQX4B</a><br>Android : <a href="https://goo.gl/P4i7Sb">https://goo.gl/P4i7Sb</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*I7jEjmhuwHS_7f4uHw9ryg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb8172958713" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>