I summarized how to run the iPhone application on the actual device with Xcode. I will also try source control from Xcode on GitHub.
Search for xcode
in the App Store and install the app that appears.
I had an older version of Xcode installed so I tried to update it
I got an error saying The product cannot be installed because there is not enough free space
even though there is enough free space.
Perhaps the time machine was affecting the capacity of the app install. Once I uninstalled Xcode and emptied the Trash, I was able to install it successfully.
There seems to be a way to install Xcode directly. [Solving the problem that "There is no free space available" when installing Xcode from the App Store](https://monaga.site/not-enough-disk-space-available -to-install-the-product /)
Now that the installation is complete, let's create an app. Since the purpose is to run it on the actual machine, I will make an application that displays only Hello Swift.
Start Xcode and create an app from Create a new Xcode project
.
Then select App and Next
Project Name: The name of the app Team: Not set (set later) Organization Identifier: Unique ID like email address Interface:Story board Life cycle:UIkit App Delegate Language:Swift
I want to create a Git repository locally, so check Source Control. If you don't need Git management, remove it.
hello swift
Open Main.storyboard
, open the + button (Library) on the upper right, and place Label
on the screen by dragging and dropping.
Change the Text in the Show the attribute inspecter
menu on the right side of the screen to Hello Swift
.
You can run the simulator by selecting the device type from the frame (active scheme) next to the ▶ ︎ button and pressing the ▶ ︎ button.
If Hello Swift is displayed, it is successful.
This time I used my iPhone 8 Plus. First, connect your Mac and iPhone.
Register the account by pressing the + button on the setting screen of [Xcode] → [Preference] → [Accounts].
Enter your email address and password to complete the registration.
Select the folder where the app name is displayed in [Project Navigater] on the left side. In the [Signing & Capabilities] menu, set the Team of the Apple account you registered earlier.
Could not launch "xxxxx" After selecting the device in the active scheme, press the ▶ ︎ button to execute it, but I got an error like this. xxxxx is the app name.
From the iPhone screen, open [Settings] → [General] → [Device Management]. Since the email address registered with your Apple account is displayed, set this account to be trusted.
Click the ▶ ︎ button again to complete the startup.
Let's manage the project created this time on GitHub.
Just like an Apple account, register your Github account by pressing the + button from [Xcode] → [Preference] → [Accounts].
Since we already have a repository locally, we will create a remote repository.
Select Show the Source Control navigator
on the left side of the screen, right-click Remotes and selectNew xxxxx Remote ...
to create a remote repository.
Select the file to commit and push from [Source Control] → [Commit ...].
After that, write a comment in the commit message, check Push to remote
and commit, and it will be reflected in the Github repository.
Recommended Posts