About Swift3 NSA ApplicationMain

Asked 2 years ago, Updated 2 years ago, 70 views

I wanted to call python on Swift3, so I referred to the following site.
https://github.com/ndevenish/Site-ndevenish/blob/master/_posts/2016-06-20-using-python-with-swift.markdown

import Cocoa

NSA ApplicationMain (Process.argc, Process.unsafeArgv)

Error Type 'Process' has no member 'argc' in ProProcess.argc で.
Please help me.
All I had to do was create the main.swift file and write the code above.

swift python xcode swift3

2022-09-29 22:18

2 Answers

The article on the link says the date is 2016-06-20, so it seems like it was still an article before the official version of Swift3 was released.The link to Swift3 is not well embedded, but it should be here.

This is the code in your article.

import Cocoa

exit(NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv))

The Swift Standard Library Process class has been renamed from Swift3 to CommandLine.

CommandLine

I didn't read the details of the article, so I don't know why it had to be enclosed in exit().

Up to Swift3, there are quite a few changes depending on the version, so you should be very careful if you want to refer to Swift articles online.


2022-09-29 22:18

StackOverflow had a similar question:

Process does not have argc and is referenced in arguments.
CommandLine has argc.

According to the StackOverflow question, CommandLine was called Process in Swift2, so the description of Process.argc in the referenced URL is simply missing an update.
"If you point out ""There is a mistake"" on the reference GitHub, you may be pleased."


2022-09-29 22:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.