Как начать разрабатывать под iOS
Как начать разрабатывать под iOS и Mac OS? Такой вопрос нередко встречается на форумах посвященных программированию. В большинстве случаев ответы на такой вопрос, это: установить на мак Xcode, скачать SDK, взять книгу по Objective-C и вперёд. Но новичку в разработке под мак, перед собственно самим программированием, встретится несколько неприятных моментов. Например: а что если нет мака?
Если мака нет, его можно конечно купить. Но можно использовать бюджетный вариант и запустить Mac OS в виртуальной машине. Я использовал вот эту сборку для VMware на довольно не мощном компьютере. Процесс установки виртуальной машины пропустим, об этом можно прочитать на самом рутрекере.
Установка Xcode
После запуска мака, нужно установить среду разработки Xcode. Для этого заходим в AppStore, находим поиском Xcode и устанавливаем. Он бесплатный.


В общем-то всё! Можете начинать делать свои программы и игры. Но тестировать вы сможете их только в симуляторе iPhone или iPad. Для того чтобы протестировать своё приложение на реальном устройстве, вам нужно получить сертификат разработчика Apple, стоит он $99 в год. Но для начала можно использовать бюджетный вариант… 🙂
Patch Xcode
Необходимо пропатчить сам Xcode и каждый проект который вы хотите протестировать на вашем айфоне или айпаде. Для этого, качаем JailCoder и запускаем.

- Наживаем «Guided Patch»
- Выполняем инструкции на экране
- Вводим пароль: jailcoder
И вот, вы сделали свой первый проект «Hello, world!» и готовы запустить его на вашем новеньком айпаде. Если ваше устройство не взломано (jailbreak), то сделать это не получится. Я делал jailbreak по этой инструкции и всё получилось. Если же устройство взломано, то компилируем проект и забираем файл *.app.

Осталось запустить iTunes, подключить устройство к компьютеру, перетащить новый *.app файл в окно iTunes и синхронизироваться.
Вот так можно сэкономить немного денег на покупке мака, сертификата и начать программировать под iOS.
Xcode install (on MacOS)
This tutorial describes the installation and usage of gcc, make and other executable utilities from Apple which Homebrew, Python, and many other development tools need.
NOTE: Content here are my personal opinions, and not intended to represent any employer (past or present). “PROTIP:” here highlight information I haven’t seen elsewhere on the internet because it is hard-won, little-know but significant facts based on my personal research and experience.
Overlapping installers!
The executables from Apple are installed two separate ways. Imagine a Venn diagram of overlapping circles:
CommandLineTools at /Library/Developer/CommandLineTools
Xcode IDE at
Each has a separate install procedure.
Xcode is Apple’s free IDE developers use to create custom programs for all Apple devices (macOS, iPhone, iPad, Apple Watch). Increasingly, Machine Learning developers are using the Swift language.
Because XCode.app is very large (several Gigabytes), developers who do not create Apple programs can save disk space by not installing it. Instead, they install just the CommandLineTools needed by Homebrew and others.
About Xcode.app
Since the Apple Store only handles individual .app files, other mechanisms are needed to install additional programs needed as a pre-requisite by Homebrew, Python, and other development programs.
BTW Xcode only works on macOS. There is no Windows PC version.
Otherwise, read on for a run-around.
Use an internet browser to view Apple’s Xcode marketing page at:
Xcode “includes everything you need to create amazing apps for all Apple platforms. Now Xcode and Instruments look great in the new Dark Mode on macOS Mojave. The source code editor lets you transform or refactor code more easily, see source control changes alongside the related line, and quickly get details on upstream code differences. You can build your own instrument with custom visualization and data analysis. Swift compiles software more quickly, helps you deliver faster apps, and generates even smaller binaries. Test suites complete many times faster, working with a team is simpler and more secure, and much more.”.
BTW the “Apple platforms” include MacOS, iPhone, iPad, Apple TV, and Apple Watch.
Xcode does not come with macOS because of its large size and because many users of macOS don’t need it to do software development.
Developers who use another IDE (such as Visual Studio, Eclipse, etc.) would only need to install Xcode’s command line utilities for the GCC compiler Python needs to build code.
PROTIP: Newer versions of Xcode installer also installs a Git client.
cc and gcc needed
Homebrew, Python, and many other development tools need the cc, gcc, make and other executable utilities from Apple.
Verify the version of GCC installed:
If Xcode.app was installed, you would see (at time of writing):
Previously, it was instead:
If CommandLineTools is installed, you would see (at time of writing):
If “Command not found” appears, either install CommandLineTools or install XCode.app, then return here.
xcrun for path
Identify the path of the gcc
If Command Line Utilities is installed, the response is:
If Xcode.app is installed, the response is:
If neither is installed:
The same for make.
Again, if “Command not found” appears, either install CommandLineTools or install XCode.app, then return here.
Files and Folders
Let’s see what is in those folders:
If CommandLineTools was installed:
The response would be:
If Xcode.app was installed:
The response would have more than what’s in CommandLineTools:
Xcode.app Version
From within a Terminal, type:
If Command Line Tools was installed, you would see:
If Xcode is installed, you would get a version code that should match up with the Build Number on the Apple web page:
For a more precise version number and other info (macOS Mavericks version and up):
A sample response, at time of writing:
The previous command was constructed based on a search of tools package names:
xcode-select
Unlike other programs, a xcode-select command is needed to designate where to find gcc and other Apple Developer utilities.
In a Terminal window, find out what has been installed:
-p is the same as –print-path
If XCode CLI was installed, you should see:
If the Xcode-select command is not found, choose to either install Command Line Tools or install the full Xcode IDE.
If XCode.app was installed, you should instead see:
Specifying the XCode utility used
PROTIP: Xcode.app cannot be installed if Command Utilities has already been installed. So the installation program needs to first check whether XCode.app or CommandLineTools is installed.
Choose which one you want used:
To specify use of the Xcode.app (IDE):
To specify use of CommandLineTools:
Install Command Line Utilities only
To install Command Line Utilities:
A shell script uses these commands to not require manual clicking on the dialog that pops up (below):

