Return to site

How To Run App On Iphone Xcode

broken image



You can run your application on an iOS device only after you have successfully completed the following steps:

Once you have a codesign signature, all that remains to do is click the 'Play' button on the top left side of the Xcode window and wait for the app to launch on your iPhone, iPad or iPod touch. Go to the location Applications Xcode Right Click Show Package Contents Contents Developer Platforms iPhoneOS.platform DeviceSupport as shown in the following screenshot and placed the unzipped directory. Inside DeviceSupport directory. First, open Xcode, and connect your iPhone to your Mac via USB. Then, open the Devices panel in Xcode via the Window → Devices and Simulators menu. Then, find your iPhone in the list on the left, and then click Enable for Development, and make sure that the Show as run destination checkbox is ticked. How to Sideload iOS Apps onto iPhone & iPad from Xcode Jan 12, 2016 - 10 Comments Modern versions of iOS and Xcode support something called sideloading, which essentially allows iPhone and iPad users to install apps and software onto their iPhone, iPad, or iPod touch directly from Xcode on a Mac, without having to go through the iOS App Store.

  • Configure your development environment for iOS application development
  • Create a development provisioning profile for your application
  • Complete the Provisioning Page for the Debug platform configuration.
Iphone

The following is a conceptual illustration of the iOS development process, including the connection to an iOS device:

Steps to Run Your Application on an iOS Device

Connect your iOS device to your Mac with an Apple USB cable
  1. Run the Platform Assistant on the Mac.
  2. Test the connection to your Mac (on the Connection Profile Manager page).
  3. Connect an iOS device (such as an iPhone or an iPad) to your Mac using the Apple standard USB cable (illustrated on the right).
    Note:
    • Only one iOS device should be connected to the Mac at one time.
    • In some cases, your iOS SDK version does not need to match the iOS device version. For example, you can build your app with the iOS 6.x SDK, and your app can run on a 5.x device.
  4. In RAD Studio:
    1. In the Project Manager, expand the Target Platforms node and double-click the iOS Device target platform to select that platform. The selected target platform is displayed using a bold font.
    2. In the Target Platforms node, expand the iOS Device node, expand the Configuration node, and double-click the Debug platform configuration to select it. The selected platform configuration is displayed using a bold font.
      Note: You cannot run applications directly from RAD Studio into an iOS Device if you build them with the Ad hoc or the Application Store platform configurations. To run applications deployed for ad hoc distribution, see Deploying Your iOS Application for Ad hoc Distribution. To run applications built for the App Store, you must install them from the App Store.
    3. Run your application, either with debugging (Run > Run) or without debugging (Run > Run Without Debugging).

RAD Studio builds your application using the SDK you previously added to the IDE, connects to your Mac using the connection profile you configured for the iOS Device platform, and the Platform Assistant on the Mac launches your application on the connected iOS device.

Note: RAD Studio might look frozen at some points until it launches your application on your iOS device, but it is just preparing to run your application.

Troubleshooting

For 'Device connection timeout,' please connect your iOS device to your Mac

If your iOS device is not connected, you see the following message in the IDE after you attempt to launch your app on an iOS device: How to install google chrome os on my laptop.

If you see this message, do the following:

  1. Dismiss the message.
  2. Connect your iOS device to the Mac using an Apple USB cable (shown above).
  3. Run your app again from the IDE. See the steps given above.
Note: The PAServer command-line utility allows you to set a device connection timeout using the -devicetimeout=. However, setting a different device timeout value does not solve the problem in the case of a missing iOS device.

'Unable to locate DeviceSupport directory matched with connected device info'

How To Run App On Iphone Xcode Settings

If you have recently upgraded the iOS version of your device, you might get the error message above when you try to run your application on your iOS device. If you see this message, do the following:

  1. Dismiss the message.
  2. On the Mac, open Xcode.
  3. Select Window > Organizer and determine whether Xcode recognizes your device:
    • If Xcode recognizes your device, let Xcode re-import your device support information, and try running your application from RAD Studio again.
    • If Xcode does not recognize your device, you must upgrade Xcode.
      Note: Alternatively, if Xcode does not recognize your device, but you do not want to upgrade Xcode in your Mac, you may try connecting your device to a different Mac which does have an upgraded version of Xcode that recognizes your device. After you let a newer version of Xcode re-import your device support information, an older version of Xcode might recognize your upgraded iOS device as well.

Nothing Shows Up in the iOS Device

