Friday, March 29, 2019

Xcode 10.2, Swift 5, iOS 12.2 Released

On March 25, 2019, Apple formally released Xcode 10.2 with Swift 5, iOS 12.2, and others. With the release available, it is time for me to update my app projects. The following are some issues I have encountered and I think it is worthwhile to take some notes.

Warnings and Errors


The update, as same as my previous experiences, presented some issues I have to deal with. The migration process does not resolve all the issues. I got about 69 errors and 50 warnings. Those are the issues I have to check and change one by one. Fortunately, most of them are just API's changes, and Xcode does provides enough hints to tell what have changed. For example method name changes, and constants changes.

Fatal Error with no Clue


After I manually migrated all those changes. I got no warnings, and no errors in my codes. However, I had this no-clue fatal error:

Command CompileSwiftSources failed with a nonzero exit code

As my project is so complex and has massive codes. I was lost at first. Where should I start to resolve the issue? Since the Xcode 10.2 and Swift 5 are quite new. I could not find direct or clear solution from web.

Even so, some people had similar issue in their project. I looked at their cases and solutions carefully. I have to say some of their analysis provide me lights out of dark. Finally, I got this issue resolved.

In the project settings, this was my previous setting in Build Settings -> Compilation Mode:



the setting is Incremental. I found one solution is to change this to Whole Module as in the following:




Then I continued to build my project. This time, I got serval errors, which could not be found in Incremental compilation mode. One error complains that override cannot be applied to method in extension.

Here I give a simplified example: a base class implementing a none-objc delegate in iOS SDK's framework. When I wrote this base class, I put all the delegate methods within an extension of the base class. I like to use the strategy to separate delegate implementation in the extension block. This is OK in Swift 4 and 5 versions.

There are some occasions, I need to override some of those methods in inheritance classes. In the inheritance class I continue to put those override methods in extension block. In the previous version of Swift, ie ver 4, it is OK. However, this is not allowed in Swift 5. In other words, the override none-objc methods cannot be defined in extension.

It seems that Xcode Incremental compilation could not be identified the issue. Each file can be built or compiled without any errors. However, in the later or integration stage of compilation, Xcode could not resolve integration of the base class and inheritance class, based on Swift 5 rules. This may be Xcode bug. Fortunately, Xcode could start reporting and explaining errors in Whole Module mode.

I moved codes from extension to its class body block, those errors are gone!

After the successful build, I changed the compilation mode back iOS recommended default Incremental mode again.


References


Read More...

Wednesday, March 06, 2019

Source Code Control and Task Management

I have been using Bitbucket on-line service as my iOS source code control for about one year. I really like this tool. As remove and online repository, it works very well, and I can use Xcode to check in & out my changes.

Another related tool is task management. I use Trello to log my tasks. Within Trello, I can manage several lists, such as todo, doing, and versions. Within each list, task can be added with comments. By using this great tool, I can add check change as a task, and move them over lists. In this way, I have overview of all my changes.

The good news is that all above on-line services are free, great for starter developers.

References


Read More...