If you see this pop up, manually click “Install”, “Agree”, then “Install” to the “Updates Available” pop-up.
CAUTION: The large number of files means it can a long time. It took 13 minutes on my 10mbps line.
When you see “The software was installed.”, click “Done” to dismiss the pop-up.
If you have the tree utility installed:
Would yield (at time of writing):
UnInstall Command Line Tools
PROTIP: This is also how you upgrade Command Line Tools.
Go to the parent folder where Command Line Tools is installed:
Get a list of its folders:
If Command Line Tools were installed, the response would be :
Remove all files in that folder, provide a password for elevated permissions to get all the files:
The response is a lot of files removed (to the Trash).
CAUTION: On a Mac M1 (Apple Silicon chip, macOS 12.0 Monterey), after installed the Command Line Tools then uninstalled them by deleting /Library/Developer/CommandLineTools and running sudo xcode-select -r, I was still getting updates to the tools in System Preferences > Software Update.
The files below are protected by SIP: to delete them, I had to disable SIP first (ie disable SIP, delete the files, re-enable SIP).
Indeed, the receipts are at /Library/Apple/System/Library/Receipts, in the form of files
- com.apple.pkg.CLTools_Executables.
- com.apple.pkg.CLTools_SDK_macOS*.
- com.apple.pkg.CLTools_macOS_SDK.
Xcode IDE install from Terminal
Make sure you have at least 13GB free on your hard-drive before attempting installation.
- Click the Apple icon to select “About this Mac”.
- Click “Storage” tab.
In an internet browser, get to the “Mac App Store Preview” for Xcode at
https://apps.apple.com/us/app/Xcode/id497799835?mt=12

Click View in Mac App Store, then “Open App Store.app” in the pop-up.
Provide your Apple ID and password. Get one if you don’t already have one.
PROTIP: DO NOT install a beta version of Xcode.
The blue “OPEN” icon appears at the upper-right when the app is installed. But don’t click it because we are done.
In Finder, look for Xcode.app in the /Applications folder.
Alternately, on the Touchpad pinch 4 fingers together to click the App Store. Type enough of “Xcode” to filter out others.
To view the version, cursor to the top of the screen and click the program name next to the Apple icon to select “About Xcode”:

A) Initial install from Terminal CLI
Open a Terminal.app console window at any directory to install -all the latest Xcode from Apple:
The response on Catalina version of macOS:
Click the Apple icon at the upper-right corner and select “Shut Down…”.
After starting again
Set Apple’s licensing agreement bit:
Manually agree to the terms.
Get the version number of the new version.
B) Initial IDE install using web App Store
Sign in to Apple Developer with your email address then click the arrow icon. Enter your password, then click the arrow icon.
Below is the “Software Update” approach:
You’ll need to establish an Apple ID if you haven’t already.
Click the cloud icon Download and provide your Apple ID.
Go through Apple’s location verification if prompted.

