Skip to content

Commit

Permalink
サンプルプロジェクトをSwift Packageで管理 (#79)
Browse files Browse the repository at this point in the history
* サンプルコードをSwiftPackageで管理する

* 不要なファイルを消す

* Entitlementsも消してみる

* パッケージのパスが間違っていたのを修正

* nameをつける
  • Loading branch information
kvvzr authored May 17, 2023
1 parent 6c7d295 commit 30d9fc1
Show file tree
Hide file tree
Showing 37 changed files with 406 additions and 749 deletions.
9 changes: 9 additions & 0 deletions CharcoalSwiftUISample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
29 changes: 29 additions & 0 deletions CharcoalSwiftUISample/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "CharcoalSwiftUISample",
platforms: [
.iOS(.v13),
.macOS(.v12)
],
products: [
.library(
name: "CharcoalSwiftUISample",
targets: ["CharcoalSwiftUISample"]
)
],
dependencies: [
.package(name: "charcoal-ios", path: "../")
],
targets: [
.target(
name: "CharcoalSwiftUISample",
dependencies: [
.product(name: "Charcoal", package: "charcoal-ios")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Charcoal
import SwiftUI

struct ContentView: View {
public struct ContentView: View {
@State var isDarkModeOn = false

var body: some View {
public init() {}

public var body: some View {
NavigationView {
List {
Toggle("Dark Mode", isOn: $isDarkModeOn)
Expand Down
9 changes: 9 additions & 0 deletions CharcoalUIKitSample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/config/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
36 changes: 36 additions & 0 deletions CharcoalUIKitSample/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "CharcoalUIKitSample",
platforms: [
.iOS(.v11)
],
products: [
.library(
name: "CharcoalUIKitSample",
targets: ["CharcoalUIKitSample"]
)
],
dependencies: [
.package(name: "charcoal-ios", path: "../")
],
targets: [
.target(
name: "CharcoalUIKitSample",
dependencies: [
.product(name: "Charcoal", package: "charcoal-ios")
],
resources: [
.copy("Storyboards/Buttons.storyboard"),
.copy("Storyboards/Colors.storyboard"),
.copy("Storyboards/Content.storyboard"),
.copy("Storyboards/Selections.storyboard"),
.copy("Storyboards/TextFields.storyboard"),
.copy("Storyboards/Typographies.storyboard")
]
)
]
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import UIKit

final class ViewController: UITableViewController {
private let storyboardTitles = ["Buttons", "TextFields", "Selections", "Colors", "Typography"]
public final class ContentViewController: UITableViewController {
public class func instantiate() -> UIViewController {
let viewController = UIStoryboard(name: "Content", bundle: .module).instantiateInitialViewController()!
return UINavigationController(rootViewController: viewController)
}

private let storyboardTitles = ["Buttons", "TextFields", "Selections", "Colors", "Typographies"]

override func viewDidLoad() {
override public func viewDidLoad() {
super.viewDidLoad()

setupNavigationBar()
Expand All @@ -28,15 +33,15 @@ final class ViewController: UITableViewController {
}
}

override func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
public override func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int {
return storyboardTitles.count
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
public override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)

let title = storyboardTitles[indexPath.item]
guard let viewController = UIStoryboard(name: title, bundle: nil).instantiateInitialViewController() else {
guard let viewController = UIStoryboard(name: title, bundle: .module).instantiateInitialViewController() else {
return
}
viewController.title = title
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21225" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21207"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -12,7 +12,7 @@
<!--Buttons View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController id="Y6W-OH-hqX" customClass="ButtonsViewController" customModule="UIKitSample" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="Y6W-OH-hqX" customClass="ButtonsViewController" customModule="CharcoalUIKitSample" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -12,7 +12,7 @@
<!--Colors View Controller-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController id="Y6W-OH-hqX" customClass="ColorsViewController" customModule="UIKitSample" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="Y6W-OH-hqX" customClass="ColorsViewController" customModule="CharcoalUIKitSample" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
Expand Down
Loading

0 comments on commit 30d9fc1

Please sign in to comment.