Xcode 에서 C# 개발 환경 구축하기

2023. 6. 7. 15:37XCODE

1.https://brew.sh/ 에 접속해 터미널을 이용해 homebrew를 설치한다.

2.터미널에 export PATH=/opt/homebrew/bin:$PATH를 입력한다

cf)1을 한 후에 터미널에 'brew install mono 를 입력하고 엔터를 칠 시

command not found 라고 뜨면 2를 행해야 하고 그렇지 않으면 2를 건너뛰어도 된다.

3.'brew install mono' 을 터미널에 입력해 mono 를 설치해준다.

4.터미널에 where mcs 라고 입력한다

5. /opt/homebrew/bin/mcs를 인지하자.

6.Xcode 에서 create a new xcode project 를 누른다

7. other 칸에 external build system 을 누른다

8.product name 과 organization identifier 에 마음에 드는 단어(나의 경우는 boongtol_C#)를 쓰고(일치시키면 좋음) build tool 칸에 5번에서 인지한 경로를 그대로 입력한다. 그리고 바탕화면에 저장한다.(create git repository on my mac 은 체크헤제한다.) 그리고 프로젝트 파일 안에서 targets 란에 arguments란에 원래 써져있던 글을 지우고 $(ACTION) $(TARGETNAME).cs 를 입력한다.

9. 왼쪽 상단에 file 란에서 new--->file 을 클릭한다. 

10. mac os 란에서 other---> empty 를 클릭한다.

11. 파일 이름을 치라고 뜰텐데 파일 이름에 8번에서 일치시키면 좋다던 단어에다가 .cs 추가해 이름을 짓는다.

12. xcode에 product 란에 scheme---> edit scheme에 들어간다.

13. Run 란에 info 탭에 들어가 executable--->other 을 누른 후 command, shift, G 를 동시에 누른다.

14. /opt/homebrew/bin/mono (터미널에 where mono를 입력했을때 얻어지는 문장)를 입력한다

15. mono라는 이름을 가진 unix executable file 을 선택한다.

16. 이제 arguments 탭에 들어가서 arguments passed on launch 에서 +를 누른다.

17. 8번에서 이름을 지었던 파일 이름을 입력한다.(나의 경우에는 boongtol_C#.exe)

18. arguments 탭에서 enviroment variables 에서 +를 누른다.

19. Name 란에 CLASSPATH 라고 적고 , Value 란에 8번에서 바탕화면에 저장한 폴더 내부에 있는 java 파일의 경로를 적는다.

     (나의 경우에는 /Users/boongtol/Desktop/boongtol_C#/boongtol_C#.cs )

20. options 란에 working directory 에서 use custom working directory 밑에 있는 폴더 모양의 아이콘을 클릭한다.

21. 8번에서 바탕화면에 만든 폴더를 찾아 더블클릭해준다.

22. 이제 설정은 끝났다. 프로그램이 정상 작동해야 한다!

cf)error: source file not found: boongtol_C#.cs

     Program ended with exit code: 1 

 에러가 뜰 시 터미널에서 pwd를 입력해 얻은 위치에 8번에서 저장한 폴더를 복사(이동)하고 19번에서의 Value 란에 pwd를 입력해 얻은 위치/boongtol_java/boongtol_C#.cs(나의 경우에는)

즉 나의 경우에는(/usr/local/bin/boongtol_C#/boongtol_C#.cs)이 된다. 또, 20번에 적은대로 하지 말고 pwd를 입력해 얻은 위치에 있는 나의경우(boongtol_C#)폴더를 선택해줘야 한다.

 

 

Building a C# Development Environment in Xcode

 

1. Go to https://brew.sh/ and install the homebrew using the terminal.
2. Enter export PATH=/opt/homebrew/bin:$PATH in the terminal
After cf)1, type 'brew install mono' in the terminal and hit the enter
If command not found appears, you have to do 2 or you can skip 2.
3. Enter 'brew install mono' in the terminal to install mono.
4. Type where mcs in the terminal
5. Recognize /opt/homebrew/bin/mcs.
6.In Xcode, press create a new xcode project
7. Press external build system in the other column
8. Write your favorite word (boongtol_C# in my case) in the product name and organization identifier, and enter the path recognized in number 5 in the build tool box. And save it on the desktop.(create git repository on my mac is checked.) In the project file, erase the text originally written in the targets column and the arguments column, and then $(ACTION)$(TARGETNAME).Enter cs.
9. Click new--->file in the file column in the upper left corner. 
10. Click other--->empty in the macos column.
11. It will say to type the file name, but I name it by adding .cs to the word that matches the file name at number 8.
12. In the xcode, enter the "product" section into the "system---> edit" scheme.
13. Enter the info tab in the Run column, press executable--->other, and then press command, shift, and G at the same time.
14. Enter /opt/homebrew/bin/mono (a sentence obtained by entering where mono in the terminal)
15. Choose a Unix executable file named mono.
16. Now enter the arguments tab and press + under arguments passed on launch.
17. Enter the name of the file you named in number 8.(In my case, boongtol_C#.exe)
18. On the arguments tab, under environment variables, press +.
19. Write CLASSPATH in the Name column and java file path in the folder saved on the desktop in number 8 in the Value column.
     (나의 경우에는 /Users/boongtol/Desktop/boongtol_C#/boongtol_C#.cs )
20. Click the folder icon under use custom working directory in the options column.
21. Find the folder you created on the desktop in number 8 and double-click it.
22. Now the setup is over. The program should work properly!
cf)error: source file not found: boongtol_C#.cs
     Program ended with exit code: 1 
 If an error appears, copy (move) the folder saved in number 8 to the location obtained by entering pwd from the terminal and the location obtained by entering pwd in the Value column in number 19/boongtol_java/boongtol_C#.cs (in my case)
That is, in my case, it becomes (/usr/local/bin/boongtol_C#/boongtol_C#.cs). Also, instead of doing what you wrote in number 20, you should select the folder (boontgol_C#) in the position you obtained by entering pwd.