Confirm your account.
Click “Allow” to the pop-up “Do you want to download?”.
Xcode size
CAUTION: Make sure that your machine has enough free space available.
These are massive files that may take a while to download if you don’t have a fast internet connection.
NOTE: Each version of Xcode is related to a specific version of the Apple OS Mac operating system.
Switch to Finder Downloads folder to watch progress on the file name ending with “Download”. The one with a clock icon which signifies downloading.
Return to the versions instructions above to view the updated version.
Delete the installer after you’re done, to reclaim disk space.
Xcode IDE Upgrade
Over time, Apple updates Xcode and its command line utilities.
Click the Apple icon, then click System Preferences. Here is an example notification:

Swift version
Get the version of the Swift program used to develop iOS mobile apps:
If you are on an Intel CPU, a sample response at time of this writing:
If you are on an ARM (M1) CPU, a sample response at time of this writing:
If jamf installed Xcode, you’ll also see:
The above appears regardless of whether Command Line Utilities or Xcode.app is installed.
Xcode FileMerge tool
Xcode graphically compares files and directories.
Open Xcode. This takes a few seconds.
Right-click on Xcode icon. Select “Open Developer Tool”. Select “FileMerge”.
Help Topic: Installing XCode and Enabling Command Line Tools
Maintained by: mikerb@mit.edu
Get PDF
Installing XCode and Enabling Command Line Tools
This page concerns getting XCode on your Mac. It contains components, like the C++ compiler, that will be essential for our purposes, so we’ll need to make sure it’s installed on your machine. On your machine, it’s possible that:

- XCode is properly installed but you just don’t know it,

- XCode is not at all on your machine.


If you have a Mac provide by the 2.680 staff, and have just created your own user account, the most likely scenario is the first one. In any event, we’ll soon find out.

Checking if XCode is already installed (using Finder) [top]
Finder is the Mac application that is running constantly and by default upon login. To switch over to running Finder, just click anywhere in the screen background outside an app. We’ll use Finder to find out if XCode is installed.

- In Finder, select the Go pull-down menu, and select Applications. Or just use the short-cut key Command-Shift-A while Finder is active.
- This should open a new Finder window, showing all the Applications installed on your machine. Look for the XCode icon in the Applications folder. It is blue and has a little hammer. It should look something like:



Figure 1.1: The Finder window, showing the XCode application, should look something like this.


After double-clicking on the XCode icon above, the XCode splash window should appear, looking something like:


Figure 1.2: The XCode splash window typically will open when you launch XCode.


If you successfully found and launched XCode, go directly to the Section «Updating XCode» .

If you did not find XCode on your system, proceed to the following Section «Installing XCode» .


Installing XCode [top]
XCode is distributed by Apple. It is free but Apple wants you to sign up as a developer to have access to XCode. This can be done anonymously, but you have to do the following steps:

- Obtain an Apple ID if you haven’t already. It is free. https://appleid.apple.com

- Obtain XCode from the App Store. Even though it’s free, this is still the way to install it on your computer. To access the App Store, you obviously will need to have a network connection.



You can go to the App Store by clicking on the main Apple Menu at the very top left of your screen, and selecing App Store . You can also get there by selecting the App Store icon in your Dock if it is there. The icon should look like:


Figure 1.3: The App Store icon.


- Once you have launched the App Store, search on the term «XCode». You should see something like:




Figure 1.4: The XCode Application is found on the App Store.


Presumably the button next to XCode will say «GET» , but it may say «UPDATE» or «OPEN» if in fact it somehow was installed but ecaped our attention when we were looking for it previously. If it says «GET» or «UPDATE» , click on the button and go through the steps to download or update the software. Once you are done, or if the button said «OPEN» , proceed to the section «Installing the XCode Command Line Utilities» .


Updating XCode [top]
Even if XCode is installed on your machine already, we want to (a) check if it needs to be updated, (b) install the command line utilities. If you just now installed XCode as in the previous section, you can skip this step and proceed to the Section «Installing the XCode Command Line Utilities» .