If after you follow the steps to run your application on an iOS device, the application does not show up in your iOS device, check the following:

  • The Platform Assistant must be running on the Mac. See Running the Platform Assistant on a Mac:
  • On RAD Studio, the connection profile associated with the iOS Device target platform must connect with the target instance of the Platform Assistant.
    • See Activating and Configuring the Target Platform for instructions on how to configure the connection profile associated with the iOS Device target platform in your project.
    • On the Tools > Options > Environment Options > Connection Profile Manager page:
      • Select the connection profile associated with the iOS Device target platform from the left-hand column (which lists the available connection profiles, grouped by platform).
      • Check the values of that connection profile, such as the IP address (it must be your Mac's IP address) and the port number (it must be the Platform Assistant's port number).
      • Click Test Connection to ensure your development PC has a working connection to the Platform Assistant that is running on the Mac.
  • Only one iOS device should be connected to the Mac at one time.

My App Does Not Stop at Breakpoints Anymore

After a crash during a debugging session on an iOS device, it might happen that the next debugging sessions do not work anymore on your iOS device.

If when you run with debugging symbols your application runs but never stops at any breakpoint, do the following:

  1. On your Mac, launch Xcode.
  2. On Xcode, create a new iOS application.
  3. With your new Xcode iOS application open, select iOS Device as your target.
  4. Click and hold Run, and select Analize from the context menu that appears.

You can now close Xcode and continue using your iOS device to debug RAD Studio applications.

See Also

February 13, 2020

Goal

Build an iPhone app to roll a dice:

Objectives

This tutorial will show you how to:

Requirements

For this tutorial no previous knowledge of Swift / Xcode is required. To develop iOS apps for the iPhone/iPad using Xcode 11, you'll need a Mac running at least macOS 10.14 Mojave.

Xcode For Iphone

Install Xcode and create a new iOS project

  1. Open the App Store app and install the latest Xcode:

  2. Start Xcode and check your Xcode version on the welcome screen:

  3. If you already know how to create Xcode projects and import image assets, take a shortcut and download the starter project Dice-starter.zip with the images already set up and skip to adding the UI views.

  4. Run Xcode and create a new project with File » New » Project⌘⇧N. Select iOS » Application » Single View Application:

  5. Configure the project settings:

    • Name the app 'Dice'.
    • Use com.example as Company Identifier. This should be a domain name you own to prevent naming conflicts; feel free to use your own domain name.
    • Choose Swift as Language.
    • Choose Storyboard as User Interface technology.
    • Uncheck Use Core Data and Include Tests (which are not needed for this tutorial):
  6. Confirm with Next and choose a folder in which Xcode should create a 'Dice' folder for the project.

Import images into the Xcode project

  1. Download assets.zip which contains images for the project and uncompress the archive. Open Assets.xcassets in the Xcode project and drag the images for the dice into the project:

  2. Add icon_60pt@2x.png and ..@3x.png as iPhone app icon:

Edit the storyboard and add UI elements to the view controller

  1. Open Main.storyboard. You'll see the Initial View Controller of the app with an empty View:

  2. Use the Library to add a Image View and a Button to the view (hint: you can search in the library by name). Double click or drag it from the library to the storyboard:

  3. Place them like this:

  4. Select the image view and choose one of the dice images from the Attributes Inspector. Use Editor » Size to Fit content⌘= to resize the view to the size of the image:

  5. For the button, set 'Roll!' as title:

Create layout constraints

To center the views on all device sizes, use a Stack View and Auto Layout constraints:

  1. Select both views and use Embed in » Stack View to create a Stack View that stacks both views vertically:

  2. Use Add Alignment constraints to create constraints that center the view horizontally and vertically in the container:

  3. Use View as to switch to another device size and check if the layout still looks good:

Handle button taps with actions and outlets

  1. Select the View Controller object and open the Identity Inspector. The class specified here contains the code responsible for managing the views of the controller:

  2. Open the assistant editor to show the code next to the storyboard editor:

  3. Drag with Ctrl pressed down / with the right mouse key from the Image View into the code of the class to create a new Outlet property that can be used to refer to the view in the code:

    Name the outlet diceImageView:

  4. Drag with Ctrl pressed down / with the right mouse key from the Button into the body of the class to create a new Action method that is called when the Button is tapped:

    Name the action method rollDice:

