Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Saturday, February 13, 2021

How to run an Xcode project on an iOS device without payment for the US$99 Apple Developer account (2021)

To run an Xcode project on an iPhone/iPad without paying US$99 for Apple Developer account, this error message may happen:

Your development team has reached maximum number of registered iPhone devices.

According to StackOverflow, I got this warning because I have a previous paid account but I cannot configure it at this stage. So I register a new and free Apple Developer account. and add it to Xcode with Preferences->Accounts.

The project with Xcode 11.6 is configured as below:


After selecting the new Apple Developer account as the team and making sure that the bundle identifier is new, the deployment becomes successful!

References:

Development team has reached maximum number of registered iPhone devices (StackOverflow)

How to Test iOS App without Developer Account?

Run an Xcode project on an iOS device without US$99 Apple Developer account (Configuration for iPhone) (StudySwift)

Saturday, August 5, 2017

Run an Xcode project on an iOS device without US$99 Apple Developer account (Configuration for iPhone)

Since iOS 9, it is possible to install the app of an Xcode project to an iOS device without paying for a US$99 Apple Developer account. The steps to download the app to an iPhone/iPad are demonstrated with an iOS 10 device as below:

When press the build and run button of Xcode:

You may see a Could not launch "deviceName" dialog like this:


So follow the instruction on the Xcode dialog to select General -> Profiles & Device Management on the iOS device (iPhone/iPad).


Select the device.
Select "Trust (Apple ID)".
 Select "Trust".

Then the app should run on the iPhone / iPad.

For more information about Xcode configuration, see this:

Monday, August 22, 2016

Xcode Tip: A powerful hotkey/shortcut to format the indentation of multiple lines

To quickly format the code indentation, simply:

1. Select the text to be adjusted.
2. press (control) + (i) .

Animated example of the (control) + (i)  hotkey:




The (control) + (i) behaviour is the same as the Editor -> Structure -> Re-Indent selection.



Related Information:

Fix code indentation in Xcode
Xcode Tip: Hotkeys/Shortcuts to move multiple lines horizontally (command ⌘) + ( [ ) or ( ] ) 
Xcode Tip: Comment Hotkey/Shortcut

Monday, July 25, 2016

iOS Simulator Tip: Map Zoom/Orientation Adjustment Hotkey

To adjust the zoom/orientation for a map in the iOS simulator, simply hold the option/alt key and two gray circles should appear on the map. Then simple click and drag the mouse to zoom in/zoom out or rotate the map.


Tuesday, July 5, 2016

Xcode Tip: Manage Apple ID with Xcode

To add/remove Apple IDs to Xcode, follow these steps:

1. Run Xcode.


2. Select Xcode->Preferences


3.Select Accounts ->  + sign -> Add Apple ID

4. Enter the Apple ID (email address) and password. Select Sign In.



5. The account information of the Apple ID is shown. You should see the team and role information as below.


Friday, May 13, 2016

Xcode Tip: Comment Hotkey/Shortcut

To put comment characters // in front of multiple lines in Xcode, highlight the area required and press:

[command ⌘] + [/]



This technique also works with IBM Swift Sandbox.

Related Information:

Xcode Tip: Hotkeys/Shortcuts to move multiple lines horizontally
Xcode Tip: Hotkey/Shortcut to format the indentation of multiple lines

Thursday, May 12, 2016

Swift Tip: Prevent code execution using #if false and #endif

To disable several lines of code in Swift, a useful method alternative to comment characters /* and */ is to use the # (number/hash/pound) sign plus if false and endif as below:

#if false
...
....code to be disabled....
... 
#endif

For example:

print("123")
#if false
print("456")
#endif

Result:

123

Tuesday, May 10, 2016

How to call functions in a separate Swift file

Update - May 22, 2017. The code below still works with Xcode 8.3.1 (Swift 3.1).

The code below shows how to call functions in a separate Swift file. Xcode 7.3 (Swift 2.2) is used. Two examples are shown in the following steps:

1. Create a new Swift file with any name such as MyFile.swift.

2. Modify the file as:


import Foundation

//Example 1
class MyClass {
    func myFun() {
        print("myFun!!")
    }
    static let myInstance = MyClass()
}

//Example 2
class AnotherClass {
    class func anotherFun() {
        print("anotherFun!!")
    }
}

3. Modify ViewController.swift as:


import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        MyClass.myInstance.myFun()
        
        AnotherClass.anotherFun()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

Result of Debug Console:


myFun!!

anotherFun!!

Wednesday, May 4, 2016

Xcode Tip: Hotkeys/Shortcuts to move multiple lines horizontally

I tried to move/shift multiple lines horizontally in Xcode, but the tab key did not work. The solution is to select the lines to be moved and hit the following keys:

(command ⌘) + ( ] ) => Right / Indent

(command ⌘) + ( [ ) => Left / Un-indent



To indent a section automatically with a single (control) + (i) short cut, see Xcode Tip: A powerful hotkey/shortcut to format the indentation of multiple lines.




Related Information:

How can I indent multiple lines in xcode?
Xcode Tip: A powerful hotkey/shortcut to format the indentation of multiple lines (control) + (i)
Xcode Tip: Comment Hotkey/Shortcut

Tuesday, March 15, 2016

Xcode Tip: Screenshot for iOS/tvOS device/simulator

To capture the screen of an iPhone/iPad/Apple TV connected to a Mac or the screen of the iOS/tvOS simulator, try the following instructions:

iOS/tvOS Device

Method 1

Select Xcode -> Debug -> View Debugging -> Take Screenshot of (device name)


Method 2

Select Xcode -> Window -> Devices


Select your device -> Take Screenshot


A screenshot PNG file will be stored to the desktop.

iOS/tvOS Simulator

Select Simulator -> File -> Save Screen Shot




or hold these two keys: [Command] + [S]

A screenshot PNG file will also be stored to the desktop.

==================

iOS/tvOS Device without a Mac

If you want to make a screen capture of an iPhone/iPad without connecting to a Mac, hold the [Sleep/Wake (Power)] button and press and release the [Home] button.

An image of the device screen will be saved in Photos app.