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, February 6, 2021

Xcode 11.6 (Swift 5.2.4) - Hello World and how to set the background color programmatically

 code:

import SwiftUI


struct ContentView: View {

    let screenWidth = UIScreen.main.bounds.width

    var body: some View {

        ZStack {

            Color.yellow

            .edgesIgnoringSafeArea(.all)

            Text("Hello, World!")

            

            Text("Study Swift")

            .position(CGPoint(x: screenWidth/2, y: 400))

            

        }

    }

}


struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}

Result:


Reference:


How to set a background color for the viewController in swiftUI? (StackOverflow)

Wednesday, September 30, 2020

Thursday, August 27, 2020

Mac Technique: Ctrl + Alt + Del command for Windows on Mac

For using the Ctrl + Alt + Del command for Windows with a Mac keyboard, hold the following keys:


Control + option (alt) + fn + delete


References:

Ctrl + Alt + Del on a Mac with Windows (superuser)

Mac Technique: Delete Key for Windows on Mac

Thursday, June 7, 2018

Complex numbers - simple calculations

This example is tested with Xcode 9.2 playground in Swift 4.0.3. Basic complex number calculations such as the magnitude are includes as below:


class ComplexNum {
    var real : Float
    var imag : Float
    
    init (real: Float, imag: Float){
        self.real = real
        self.imag = imag
    }
    func show()->String {
        let plusChar = (imag>0) ? "+" : "-"
        return "\(real) \(plusChar) \(abs(imag))i"
    }
    //Magnitude
    func mag()->Float {
        return sqrt(self.real*self.real+self.imag*self.imag)
    }
    //Quick calculation with (i)
    func multiplyPlusI(num:ComplexNum) -> ComplexNum{
        return ComplexNum(real: -num.imag, imag: num.real)
    }
    //Quick calculation with (-i)
    func multiplyMinusI(num:ComplexNum) -> ComplexNum{
        return ComplexNum(real: num.imag, imag: -num.real)
    }
}
func addComplex(a: ComplexNum, b: ComplexNum)->ComplexNum {
    return ComplexNum(real: a.real+b.real, imag: a.imag+b.imag)
}
func multiplyComplex(a: ComplexNum, b: ComplexNum)->ComplexNum {
    return ComplexNum(real: a.real*b.real-a.imag*b.imag, imag: a.real*b.imag+a.imag*b.real)
}

let x = ComplexNum(real: 3, imag: 1)
print("x = \(x.show())")
print("|x| = \(x.mag())")
print("x(j) = \(x.multiplyPlusI(num: x).show())")
print("x(-j) = \(x.multiplyMinusI(num: x).show())")

let y = ComplexNum(real: -1, imag: -2)
print("y = \(y.show())")
print("|y| = \(y.mag())")
print("y(j) = \(x.multiplyPlusI(num: y).show())")
print("y(-j) = \(x.multiplyMinusI(num: y).show())")

print("x + y = \(addComplex(a: x, b: y).show())")
print("x * y = \(multiplyComplex(a: x, b: y).show())")

Results:


x = 3.0 + 1.0i
|x| = 3.16228
x(j) = -1.0 + 3.0i
x(-j) = 1.0 - 3.0i
y = -1.0 - 2.0i
|y| = 2.23607
y(j) = 2.0 - 1.0i
y(-j) = -2.0 + 1.0i
x + y = 2.0 - 1.0i
x * y = -1.0 - 7.0i

Related Information:
Matlab: Real and imaginary parts of complex number and multiplication with imaginary unit j

Friday, April 6, 2018

Mac Technique: How to Enable the Hidden Security & Privacy Option to Allow Apps from Unidentified Developers

With macOS High Sierra 10.13.4, there is no option by default to allow apps from unidentified developers in  -> System Preferences -> Security & Privacy -> General:


Close the window and type the following command in terminal:

sudo spctl --master-disable

and enter your password. Now go back to and the previously hidden Anywhere option is displayed:


Note that if you change a more secure option, the Anywhere option is hidden again when you turn on the Security & Privacy window next time.

Monday, April 2, 2018

Mac Technique: Dr. Eye Chinese-English Bilingual Dictionary with macOS 10.13.4 譯典通英漢雙向字典

Dr. Eye (譯典通), a famous Chinese-English bidirectional dictionary, is now available free with macOS High Sierra 10.13.4.

After installing the latest version of macOS, select Dictionary -> Preferences and 譯典通英漢雙向字典(Traditional Chinese-English).


Now both English and Chinese words may be looked up in the dictionary:



It is interesting that the Bopomofo (ㄅㄆㄇㄈ) Zhuyin Mandarin Phonetic Symbols (注音符號) used in Taiwan are displayed in this dictionary.

The Dr. Eye dictionary is also available with iOS 11.3.