How to Set up the iOS Development Environment
In the era of mobile Internet, it is very beneficial to master iOS development and Android development. When I was learning mobile terminal development recently, the first problem I encountered was the installation of the environment.
Although the tutorials on the Internet are already very rich, it is not always smooth, and it is always unavoidable to step on the pit. Here is a pit-stepping note for iOS development. Not everyone will encounter these pits, but if you happen to encounter them, I hope to be able to help and inspire you.
First of all, to declare that to package iOS or macOS apps locally, you must have a Mac computer, because iOS software must be packaged with Xcode. Xcode is a development tool dedicated to Apple devices. Apple makes this a complete tool chain, not cross-platform. If you develop Android APP, it doesn't matter whether it is Windows or Mac. Android Studio for Android development is cross-platform, and both Mac and Windows can be installed and used.
To mention a little knowledge, modern web development is developing rapidly, and some cross-platform frameworks such as React Native and Ionic can be developed once and deployed across platforms. Such a framework brings an advantage, you can actually not use a Mac during the development stage, you only need an iPhone. For example, using the service of expo, you can use your own iPhone to debug, and use the official cloud deployment to package iOS APP. The same Ionic also provides this kind of service, but the price of this kind of service is too high, it may not be suitable for individual developers, and there is no iOS local simulator debugging, it may not be convenient to check the problem, interested friends can learn more about it .
In short, in general, if you want to do iOS development, you need to prepare a Mac computer first.
I found two good mobile APP development environment installation guides
Capacitor build APP development environment documentation: Environment Setup
React Native builds APP development environment documentation: Setting up the development environment
We build the environment according to the Capacitor documentation. Capacitor is a tool for packaging native apps launched by the Ionic team.
- The first step is to install Xcode, click on the Xcode introduction page through the official website link, there is a download button
Download Xcodeat the bottom, you need to log in before downloading, but after downloading, it will prompt
No Operating Systems available for download
So I can only install Xcode on the Apple Store, which is relatively simple, just search for Xcode on the Apple Store.
- Then install CocoaPods for Swift and Objective-C dependency management using the following commands
sudo gem install cocoapods
I'm getting an error at this step
You might have to install separate package for the ruby development environment, ruby-dev or ruby-devel for example.
The error message roughly says that I need a Ruby development environment. Install the Xcode command line tools with the following two commands
xcode-select --install sudo xcodebuild -license
Then a new error was reported, prompting me that the command line tool has been installed and needs to be updated
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
First delete the old one and then reinstall it, so I need the following 4 commands to install CocoaPods in this step
sudo rm -rf /Library/Developer/CommandLineTools # The installation window will pop up during installation, click OK according to the prompts xcode-select --install # This step agrees to the certificate, be sure to enter "agree" at the end to take effect, you can't "Enter" all the way to the end sudo xcodebuild -license sudo gem install cocoapods
- I noticed that the official tutorial has an action to select the command line tools in Xcode, open
Xcode -> Preferences -> Locationsand select the latest version in the drop-down list to install the Xcode command line tools. I may have already installed the command line tools, and there is no problem here.
The above are the pits that I encountered when setting up the iOS/macOS APP development environment, as a note for your reference. If you have a better experience, please share it.