Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
You're the man Lloyd, thank you.

The program itself doesn't work in this old OS which is absolutely fine. I'm not asking for help to get it working on this old OS in any way. I'd just like to know if the error that was displayed looks normal, i.e. is this error confirmation that the program doesn't work just because the OS is old?

Also are there any software requirements needed to run a swift program? I just want to make sure that something unexpected or unusual hasn't happened.

View attachment 758770

It appears I misread your Macs OS version, I mistakenly read 10.9, which happens to be the cutoff for Swifts backwards compatibility. So you're one revision to far back for this solution to be of use.

My apologies for wasting your time, I learned several things so it was still of benefit to me.

I assume your Mac is not 64 bit capable and thus not updatable to a newer version of Mac OS or you would've done so, correct? But if that were true it should not have proceeded to run on your machine as far as it did!

EDIT: Would you mind sharing what Mac you're using? For instance the machine I am currently on is the iMac17,1
 
Last edited:
No no no, dude this is a SUCCESS!

I don't care care that it doesn't work on this old OS, it's useless to do that (although I would have liked to have run it to see it, but that's not really necessary).

If you can confirm that it DOES work on a normal updated mac this is 100% a job well done.

My mac is a VM, it was set to 64-bit prior to installation of the OS so I assume it is 64-bit. I followed this guide to do it.

VirtualBox (the VM software I'm using) does not support MacOS so you have use "hacks" to get it working. If the OS gets updated those boot hacks will stop working, so it has to remain on the version it is.
 
No no no, dude this is a SUCCESS!

I don't care care that it doesn't work on this old OS, it's useless to do that (although I would have liked to have run it to see it, but that's not really necessary).

If you can confirm that it DOES work on a normal updated mac this is 100% a job well done.

My mac is a VM, it was set to 64-bit prior to installation of the OS so I assume it is 64-bit. I followed this guide to do it.

