CLEMで発表した資料
英語LT
ResourceKitの使い方について
http://github.com/bannzai/ResourceKit
https://clem.connpass.com/event/55548/
これより下はカンペ
1------------------------------------------------------------------
Hi, everyone
2--------------------------------------------------------------------
My name is Yudai HIrose.
I develop iOS application in work.
I use GitHub.
I have GitHub account.
I have some repository on GitHub, written by swift.
My friends call me スター乞食.
So, give me star all repository.
Make me happy.
Give me star.
3------------------------------------------------------------------------
So here goes the main part.
This talk about way to erase hard code.
I will explain with examples that meaning.
4------------------------------------------------------------------------
Let’s see this code from top to bottom.
// instaciate viewcontroller from storyboard
// perform segue
// image from Asset.xcassets
// instantiate from nib
// register cell using by identifier
Well, what is the problem common to this code?
So,
That is using string literalwhen get instance from resource name.
So what’s happen?
5--------------------------------------------------------------------------------
(スライドの文字を読んでから)
This is a very serious problem.
It will be late to go home with this.
I want to play ゼルダ
But I made a ResourceKit to solve this problem.
So, This talk about using ResourceKit.
6--------------------------------------------------------------------------------
This link to ResourceKit.
Please give me a star when I have finished talking.
7--------------------------------------------------------------------------------
Let’s see this code.
It does not use hard code.
But It has the same meaning as the problem code just before.
ResourceKit solves the hard code problem by automatically generating functions is syntax valid.
Next, I will explain how to use ResourceKit.
8----------------------------------------------------------------------------------
This slide about install ResourceKit via cocoapods.
(スライドの文字を読む)
9---------------------------------------------------------------------------------
Go to Xcode.
Select plus mark button.
And Select New Run Scrip
10-------------------------------------------------------------------------------
Added New Run Script.
10 〜 11 にかけて------------------------------------------------------------
And Move this third from the to
12-----------------------------------------------------------------------------------
Open Run Script row.
You can write to run any script about Your xcode project when each xcode build.
So, next Write "$PODS_ROOT/ResourceKit/ResourceKit"
This is ResourceKit path, downloaded via cocoapods.
13-----------------------------------------------------------------------------------
Go to Xcode, and build.
When the build is successfully.
Show in the finder for your Xcode project directory.
You find ‘ResourceKit.generated.swift’ file.
This file is auto generated file by resourcekit when Xcode build.
14-----------------------------------------------------------------------------------
You add Resource.generated.swift to your Xcode project.
And add build target.
15-----------------------------------------------------------------------------------
Open ResourceKit.generated.swift.
You find functions.
e.g
Instanciate viewcontroller from storyboard,
and instanciate UIImage from Asset.xcasets, ,,
and so on.
These functions automatically generated on build time.
Functions are remade from each resource information from Xcode project at build time.
For example, storyboard, xib, .xcasset, and so on.
Function names are decided from resource information.
In short, this is changed Resource.generated.file from resource information at each build time. Runtime error can be prevent.
16-----------------------------------------------------------------------------------
You can use this functions from now on your project.
Just like the way this.
I showed you first.
You are able to erase the hard code with this.
That's perfect.
17-----------------------------------------------------------------------------------
18-----------------------------------------------------------------------------------
19-----------------------------------------------------------------------------------
20-----------------------------------------------------------------------------------