iOS ๊ฐ๋ฐ์ ํ๋ค๋ณด๋ฉด ์์ฃผ ๋์ค๋ target์ด๋ผ๋ ์ฉ์ด์ ๋ํด ์ข ๋ ์์ธํ ๊ณต๋ถํ๊ณ ๊ฐ์ผ๊ฒ ๋ค๋ ์๊ฐ์ด ๋ค์์ต๋๋ค.
๋ณดํต ์๋ ์ฌ์ง์ฒ๋ผ ์๋ก์ด ํ์ผ์ ์ถ๊ฐํ๊ฑฐ๋ ํ ๋ ๊ผญ target์ ์ ํํ๋ ๋ถ๋ถ์ด ๋์ค๋๋ฐ ๋ณดํต ๊ธฐ๋ณธ์ ์ผ๋ก ์ ํ์ด ๋์ด์์ต๋๋ค. ๊ทธ๋ ๋ค๋ฉด ์ค๋์ ์ด target์ ๋ฌด์์ธ์ง ํ ๋ฒ ์์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
(+ Group๋์ ์ด ํ์ผ์ ๋ฃ์ Group(ํด๋)๋ฅผ ์ ํํ๋ ๊ฒ์ด๊ณ ์ํ๋ ํด๋ํด๋ฆญ ํ ์ฐํด๋ฆญ ํ๋ค New File ๋๋ ์ ๊ฒฝ์ฐ์๋ ์๋์ผ๋ก ํด๋น ๊ทธ๋ฃน ์ ํ๋์ด์์)
target์ ๋ฌด์์ผ๊น?
target๊ณผ ๊ด๋ จํ์ฌ apple ๊ณต์ ๋ฌธ์์์ ์ ์ค๋ช ํด์ฃผ๊ณ ์๋๋ฐ ํด๋น ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ์ฌ ์ดํดํ ๋ด์ฉ์ ์ค๋ช ํด ๋ณด๊ฒ ์ต๋๋ค.
target์ ์ฑ, ํ๋ ์์ํฌ, ์ฑ ํ์ฅ ํ๋ก๊ทธ๋จ ๋๋ ์ ๋ ํ ์คํธ์ ๊ฐ์ด ๋น๋ ํ๊ธฐ ์ํ ๊ฐ product๋ค์ ๋ช ์ํฉ๋๋ค.
ํ๋์ ํ๋ก์ ํธ์์๋ ์ผ๋ฐ์ ์ผ๋ก ๋จ์ผ product์ ๊ด๋ จ ๋ถ๋ถ๋ค์ ๋ํ๋ด๋ ํ ๊ฐ ์ด์์ target๋ค์ ํฌํจํ ์๋ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๋ค์ค ํ๋ซํผ ์ฑ ํ ํ๋ฆฟ ๊ฐ์ ๊ฒฝ์ฐ์๋ iOS ์ฑ๊ณผ Mac ์ฑ์ ๋ํ ๋ณ๋์ target๋ค์ด ํฌํจ๋์ด ์์ต๋๋ค.
ํ ํ๋ฆฟ์์ ์ ํ๋ก์ ํธ๋ฅผ ์์ฑํ ๋, Xcode๋ ์๋์ผ๋ก ํ ๊ฐ ์ด์์ ํ๊ฒ์ ํ๋ก์ ํธ์ ์ถ๊ฐํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ๋ฉํฐํ๋ซํผ ์ฑ ํ ํ๋ฆฟ์ iOS ์ฑ๊ณผ Mac ์ฑ์ ๋ํ ๊ฐ๊ฐ์ ํ๊ฒ์ ํฌํจํ๊ณ ์์ต๋๋ค.
A target specifies a product to build, such as an app, framework, app extension, or unit test. A project can contain multiple targets, usually representing related parts of a single product. For example, a project might contain separate targets for an app, a private framework, an app extension, and a suite of tests. When you create a new project from a template, Xcode adds one or more targets to the project automatically. For example, the multiplatform app template contains separate targets for an iOS app and Mac app.
ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก ํ๋ก์ ํธ ํ ํ๋ฆฟ์ ๋ง์ถฐ์ target์ด ํ๊ฐ๋ ๊ทธ ์ด์์ผ๋ก ์๊ธฐ๊ณ ๊ทธ target๋ค์ ๋น๋๋ฅผ ํตํด ๊ฐ๊ฐ์ product๋ค์ ๋ง๋ค์ด ๋ผ ์ ์์ต๋๋ค!
ํ๋ก์ ํธ target ํ์ธ ๋ฐฉ๋ฒ
๊ทธ๋ ๋ค๋ฉด ๋ด ํ๋ก์ ํธ์ target๋ค์ ๋ํ ์ ๋ณด๋ฅผ ์ด๋์ ํ์ธ ํ ์ ์์๊น์? ์์ ๋ด ์๋ค.
ํ๋ก์ ํธ์ target์ ํ์ธํ๋ ค๋ฉด ์ ์ฌ์ง์์ ๋ณด์ด๋ค์ํผ ์ผ์ชฝ ๋ค๋น๊ฒ์ดํฐ ์์ญ์์ ํด๋น ํ๋ก์ ํธ๋ฅผ ์ ํํฉ๋๋ค.
๊ทธ๋ผ ๊ฐ์ด๋ฐ ์๋ํฐ ์์ญ์์๋ ํ์ฌ ํ๋ก์ ํธ์ target์ ๋ํ ์ ๋ณด๊ฐ ํ์๋ฉ๋๋ค.
๊ฐ target์ ์ ํํ๋ฉด ํด๋น target์ ๋ํ General ์ ๋ณด, ํ์ฌ Build Setting ๊ณผ Capability ๋ฑ ์ ๋ณผ ์ ์์ต๋๋ค.
target์ ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ๋ฉด ํด๋น target์๋ง ์ํฅ์ ๋ฏธ์น๊ณ project๋ฅผ ๋ณ๊ฒฝํ๋ฉด ๋ชจ๋ target์ ์ํฅ์ ๋ฏธ์นฉ๋๋ค.
To view the targets in a project, select the project in the navigator area. The editor area displays the current project and target information. Select a target to view general information about it, and to view its current build settings and capabilities. Changes you make to a target’s configuration affect that target only. Changes you make to the project affect all targets.
์์ ์ด ์ํ๋ ๋ฐฉํฅ์ผ๋ก target๋ค์ ๋น๋ํ๊ธฐ ์ํด์๋ ๊ฐ target๋ค์ ๋น๋ ์ค์ ๋ค์ ๊ฑด๋๋ฆฌ๋ฉด ๋ฉ๋๋ค.
(๋น๋ ์ค์ ๊ด๋ จ ๋ถ๋ถ์ ๋ํด์๋ ๋ค์ํธ์์ ๋ค๋ค๋ณด๋๋กํ๊ฒ ์ต๋๋ค.)
์ํ๋ target์ ์์ค ํ์ผ ๋ฐ ๊ธฐํ ์ฝํ ์ธ ๋ฅผ ์ถ๊ฐํ๊ธฐ
target์ ํ ํ๋ฆฟ์ ๋ง์ถฐ ๊ธฐ๋ณธ์ ์ผ๋ก ๊ฐ๋ฐ์ ์์ํ๋๋ฐ ๋๋ ๊ธฐ๋ณธ ํ์ผ๋ค์ ํฌํจํ๊ณ ์์ต๋๋ค.
๊ทธ๋ฐ๋ฐ ์ด์ธ์ ๊ธฐํ ํ์ผ๋ค์ ์ถ๊ฐํ๊ฑฐ๋ ํ ๋๋ ์ฒ์ ๋ดค๋ ์ฌ์ง์ฒ๋ผ target์ ์ง์ ํด์ฃผ๋ฉด ๋๊ณ ์ด๋ฏธ ์ง์ ๋์ด์๋ target์ ๋ค๋ฅธ target์ผ๋ก ๋ฐ๊ฟ์ฃผ๊ฑฐ๋ ์ถ๊ฐํด์ฃผ๊ณ ์ถ๋ค๋ฉด ํด๋น ํ์ผ์ ํด๋ฆญํ ์ฐ์ธก์ identity inspector์์ Target Membership์ ์ฒดํฌ๋ ๋ถ๋ถ์ ์ํ๋๋๋ก ์์ ํด์ฃผ๋ฉด ๋ฉ๋๋ค.
Target templates contain default files to help you start development. Choose File > New to create new files and embed them directly into an existing target. To assign an existing file to a new target, select the file and update its membership attributes in the Identity inspector.
์ ๋ ๊ฐ์ฅ ๊ฐ๋จํ ํ ํ๋ฆฟ์ธ single app ํ ํ๋ฆฟ์ผ๋ก ์ฑ์ ๊ฐ๋ฐํ ๋๋ ์์๊ฐ์ด ํ๊ฒ์ด ํ๋๋ง ์๋ ๊ฒ์ ๋ณผ ์ ์์์ต๋๋ค.
Target๋ค ๊ฐ์ ์ข ์์ฑ
ํํ๋ก์ ํธ์ ํ๊ฒ์ด ์ฌ๋ฌ๊ฐ๋ผ๋ฉด ํ๊ฒ๊ฐ์ ์ข ์์ฑ์ ๊ฐ์ง๊ณ ์์ ์ ์์ต๋๋ค.
์ข ์์ฑ(dependencies)์ Xcode์๊ฒ ์ผ๋ จ์ ํ๊ฒ์ ์ฌ๋ฐ๋ฅธ ์์๋ก ๋น๋ํ ์ง์๋ฅผ ์ ๊ณตํฉ๋๋ค.
Xcode๋ ๊ฐ๋ฅํ ๊ฒฝ์ฐ ํ๊ฒ์ ๋ณ๋ ฌ๋ก ๋น๋ํ์ง๋ง, ๋๋ก๋ ํ๊ฒ์ ์ง๋ ฌ๋ก ๋น๋ํด์ผ ํฉ๋๋ค.
์๋ฅผ ๋ค์ด, Xcode๋ ํน์ ํ๋ ์์ํฌ๋ฅผ ๋งํฌํ๋ ์ฑ์ ๋น๋ํ๊ธฐ ์ ์ ํด๋น ํ๋ ์์ํฌ๋ฅผ ๋จผ์ ๋น๋ํด์ผ ํฉ๋๋ค. ์๋ก์ด ํ๊ฒ์ ์ฑ ๋ด์ ํฌํจ์ํฌ ๋, Xcode๋ ์คํด์ "Find Implicit Dependencies" ์ต์ ์ด ํ์ฑํ๋ ๊ฒฝ์ฐ ์ฑ๊ณผ ํ๊ฒ ์ฌ์ด์ ์ข ์์ฑ(dependency)์ ์์ฑํฉ๋๋ค.
์ด ์ต์ ์ด ๋นํ์ฑํ๋ ๊ฒฝ์ฐ ์ข ์์ฑ์ ์ง์ ๊ตฌ์ฑํด์ผ ํฉ๋๋ค.
์ข ์์ฑ์ ํ์ธํ๊ณ ์ถ๊ฐํ๋ ค๋ฉด, ํ๊ฒ์ ์ ํํ๊ณ ๋น๋ ๋จ๊ณ(build phase) ์ค์ ์ ์ด์ด์ผ ํฉ๋๋ค. "Dependencies" ๋น๋ ๋จ๊ณ์๋ Xcode๊ฐ ํ์ฌ ํ๊ฒ์ ๋น๋ํ๊ธฐ ์ ์ ์ฑ๊ณต์ ์ผ๋ก ๋น๋ํด์ผ ํ๋ ํ๊ฒ๋ค์ด ํฌํจ๋ฉ๋๋ค.
ํ๊ฒ ๊ฐ์ ์ํธ ์ข ์์ฑ์ด ์๋ค๋ฉด Xcode๋ ์ฌ๋ฌ ์ข ์ ํ๊ฒ์ ๋์์ ๋น๋ํ ์ ์์ต๋๋ค.
Dependencies tell Xcode the correct order in which to build a set of targets. Xcode builds targets in parallel when it can, but sometimes it must build targets serially. For example, Xcode must build a custom framework before it builds an app that links against that framework. When you embed a new target inside an app, Xcode creates a dependency between the app and target if the scheme’s Find Implicit Dependencies option is enabled. If that option is disabled, you must configure the dependency yourself. To view and add dependencies, select a target and open its build phase settings. The Dependencies build phase contains the targets that Xcode must successfully build before it builds the current target. Xcode can build multiple dependent targets simultaneously if there are no interdependencies between those targets.
์ฌ๊ธฐ๊น์ง target๊ณผ ๊ด๋ จ๋ ๊ฐ๋ ์ ์์๋ณด์๋๋ฐ์. target๊ณผ project๊ฐ ์ด๋ป๊ฒ ๋ค๋ฅธ ๊ฐ๋ ์ธ์ง์ง ์ ํํ ์ดํดํ๊ธฐ ์ํด์๋ build๊ด๋ จ ๊ฐ๋ ๋ค์ ์ดํดํ์ฌ์ผ ํฉ๋๋ค. ์ผ๋จ์ ํ๋์ ํ๋ก์ ํธ๋ ๋ฌด์กฐ๊ฑด ์ ์ด๋ ํ๋์ target์ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ ์์๋๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.
๊ทธ๋ผ build setting, build phase, configuration ๋ฑ์ ๋ด์ฉ์ ๋ค์ํธ์์ ์ด์ด์ ๋ค๋ค๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
Reference
Configuring a new target in your project | Apple Developer Documentation
'iOS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[iOS] ์ปค์คํ ํฐํธ ์ถ๊ฐ ๋ฐฉ๋ฒ (0) | 2023.02.16 |
---|---|
[iOS] addsubview()์ ํ๋ฒ์ ์ฌ๋ฌ subview ์ถ๊ฐํ๊ธฐ (0) | 2023.02.14 |
[iOS] iOS Concurrency - 1. GCD/Operation, ๋๊ธฐ/๋น๋๊ธฐ, ์ง๋ ฌ/๋์ (0) | 2023.02.11 |
[iOS] Rx์์ด ๊ตฌํํ๋ MVVM๊ธฐ์ด (0) | 2023.02.09 |
[iOS] UIButton.Configuration ์ฌ์ฉํด๋ณด๊ธฐ (0) | 2023.02.07 |