CATEGORY

App Developer

  • January 9, 2021

2 types of Life cycle of SwiftUI

SwiftUI has 2 types of lifecycle. UIKit App Delegate SwiftUI App This post says about these life cycles. Select the life cycle of app You can select the life cycle of app when you create the project. Xcode 12 added the life cycle option into the project options dialog. However, if you choose the template for the Multiplatform, this option will not appeared. Multiplatform template always use the SwiftUI App life cycle. UIKit App Delegate UIKit App Delegate use the UIKit to implement. The framework is different by OS. UIKit App Delegate – iOS/iPadOS/tvOS AppKit App Delegate – macOS WatchKit […]

  • January 3, 2021
  • January 3, 2021

Python: Output the log with logging module

It is general to export the log from the batch script which is executed periodically. The log is also useful to analyze the problem. You may insert the special log for debug to explore the reason of bug. The log is base facility to explore the reason of problem and recover from it. You can output the log from Python script with logging module. Simple Logging Most simple logging code is following. import logging logging.basicConfig(level=logging.INFO) logging.info("Most Simple Log. The Value is %d.", 10) Execute this script, the following log will be output. $ python3 demo.py INFO:root:Most Simple Log. The Value is […]

  • January 2, 2021
  • December 26, 2020

Python: Get the Command Line Argument with ArgumentParser

It is easy to get the command line argument of python shell script with ArgumentParser class. The ArgumentParser class has following functions: Get the positional required argument Get the optional argument Output the help If the script executed without required arguments, the ArgumentParser class abort the script. It is hard work to write above functions by yourself in your own script. Basic usage The basic code to use `ArgumentParser` class is following: import argparse # Allocate the parser parser = argparse.ArgumentParser() # Register arguments to the parser # Parse command line arguments # The result will be returned into the args variable. args […]

  • December 29, 2020
  • December 26, 2020

Supporting notarization services in the installer

If the application is packaged into the installer package and it is deployed, the installer package also need to support the Notarization Services. This article explains that how to support Notarization Services for the installer. Overview of How to make the installer The installer of macOS is created with following 2 steps. Create the component package with pkgbuild. Create the deployment installer with productbuild. If the deployment file is disk image format, the step to create the dmg file with hdiutils will be followed. And you will upload it to the Apple Notarization Services. Prerequirements of the Notarization In prerequirements […]

  • December 28, 2020
  • December 26, 2020

Introduction to Combine | Connecting to the Web Server with the Combine

This article explains that how to connect to the web server with the Combine. Create the Publisher of the DataTask Create the publisher of the data task to connect to the web server. Two methods are available to create it: func dataTaskPublisher(for: URL) -> URLSession.DataTaskPublisher func dataTaskPublisher(for: URLRequest) -> URLSession.DataTaskPublisher The first method has an argument “URL”. If you want to simply connect to the URL and GET the contents, you can use this method. The second method has an argument “URLRequest”. With “URLRequest”, you can set the method of the HTTP, the body data, the header value and so […]

  • December 27, 2020
  • December 26, 2020

Introduction to Combine | Supporting Combine in a custom class

Combine is a framework to implement asynchronous operations. It is created by Apple, it is also used in Swift Data Binding. It is an important framework. If you new to Combine, see next article. If you want other samples, see following articles. This article explains how to support Combine in a custom class. Adopt to ObservableObject protocol. To make a class to support Combine, adopt to ObservableObject protocol. To notify a changes of properties with Combine, mark the property with @Published attribute. class PlayerStatus : ObservableObject { @Published var name: String = "" @Published var hitPoint: Int = 100 } […]

  • December 26, 2020
  • December 26, 2020

Configure the project with Xcode to support Apple Notarization Service

March 6, 2020  In “How confirm the program satisfied requirements”, --strict option was missing, added it. There are some way to support Apple Notarization Service. From February 3, 2020, if the app want to be notarized, the app need to meet the original notarization prerequisites. This article describe that how to configure the project with Xcode. Notarization Prerequisites Notarization Prerequisites are following: All Executables are need to be code signed. Enable Hardened Runtime of all of the applications and the command line tools (CLI). Use “Developer ID Application Certificate”, “Developer ID Kernel Extension Certificate” or “Developer ID Installer Certificate” to […]

  • December 7, 2020
  • December 26, 2020

Tips for combining Objective-C and Swift

The applications have been used long time can not be written with only Swift. They ofter contains C/C++ or Objective-C codes. My mac application is also written with C/C++ and Objective-C. This post says that tips for combining Objective-C and Swift. Declare the code supports ARC If your code expects that is compiled with ARC, you should declare it. The following code reports the error when you compile without the ARC. #if !__has_feature(objc_arc) #error This source file must be compiled with ARC. #endif If you write the warning “This source file must be compiled with ARC” with the comment only, […]

  • December 4, 2020
  • December 26, 2020

Which class we should use? WKWebView or SFSafariViewController

UIWebViewClass was deprecated and we need to replace it with WKWebView or SFSafariViewController. Which class we should use? I think we use WKWebView normally, but SFSafariViewController has enough functionality in some case. Requirements It is decided which class can be used by requirements. You want to do something just before or after loading pages. You want to know the URL of loading pages. You want to execute JavaScript on loaded pages. If you want to do above, you need to use WKWebView. SFSafariViewController can not do above. Requirements are really needed? “We want to do something just after loading pages.”. […]

  • December 3, 2020
  • December 26, 2020

[2020/04/01 Up] [Swift/ObjC] How to replace UIWebView with WKWebView

According to post in Developer News And Updates on December 23, 2019, UIWebView class was deprecated and apps using it will be rejected. I wrote this change in post below. We should use WKWebView or SFSafariViewController instead of UIWebView. This post says how to replace UIWebView with WKWebView.

>Programming Tips From Software Engineer

Programming Tips From Software Engineer

Technical News, Documents and Tips.

CTR IMG