VirtualBox (the VM software I'm using) does not support MacOS so you have use "hacks" to get it working. If the OS gets updated those boot hacks will stop working, so it has to remain on the version it is.

EDITED: (For hopefully better understanding)
The code I wrote works as designed based on the code you provided, but of course I don't have a compiled version of said code to compare the results against so I don't REALLY know.

The code you provided consists of a summing alphabetic substitution cypher algorithm, using 16 different substitution tables of a message of lower case characters and displaying the results in a 4 x 4 matrix.

It looks simple and straight forward, so I have no reason to believe it doesn't work - that's why I originally asked you to verify the encoding.

I gave you the phrase, and the resulting output of using the code I created, and asked you to verify in order to answer that question, so you're going to have to tell me.
 
Last edited:
Although the OP is resolved by rewriting the C# project in Swift, I thought it would be worth noting that Microsoft released Visual Studio for Mac last year. The requirements are El Capitan and up. Sierra (w/ Xcode 8.3+) is required for Xamarin project support.

Visual Studio can therefore compile C# code on a 10.11+ Mac.

https://www.visualstudio.com/vs/mac/
 
  • Like
Reactions: pier
Although the OP is resolved by rewriting the C# project in Swift, I thought it would be worth noting that Microsoft released Visual Studio for Mac last year. The requirements are El Capitan and up. Sierra (w/ Xcode 8.3+) is required for Xamarin project support.

Visual Studio can therefore compile C# code on a 10.11+ Mac.

https://www.visualstudio.com/vs/mac/
Mentioned in the first provided reply to this thread.

It turns out his interest in the requested solution wasn't real.

He was provided various solutions that would've worked but were seemingly to much trouble to install and test against in the VM running an older version of Mac OS that he had installed on his Windows box.

And for some as yet unspecified purpose
 
He was provided various solutions that would've worked but were seemingly to much trouble to install and test against in the VM running an older version of Mac OS that he had installed on his Windows box.

All solutions provided only work on a real mac.

Let me describe a recent "update" to this problem. I managed to find a guide on how to install macOS 10.13, Visual Studio installed fine on that, but simply wouldn't run. If it did I could just compile the source code myself, nice and simple.

Try to understand the reasons I am going through all this awkwardness, it's not by choice.
 
You still haven't told me if the work I did was correct on the last page. An input and output was provided you should be able to verify on your Windows development machine by inputing the provide word (your handle) eye-balling the results on your system vs mine and telling me yeah or nay.

Now it's good to know you're trying to go further and it wasn't shear laziness like so many I run across.

EDIT: <https://www.pcsteps.com/2157-mac-os-x-virtual-machine-vmware-player/>
 
Last edited:
I did verify the output but I was not clear about it it seems, my apologies. The numbers are correct though.

The program works on this 10.13 version of macOS, so I can confirm everything works.

Do you have any idea how to run visual studio from the terminal on mac? VS wont run, and I get no error. Someone suggested running it in the terminal to see the error but I don't know how to do it (what to type in the terminal).

Edit: I'm back to .Net Core SDK, it installs on this version. I'm going to see what I can do with it, but I think I need to combine the code into a single file. Could I paste the class code into the program.cs file right at the top? Or would it need to go in a specific place in the file?

Edit 2: Scratch that, the class would be pasted into the namespace containing the program class correct?

Edit 3: More progress, Visual Studio now works (no idea why but I aint complaining). So I copied my class code into the main program code. I put the cipher class above the program class, but there are build errors, specifically the program doesn't understand my class name, so I have put it in the wrong place I guess. The specific error is: "The type or namespace name 'Cipher' could not be found (are you missing a using directive or an assembly reference?) (CS0246)"

Edit 4: I'm on a roll here :D I got the program compiled successfully and built on the mac. But when I go into the project folder I don't know what I'm looking at, where do I find the actual program file that I can run?

Edit 5: Just to clarify, I can run the program fine from within VS, but I don't know how to run it outside of VS.
 
Last edited:
  • Like
Reactions: AphoticD
I did verify the output but I was not clear about it it seems, my apologies. The numbers are correct though.

Thank you for that!
[doublepost=1524492642][/doublepost]
Do you have any idea how to run visual studio from the terminal on mac? VS wont run, and I get no error. Someone suggested running it in the terminal to see the error but I don't know how to do it (what to type in the terminal).

Edit: I'm back to .Net Core SDK, it installs on this version. I'm going to see what I can do with it, but I think I need to combine the code into a single file. Could I paste the class code into the program.cs file right at the top? Or would it need to go in a specific place in the file?

Edit 2: Scratch that, the class would be pasted into the namespace containing the program class correct?

Edit 3: More progress, Visual Studio now works (no idea why but I aint complaining). So I copied my class code into the main program code. I put the cipher class above the program class, but there are build errors, specifically the program doesn't understand my class name, so I have put it in the wrong place I guess. The specific error is: "The type or namespace name 'Cipher' could not be found (are you missing a using directive or an assembly reference?) (CS0246)"

Edit 4: I'm on a roll here :D I got the program compiled successfully and built on the mac. But when I go into the project folder I don't know what I'm looking at, where do I find the actual program file that I can run?

Edit 5: Just to clarify, I can run the program fine from within VS, but I don't know how to run it outside of VS.


It's good to see some persistence.

Do you know about "Terminal.app" located in '/Applications/Utilities'?
 
Thank you for that!
[doublepost=1524492642][/doublepost]


It's good to see some persistence.

Do you know about "Terminal.app" located in '/Applications/Utilities'?

Well, if I understand you right, I do know how to open the terminal. But yes, I've been exploring and have had a look in that directory, and I see Terminal.app.
 
Last edited:
Well, if I understand you right, I do know how to open the terminal, I just don't know what to type in it. But yes, I've been exploring and have had a look in that directory, and I see Terminal.app.

Do a little exploration!

Within Terminal app get familiar with the commands

cd
ls

You can learn their syntax and parameters with the commands 'man cd' and 'man ls'.
'man' for manual.

Then I suggest locating and 'cd'ing into your C# project folder and doing a 'ls -alF' to display all files and directories in the project in an attempt to locate the generated executable.

In my instance of your utility named 'astralogic' the executeble shows up as -

-rwxr-xr-x 1 lloyd staff 9727856 Apr 16 22:11 astralogic*

The '-rwxr-xr-x' are the file access permissions and consists of three groupings from left to right of 'user', 'group' and 'everybody else'. The man for 'ls' should explain it all.

In this example '-rwxr-xr-x' far left 'rwx' says this file is readable, writable and executable by the currently logged-in user. Since it is executable with the name given within my project I know this is the end product of my development effort.
 
  • Like
Reactions: AphoticD
Edit 4: I'm on a roll here :D I got the program compiled successfully and built on the mac. But when I go into the project folder I don't know what I'm looking at, where do I find the actual program file that I can run?

Edit 5: Just to clarify, I can run the program fine from within VS, but I don't know how to run it outside of VS.
The answer to Edit 4's question will generally be found in the user guide for the app. If you haven't already bookmarked the online guide, you should probably do that.
https://docs.microsoft.com/en-us/visualstudio/mac/

Knowing how to use documentation effectively is an essential programming skill. The user guide should usually be the first thing consulted, not the last.


I found the following page by googling where does visual studio put a mac executable :
https://docs.microsoft.com/en-us/visualstudio/mac/compiling-and-building

The first section on that page shows how to change output path from within VS.


The answer to Edit 5's question is to use the output path in a Terminal window. Start by either writing down where the default output is, or setting it to a location you choose.

Next, in a Terminal window, copy and paste the complete pathname leading to the actual executable file. Then press the RETURN or ENTER key.

I usually keep a command and arguments in a text file. This makes it simple to select the whole line, then either copy and paste into a Terminal window, or drag the selected lines to a Terminal window and drop them.
 
Hmm... I'm wondering if I even did build an executable. In my debug and release folder I have the same five files listed below:

image_336.png


As you can see I also renamed the program. Are one of those the executable? I was expecting no filename extension for the file, like the one you built.

Within the project folder itself are two folders called "bin" and "obj" each one contains a "debug" and "release" folder. I listed the files in the "debug" folder that's in the "bin" folder.

In the "obj" folder, the "debug" and "bin" folder both contains the same files as each other again but in "obj" the files are different, shown below.

image_337.png
 
  • Like
Reactions: AphoticD
Hey Lloyd, I've done more research and it seems it's time to give this up. You've been a great help, but could you make one small change to the program you wrote in swift? Could you remove the error message "invalid characters entered" please? Invalid characters can just be ignored and not added in to the value. The way it is right now, single words can only be entered because typing a space causes that app to not produce output.
 
Sure here's the modified Swift 4.1 source file.

The source code has has been reduced in size but the compiled and zipped file is 200KB larger at 3.1MB and won't attatch saying it's to large.

Is there someplace I can place it for you?

Code:
//
//  main.swift
//
//  Astralogic
// <https://forums.macrumors.com/threads/how-to-compile-c-on-a-mac.2114710/>

import Foundation

extension String {
    func encrypt(using: String) -> UInt32 {

        let tables: [String: [UInt8]] = [
              "god":                  [  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38
                                      ,  39,  40,  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51]
            , "reverseGod":           [  51,  50,  49,  48,  47,  46,  45,  44,  43,  42,  41,  40,  39
                                      ,  38,  37,  36,  35,  34,  33,  32,  31,  30,  29,  28,  27,  26]
            , "masonic":              [  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45
                                      ,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58]
            , "reverseMasonic":       [  58,  57,  56,  55,  54,  53,  52,  51,  50,  49,  48,  47,  46
                                      ,  45,  44,  43,  42,  41,  40,  39,  38,  37,  36,  35,  34,  33]
            , "masterNumber":         [  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23
                                      ,  24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36]
            , "reverseMasterNumber":  [  36,  35,  34,  33,  32,  31,  30,  29,  28,  27,  26,  25,  24
                                      ,  23,  22,  21,  20,  19,  18,  17,  16,  15,  14,  13,  12,  11]
            , "masterBuilder":        [  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34
                                      ,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,  45,  46,  47]
            , "reverseMasterBuilder": [  47,  46,  45,  44,  43,  42,  41,  40,  39,  38,  37,  36,  35
                                      ,  34,  33,  32,  31,  30,  29,  28,  27,  26,  25,  24,  23,  22]
            , "vortex":               [   1,   2,   4,   5,   7,   8,  10,  11,  13,  14,  16,  17,  19
                                      ,  20,  22,  23,  25,  26,  28,  29,  31,  32,  34,  35,  37,  38]
            , "reverseVortex":        [  38,  37,  35,  34,  32,  31,  29,  28,  26,  25,  23,  22,  20
                                      ,  19,  17,  16,  14,  13,  11,  10,   8,   7,   5,   4,   2,   1]
            , "foundation":           [  44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56
                                      ,  57,  58,  59,  60,  61,  62,  63,  64,  65,  66,  67,  68,  69]
            , "reverseFoundation":    [  69,  68,  67,  66,  65,  64,  63,  62,  61,  60,  59,  58,  57
                                      ,  56,  55,  54,  53,  52,  51,  50,  49,  48,  47,  46,  45,  44]
            , "god2ndLevel":          [  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63
                                      ,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76]
            , "reverseGod2ndLevel":   [  76,  75,  74,  73,  72,  71,  70,  69,  68,  67,  66,  65,  64
                                      ,  63,  62,  61,  60,  59,  58,  57,  56,  55,  54,  53,  52,  51]
            , "god3rdLevel":          [  76,  77,  78,  79,  80,  81,  82,  83,  84,  85,  86,  87,  88
                                      ,  89,  90,  91,  92,  93,  94,  95,  96,  97,  98,  99, 100, 101]
            , "reverseGod3rdLevel":   [ 101, 100,  99,  98,  97,  96,  95,  94,  93,  92,  91,  90,  89
                                      ,  88,  87,  86,  85,  84,  83,  82,  81,  80,  79,  78,  77,  76]
        ]

        let message = self.trimmingCharacters(in: .whitespacesAndNewlines).lowercased().utf8
        let table   = tables[using]

        var value: UInt32 = 0
        for element in message {
            let index    = Int(UInt8(element) - UInt8(ascii: "a"))
            value      += UInt32(table![index])
        }

        return value
    }
}

let encryptors = [
      ("        God Cipher:", "god"                 ) //  0
    , ("          Rev. God:", "reverseGod"          ) //  1
    , ("           Masonic:", "masonic"             ) //  2
    , ("      Rev. Masonic:", "reverseMasonic"      ) //  3
    , ("     Master Number:", "masterNumber"        ) //  4
    , ("Rev. Master Number:", "reverseMasterNumber" ) //  5
    , ("    Master Builder:", "masterBuilder"       ) //  6
    , ("Rev. Master Number:", "reverseMasterBuilder") //  7
    , ("            Vortex:", "vortex"              ) //  8
    , ("       Rev. Vortex:", "reverseVortex"       ) //  9
    , ("        Foundation:", "foundation"          ) // 10
    , ("   Rev. Foundation:", "reverseFoundation"   ) // 11
    , ("       God Level 2:", "god2ndLevel"         ) // 12
    , ("  Rev. God Level 2:", "reverseGod2ndLevel"  ) // 13
    , ("       God Level 3:", "god3rdLevel"         ) // 14
    , ("  Rev. God Level 3:", "reverseGod3rdLevel"  ) // 15
]

let width  = String(UInt32.max).count
while ( true ) {
    let line = readLine(strippingNewline: true)
    if let line = line {
        let filtered = line.filter { "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".contains($0) }
        for (index, encryptor) in encryptors.enumerated() {
            let encrypted   = filtered.encrypt(using: encryptor.1)
            let lead        = (index % 4) == 0 ? "\n" : "    "
            let formatting  = lead + "%@%\(width)d"
            print(String(format: formatting, encryptor.0, encrypted), separator: "", terminator: "")
        }

        print("")
    }
}
 
Last edited:
  • Like
Reactions: AphoticD
For future reference Mono is your best bet, which is what Visual Studio for Mac probably uses in the background.

For future cross platform CLI projects it would be better to simply use Go which can cross compile to any OS from any OS (Linux, Mac, Windows).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.