We check for available updates first since, if a new update is indeed applied, the command line utilities may need to be re-installed anyway. Note, some people may have their system configured to apply updates automatically. But if you don’t you need to periodically check to see if updates are available and decide if the current moment allows for the disruption of downloading and applying updates.

To check if an update is available for XCode, select the main Apple pull-down menu from the upper-left corner of your screen. It may show something like:


Figure 1.5: The Apple pull-down menu shows that there are currently 6 applications that need to be update.


In the above case, there are 6 applications from the App Store (XCode is obtained through the Apple App Store), that have updates available. Select this menu item, and a window like the following should appear.


Figure 1.6: In this case XCode is listed as needing an update.


If you see XCode in the list of apps that need to be updated, as above, go ahead and select it by clicking on the UPDATE button and following the instructions.


Installing the XCode Command Line Utilities [top]
XCode is quite large and there are a number of optional components that may not be installed by default. One of these is the Command Line Utilities. We will install this from the command line with:
Установка
Как я упомянул ранее, Xcode предоставлен компанией Apple. Для того чтобы установить его на свой Mac, необходимо сделать следующее:
- Открыть App Store на Mac.
- В поиске ввести «Xcode».
- Выбрать Xcode из списка найденных приложений.
- Нажать на кнопку «Install» и дождаться загрузки/установки.
Всё легко и просто, правда?
Первое знакомство
Xcode установлен, глаза горят, руки хотят начать писать код и внести свой вклад в разработку мобильных приложений. Но для начала, нужно ознакомится с новой IDE, иначе ничего дельного у нас не получится.
Запустите Xcode и перед Вами появится окно приветствия:

Здесь мы видим, что оно условно разделено на 2 секции:
- Левая часть позволяет создавать новые проекты
- Правая часть — открывать уже существующие.
Воспользуемся первым вариантом и создадим новый проект. Нажмите на «Create a new Xcode project» и Вы увидите следующее меню выбора:

Знакомство с Xcode — 1
IDE тут же предложит Вам выбрать один из шаблонов:
- Master-Detail Application — в данном шаблоне используется раздвоение контроллера представления для отображения списка элементов и их содержание. Примерно так устроены стандартные «Настройки» на iPad.
- Page-Based Application — в основе шаблона лежит UIPageViewController.
- Single View Application — наиболее используемый и самый простой шаблон. Включает в себя стандартный UIViewController и его класс.
- Tabbed Application представляет из себя UITabBarController с двумя «вложенными» UIViewController‘ами.
Со временем мы рассмотрим их все и Вас не будут пугать эти контроллеры, упомянутые выше. Но на данном этапе нам понадобится Single View Application. Выберите его и нажмите кнопку «Next«.

В новом окне нужно заполнить следующие поля:
- Product Name — это, собственно, название Вашего проекта. Назовите его «HelloWorld».
- В Organization name указывается название организации или разработчика. Система по-умолчанию берет имя Вашего аккаунта Mac.
- Organization identifier зачастую представляет из себя доменное имя Вашей организации, записанное в обратном порядке. К примеру, web-адрес нашей команды woopss.com, следовательно нашим идентификатором является com.woopss. Немного запутано, но это стоит соблюдать, так как это поможет сделать идентификатор приложения уникальным.
- Bundle idenitifier и является тем уникальным идентификатором приложения, упомянутым выше. Он создается на основе названия приложения и ID организации. Сейчас он должен выглядеть примерно так: «com.woopss.HelloWorld«.
- В поле Language выбирается тот язык программирования, на котором будет написан проект. Выберите Swift.
- В графе Devices нужно выбрать семью устройств, которые будут поддерживаться: iPhone, iPad или Universal (iPhone+iPad). Оставьте Universal.
Все следующие опции на данный момент нам не нужны, поэтому можете снять с них выделения (если они выделены). Нажмите кнопку «Next» и выберите папку на Вашем Mac, куда нужно сохранить проект.
Верьте или нет, но Вы только что создали Ваш первый проект. Вы можете уже сейчас запустить его, нажав на cmd+R или кнопку Run в правом верхнем углу. Вы увидите просто белый экран. Это вполне логично, т.к. мы не добавляли никаких графических объектов. Так что можно это воспринимать как белый холст, на котором можно творить.
На этом наш урок подходит к концу. В следующем мы чуть более подробно рассмотрим все области Xcode и уже совсем скоро научим наше приложение что-то делать.