Writing code to roll the dice

  1. The view controller class should look like this now:

  2. Inside the rollDice method, use the range feature of Swift to generate a random number. Keep the generated number as a constant declared with let:

  3. Check the returned type by -clicking the number constant:

    The type is an Optional type Int?. In this case, the method always returns a value, but randomElement() could return nothing (nil) if it is called on an empty list.

  4. Use the force unwrap operator! to unwrap the optional - this can be used here because we can be 100% sure that there will always be a value and the method will never return nil:

  5. Load the image using UIImage(named: ..). You can use (..) to insert a value into a string and load an image by name (the images are named dice-1, dice-2, ..):

Running the app in the Simulator

How to run app on iphone xcode settings

The following is a conceptual illustration of the iOS development process, including the connection to an iOS device:

Steps to Run Your Application on an iOS Device

Connect your iOS device to your Mac with an Apple USB cable
  1. Run the Platform Assistant on the Mac.
  2. Test the connection to your Mac (on the Connection Profile Manager page).
  3. Connect an iOS device (such as an iPhone or an iPad) to your Mac using the Apple standard USB cable (illustrated on the right).
    Note:
    • Only one iOS device should be connected to the Mac at one time.
    • In some cases, your iOS SDK version does not need to match the iOS device version. For example, you can build your app with the iOS 6.x SDK, and your app can run on a 5.x device.
  4. In RAD Studio:
    1. In the Project Manager, expand the Target Platforms node and double-click the iOS Device target platform to select that platform. The selected target platform is displayed using a bold font.
    2. In the Target Platforms node, expand the iOS Device node, expand the Configuration node, and double-click the Debug platform configuration to select it. The selected platform configuration is displayed using a bold font.
      Note: You cannot run applications directly from RAD Studio into an iOS Device if you build them with the Ad hoc or the Application Store platform configurations. To run applications deployed for ad hoc distribution, see Deploying Your iOS Application for Ad hoc Distribution. To run applications built for the App Store, you must install them from the App Store.
    3. Run your application, either with debugging (Run > Run) or without debugging (Run > Run Without Debugging).

RAD Studio builds your application using the SDK you previously added to the IDE, connects to your Mac using the connection profile you configured for the iOS Device platform, and the Platform Assistant on the Mac launches your application on the connected iOS device.

Note: RAD Studio might look frozen at some points until it launches your application on your iOS device, but it is just preparing to run your application.

Troubleshooting

For 'Device connection timeout,' please connect your iOS device to your Mac

If your iOS device is not connected, you see the following message in the IDE after you attempt to launch your app on an iOS device: How to install google chrome os on my laptop.

If you see this message, do the following:

  1. Dismiss the message.
  2. Connect your iOS device to the Mac using an Apple USB cable (shown above).
  3. Run your app again from the IDE. See the steps given above.
Note: The PAServer command-line utility allows you to set a device connection timeout using the -devicetimeout=. However, setting a different device timeout value does not solve the problem in the case of a missing iOS device.

'Unable to locate DeviceSupport directory matched with connected device info'

How To Run App On Iphone Xcode Settings

If you have recently upgraded the iOS version of your device, you might get the error message above when you try to run your application on your iOS device. If you see this message, do the following:

  1. Dismiss the message.
  2. On the Mac, open Xcode.
  3. Select Window > Organizer and determine whether Xcode recognizes your device:
    • If Xcode recognizes your device, let Xcode re-import your device support information, and try running your application from RAD Studio again.
    • If Xcode does not recognize your device, you must upgrade Xcode.
      Note: Alternatively, if Xcode does not recognize your device, but you do not want to upgrade Xcode in your Mac, you may try connecting your device to a different Mac which does have an upgraded version of Xcode that recognizes your device. After you let a newer version of Xcode re-import your device support information, an older version of Xcode might recognize your upgraded iOS device as well.

Nothing Shows Up in the iOS Device

If after you follow the steps to run your application on an iOS device, the application does not show up in your iOS device, check the following:

  • The Platform Assistant must be running on the Mac. See Running the Platform Assistant on a Mac:
  • On RAD Studio, the connection profile associated with the iOS Device target platform must connect with the target instance of the Platform Assistant.
    • See Activating and Configuring the Target Platform for instructions on how to configure the connection profile associated with the iOS Device target platform in your project.
    • On the Tools > Options > Environment Options > Connection Profile Manager page:
      • Select the connection profile associated with the iOS Device target platform from the left-hand column (which lists the available connection profiles, grouped by platform).
      • Check the values of that connection profile, such as the IP address (it must be your Mac's IP address) and the port number (it must be the Platform Assistant's port number).
      • Click Test Connection to ensure your development PC has a working connection to the Platform Assistant that is running on the Mac.
  • Only one iOS device should be connected to the Mac at one time.

