티스토리 뷰
<<참고링크 내용>>
Some months ago, I needed to create new versions of my app’s. I wanted to do this without duplicating any code or projects. So I did some research and decided to figure out how to build towards multiple targets in XCode.
This is something I shied away from for a long time as I thought it would be a nightmare to figure out. What I discovered was that it’s much easier than I first thought, and also much more powerful as well.
So why do I need to do this? There are a few reasons:
- To create different versions of your app which have different features. E.g. a ‘Lite’ or ‘Free’ version
- To create targets which are tailored for different devices, possible with the same model and controller classes, but different view classes E.g. one target for iPhone, and another for iPad
So how do we do it?
Lets create a simple demo project.
In XCode, create a new project based on the ‘Utility Application’ template. Lets call it ‘TargetTest’.
Click on ‘Build and Run’
Notice under ‘Targets’ that there is one default target called ‘TargetTest’
We can create a new target by simply duplicating this one. Right click on that target and select ‘Duplicate’
You will notice a new info.plist copy is made for this new target. We can add target specific information here, such as changing the ‘Bundle Display Name’.
Lets rename the newly created target, TargetTest_VIP
Now, right click on the new target, and select ‘Get Info’. Under the ‘Build’ tab, ensure you have Configuration set to ‘All Configurations’.
Now we want to add a new flag under the ‘Other C Flags’ setting. We will enter -DVIPVERSION
We should also at this point, change the Product Name to a more meaningful name as shown.
Now, to see how it works, we will modify MainViewController.m slightly. In the showInfo method, we want to check which target we are running on.
So as you can see, if the C flag we defined is detected, the code will run in one direction, if not, then we go another way. We could easily give users who used in-app purchasing more features at this point for example.
Now, to test, we simply choose TargetTest_VIP from the Active Target dropdown, and ‘Build and Run’.
Now, when we click on the info button, we get the VIP message:
Now if we run again, but this time first select the Active Target, TargetTest, when we press the info button, the view flips.
You will also notice that 2 separate targets are built in your build output folder.
So overall this makes things a lot easier when it comes to distribution and allows maximum code reuse which can only be a good thing!
Download the demo project here.
If there’s anything I’m missing, please leave a comment and I can add it to the post.
'컴퓨터 > 개발' 카테고리의 다른 글
[이클립스/웹어플리케이션] war파일 만들기 & tomcat 활용 방법 (0) | 2012.11.02 |
---|---|
안드로이드] 현재 액티비티, 다른 액티비티 종료하기 (0) | 2012.11.02 |
[MAC 사용 TIP]맥의 Finder에서 숨김파일 보이기/숨기기 (0) | 2012.10.10 |
JSP 내에서 java script 호출방법 (0) | 2012.09.28 |
[IOS 개발 TIP] 아이폰앱 아이패드로 변환시 Tip!! (0) | 2012.09.27 |
- Total
- Today
- Yesterday
- 영화
- 한국의 인종차별 사례
- AirPod
- 비트코인
- 케이민즈
- 리뷰
- l1 norm
- 오곡우유
- 브렉시트
- Master of None
- AirPods
- 넥서스7
- 델 XPS
- 뉴넥서스
- 샤플
- 김연아 직촬
- 에어팟
- 비보북
- VIVO BOOK
- l2 norm
- 고사양노트북
- 와디즈
- 주식
- 마스터오브제로
- qoo10
- TensorFlow
- 클라우드펀딩
- dell xps
- 마스터오브논
- 오곡라떼
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |