Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
GANMA!にSwift PMを 導入した話
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
masayuki sano
May 19, 2022
Programming
510
0
Share
GANMA!にSwift PMを 導入した話
iOS Snack bar #1 2022/05/13
masayuki sano
May 19, 2022
Other Decks in Programming
See All in Programming
ソフトウェア設計の結合バランス #phperkaigi
kajitack
0
140
一度始めたらやめられない開発効率向上術 / Findy あなたのdotfilesを教えて!
k0kubun
4
3k
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
640
アーキテクチャモダナイゼーションとは何か
nwiizo
19
5.4k
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
570
AIエージェントで業務改善してみた
taku271
0
540
実践CRDT
tamadeveloper
0
590
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
110
forteeの改修から振り返るPHPerKaigi 2026
muno92
PRO
3
290
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
2
550
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
150
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
280
Featured
See All Featured
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
320
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
510
Design in an AI World
tapps
1
200
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
340
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
460
From π to Pie charts
rasagy
0
170
Prompt Engineering for Job Search
mfonobong
0
270
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Become a Pro
speakerdeck
PRO
31
5.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
What's in a price? How to price your products and services
michaelherold
247
13k
Transcript
GANMA!にSwift PMを 導入した話 FLINTERS 佐野真之 iOS Snack bar #1 2022/5/13
自己紹介 FLINTERS / GANMA! iOSエンジニア 1600万ダウンロード突破! プレミアム会員(サブスク)、広告、GANMA!コイン、グッズ、書籍など
アジェンダ • GANMA!へのSwift Package Managerの段階的導入 ◦ ライブラリ管理 ◦ Embedded Framework
→ Swift Package ◦ Viewなどの移行 • その後の効果
Swift PM導入の背景 • xcodeprojファイルのコンフリクト • Embedded frameworkを気軽に作成しづらい • Swift PMでライブラリ管理
• Embedded frameworkをSwift Packageへ • マルチモジュール化 SwiftPMに対応したライブラリも増えてきたこともあり段階的に導入していく 課題感
Swift PM導入 app.xcworkspace/contents.xcworkspacedata Package.swift プロジェクトナビゲーター ワークスペースの編集、Package.swiftを追加 既存コードをAppに移動
<1st step> Cocoa Pods x Swift PMへ SwiftPMに対応 → Swift
PM バイナリ形式のxcframework → Swift PM それ以外の広告SDKなど → CocoaPods Carthage → 削除 モジュールへ依存追加 Package.resolved
Swift PMと CocoaPodsでのコンフリクト Swift PMでFirebase、CocoaPodsでAdMobをインストールした場合 GoogleAppMeasurementがどちらからもインストールされてしまう Podfile MyAdMob.podspec.json コンフリクトする依存を削除
Appでのライブラリ使用 App側でSwiftPMでインストールしたライブラリを使用したい場合は 必要なライブラリをModuleに含めてFrameworkをプロジェクトに依存を追加
<2nd step> Embedded Frameworkの移行 まずはEmbedded frameworkをSwift Packageに移行 そのあと第3ステップでViewやPresentationも移行 App ∟View
∟ ViewModel, Presenter ∟ Resources Embedded framework ∟DataLayer ∟ ModelLayer ∟ DomainLayer ∟ ApplicationLayer 以前のGANMA!のプロジェクト構成
Module、Frameworkの作成 Sources以下のディレクトリを .targetでModuleとして作成 .libraryで複数ModuleからFrameworkを作成 xcodeprojのようにコンフリクトしない!
Appへの取り込み FrameworkをAppのプロジェクトに追加していけばOK あとはモジュール単位でimport していくだけ App/File.swift imoprt ModelLayer ModelLayer.Model() ModelLayer =
Framework ModelLayer = Module
<3rd step> マルチモジュール化 xib, storyboardを使用する場合 App ∟View ∟ ViewModel, Presenter
∟ Resources 表示確認をしながら少しずつViewLayerに分離中 ViewのSwift Packageへの移動 コードからxibを使用する場合 Appに残っているコードをSwift Packageに移し モジュールを作成しやすいようにしていく
Assetモジュール作成 Appの画像や色のアセットを ViewLayerでも使用したい SwiftGenの自動生成コードを Assetモジュールとして分離 SwiftGenでの自動生成コード
@_exported import @_exported importにより同一モジュールでのimport Assetsを 書かなくても使用可能 @_exported import Assets //
import Assets がいらない File1.swit File2.swit Module A import ModuleA // Assets使用可能 File1.swit Module B
導入の効果 • マルチモジュール化しやすくなった。ミニアプリつくりやすい • アプリサイズが減った ◦ 23.5MB -> 20.6MB •
ライブラリバージョン変わってもコマンド叩かなくていい • ビルド時間短縮
まとめ Swift Package Managerでライブラリ管理、モジュール分割を段階的に行った。 今後はさらにマルチモジュール化を進めていく予定。