My App Does Not Stop at Breakpoints Anymore

After a crash during a debugging session on an iOS device, it might happen that the next debugging sessions do not work anymore on your iOS device.

If when you run with debugging symbols your application runs but never stops at any breakpoint, do the following:

  1. On your Mac, launch Xcode.
  2. On Xcode, create a new iOS application.
  3. With your new Xcode iOS application open, select iOS Device as your target.
  4. Click and hold Run, and select Analize from the context menu that appears.

You can now close Xcode and continue using your iOS device to debug RAD Studio applications.

See Also

February 13, 2020

Goal

Build an iPhone app to roll a dice:

Objectives

This tutorial will show you how to:

Requirements

For this tutorial no previous knowledge of Swift / Xcode is required. To develop iOS apps for the iPhone/iPad using Xcode 11, you'll need a Mac running at least macOS 10.14 Mojave.

Xcode For Iphone

Install Xcode and create a new iOS project

  1. Open the App Store app and install the latest Xcode:

  2. Start Xcode and check your Xcode version on the welcome screen:

  3. If you already know how to create Xcode projects and import image assets, take a shortcut and download the starter project Dice-starter.zip with the images already set up and skip to adding the UI views.

  4. Run Xcode and create a new project with File » New » Project⌘⇧N. Select iOS » Application » Single View Application:

  5. Configure the project settings:

    • Name the app 'Dice'.
    • Use com.example as Company Identifier. This should be a domain name you own to prevent naming conflicts; feel free to use your own domain name.
    • Choose Swift as Language.
    • Choose Storyboard as User Interface technology.
    • Uncheck Use Core Data and Include Tests (which are not needed for this tutorial):
  6. Confirm with Next and choose a folder in which Xcode should create a 'Dice' folder for the project.

Import images into the Xcode project

  1. Download assets.zip which contains images for the project and uncompress the archive. Open Assets.xcassets in the Xcode project and drag the images for the dice into the project:

  2. Add icon_60pt@2x.png and ..@3x.png as iPhone app icon:

Edit the storyboard and add UI elements to the view controller

  1. Open Main.storyboard. You'll see the Initial View Controller of the app with an empty View:

  2. Use the Library to add a Image View and a Button to the view (hint: you can search in the library by name). Double click or drag it from the library to the storyboard:

  3. Place them like this:

  4. Select the image view and choose one of the dice images from the Attributes Inspector. Use Editor » Size to Fit content⌘= to resize the view to the size of the image:

  5. For the button, set 'Roll!' as title:

Create layout constraints

To center the views on all device sizes, use a Stack View and Auto Layout constraints:

  1. Select both views and use Embed in » Stack View to create a Stack View that stacks both views vertically:

  2. Use Add Alignment constraints to create constraints that center the view horizontally and vertically in the container:

  3. Use View as to switch to another device size and check if the layout still looks good:

Handle button taps with actions and outlets

  1. Select the View Controller object and open the Identity Inspector. The class specified here contains the code responsible for managing the views of the controller:

  2. Open the assistant editor to show the code next to the storyboard editor:

  3. Drag with Ctrl pressed down / with the right mouse key from the Image View into the code of the class to create a new Outlet property that can be used to refer to the view in the code:

    Name the outlet diceImageView:

  4. Drag with Ctrl pressed down / with the right mouse key from the Button into the body of the class to create a new Action method that is called when the Button is tapped:

    Name the action method rollDice:

Writing code to roll the dice

  1. The view controller class should look like this now:

  2. Inside the rollDice method, use the range feature of Swift to generate a random number. Keep the generated number as a constant declared with let:

  3. Check the returned type by -clicking the number constant:

    The type is an Optional type Int?. In this case, the method always returns a value, but randomElement() could return nothing (nil) if it is called on an empty list.

  4. Use the force unwrap operator! to unwrap the optional - this can be used here because we can be 100% sure that there will always be a value and the method will never return nil:

  5. Load the image using UIImage(named: ..). You can use (..) to insert a value into a string and load an image by name (the images are named dice-1, dice-2, ..):

Running the app in the Simulator

  1. Select an iPhone Simulator for the Scheme and hit Run ⌘R:

  2. The app starts up in the Simulator - test to roll the dice:





broken image