Programing

Xcode 프로젝트 및 관련 폴더를 복제하고 이름을 바꿉니다.

lottogame 2020. 5. 12. 07:54
반응형

Xcode 프로젝트 및 관련 폴더를 복제하고 이름을 바꿉니다.


전체 Xcode 프로젝트를 복제하고 Xcode가 마음에 들지 않고 프로젝트로 모든 파일을 수동으로 다시 가져올 필요없이 프로젝트 및 관련 파일의 이름을 바꾸고 싶습니다.


이 답변은 인터넷을 중심으로 한 다른 StackOverflow 게시물과 자습서를 마무리하여 나중에 참조 할 수 있도록 한 곳으로 가져 와서 같은 문제에 직면 할 수있는 다른 사람들을 도울 수 있습니다. 마지막에 다른 답변에 대한 모든 크레딧이 제공됩니다.

Xcode 프로젝트 복제

  • Finder에서 프로젝트 폴더를 새 프로젝트의 원하는 위치에 복제하십시오. 이 단계에서 .xcodeproj 파일 이름 또는 관련 폴더의 이름을 바꾸지 마십시오.

  • Xcode에서 프로젝트 이름을 바꿉니다. 네비게이터 분할 창 (왼쪽 분할 창)에서 프로젝트를 선택하십시오. 유틸리티 분할 창 (오른쪽 분할 창)에서 프로젝트 이름을 바꾸고 Xcode가 제안한 변경 사항을 승인하십시오.

  • Xcode에서 "구성표 관리"의 구성표 이름을 바꾸고 사용 가능한 대상의 이름도 바꾸십시오.

  • 마지막에 현재 PRODUCT_NAME이 포함 된 기본 번들 식별자를 사용하지 않는 경우 (자동으로 업데이트 됨) 번들 식별자를 복제 된 프로젝트에 사용할 새 식별자로 변경하십시오.

소스 폴더 이름 바꾸기

따라서 위의 단계를 수행 한 후에는 성공적으로 빌드하고 컴파일해야하는 중복되고 이름이 바뀐 Xcode 프로젝트가 있어야하지만 소스 코드 폴더의 이름은 여전히 ​​원래 프로젝트에서와 동일하게 지정됩니다. 이로 인해 컴파일러 문제가 발생하지는 않지만 SCM 등을 탐색하는 사람들에게는 가장 명확한 파일 구조는 아닙니다. 모든 파일 링크를 끊지 않고이 폴더의 이름을 바꾸려면 다음 단계를 수행하십시오.

  • Finder에서 소스 폴더의 이름을 바꾸십시오. Xcode는 변경 사항을 자동으로 감지하지 않기 때문에 프로젝트가 중단됩니다. 모든 xcode 파일 목록은 실제 파일과의 연결이 끊어 지므로 모두 빨간색으로 바뀝니다.

  • Xcode에서 이름을 바꾼 가상 폴더를 클릭하십시오 (실제로 .xcodeproject 바로 아래에있을 것입니다) Finder의 이름과 일치하도록 이름을 바꾸십시오. 이것은 아무것도 수정하지 않으며 엄격하지 않습니다. 필수 단계이지만 파일 이름이 일치하는 것이 좋습니다.

  • Xcode의 탐색 창에서 방금 이름을 바꾼 폴더를 선택하십시오. 그런 다음 유틸리티 창 (맨 오른쪽)에서 '위치'드롭 다운 메뉴 바로 아래에 어두운 회색 폴더 모양의 아이콘을 클릭하십시오. 여기에서 파인더의 이름이 바뀐 폴더로 이동하여 '선택'을 클릭하십시오. 이렇게하면 모든 파일이 자동으로 다시 연결되며 Xcode 탐색 창에서 더 이상 빨간색으로 표시되지 않습니다.

클릭 아이콘

  • 프로젝트 / 대상 빌드 설정에서 이전 폴더 이름을 검색하고 찾은 항목의 이름을 수동으로 바꿉니다. 일반적으로 prefix.pch와 info.plist에 하나가 있지만 더있을 수 있습니다.

  • 타사 라이브러리 (Testflight / Hockeyapp / etc)를 사용하는 경우 'Library Search Paths'를 검색하고 여기에서 이전 파일 이름의 이름도 바꾸어야합니다.

  • 프로젝트에 포함될 수있는 모든 단위 테스트 소스 코드 폴더에 대해이 프로세스를 반복하십시오. 프로세스는 동일합니다.

이를 통해 xcode 파일을 수동으로 편집하지 않고도 xcode 프로젝트 및 모든 관련 파일을 복제하고 이름을 바꿀 수 있으며 엉망이 될 수 있습니다.

크레딧

이 문제에 대한 별도의 답변을 제공해 주신 Nick LockwoodPauly Glott 에게 많은 감사를드립니다 .


I'm posting this since I have always been struggling when renaming a project in XCode.

Renaming the project is good and simple but this doesn't rename the source folder. Here is a step by step of what I have done that worked great in Xcode 4 and 5 thanks to the links below.

REF links:
Rename Project.
Rename Source Folder and other files.

1- Backup your project.

If you are using git, commit any changes, make a copy of the entire project folder and backup in time machine before making any changes (this step is not required but I highly recommended).

2- Open your project.

3- Slow double click or hit enter on the Project name (blue top icon) and rename it to whatever you like.

NOTE: After you rename the project and press ‘enter’ it will suggest to automatically change all project-name-related entries and will allow you to de-select some of them if you want. Select all of them and click ok.

4- Rename the Scheme

a) Click the menu right next to the stop button and select Manage Schemes.

b) Single-slow-click or hit enter on the old name scheme and rename it to whatever you like.

c) Click ok.

5 - Build and run to make sure it works.

NOTES: At this point all of the important project files should be renamed except the comments in the classes created when the project was created nor the source folder. Next we will rename the folder in the file system.

6- Close the project.

7- Rename the main and the source folder.

8- Right click the project bundle .xcodeproj file and select “Show Package Contents” from the context menu. Open the .pbxproj file with any text editor.

9- Search and replace any occurrence of the original folder name with the new folder name.

10- Save the file.

11- Open XCode project, test it.

12- Done.


As of XCode 7 this has become much easier.

Apple has documented the process on their site: https://developer.apple.com/library/ios/recipes/xcode_help-project_editor/RenamingaProject/RenamingaProject.html

Update: XCode 8 link: http://help.apple.com/xcode/mac/8.0/#/dev3db3afe4f


I am using this script after I rename my iOS Project. It helps to change the directories name and make the names in sync.

http://github.com/ytbryan/rename

NOTE: you will need to manually change the scheme's name.


In the example code for the book "Instant OpenCV for iOS" I have found a bash script that copies a project from a folder to another.
Doing a little research I've found a blog post from what seems to be the original author of the script: http://mohrt.blogspot.it/2009/01/renaming-xcode-project-from-command.html, where you can download the script. I gave it a try and running it from terminal like this

    sh renameXcodeProject.sh <name-of-existing-folder> <name-of-folder-to-create>   

works fine.
Additional info can be found opening the file with a text editor. Hope that helps


I using Xcode 6+ and I just do:

  • Copy all files in project folders to new Folders (with new name).
  • Open *.xcodeproj or *.xcworkspace
  • Change name of Project.
  • Click on schema and delete current chema and add new one.

Here is done, but name of window Xcode and *.xcodeproj or *.xcworkspace still <old-name>. Then I do:

  • pop install
  • Open <new name>.xcworkspace

One more thing to try!

When I copied all of my files, opened the project, and renamed it, everything changed to my new project name except for the test target! I got a linker error that said I was missing a file called "myOldProjectname.app". Here's what fixed it:

  1. Click on your project settings and select your test target 여기에 이미지 설명을 입력하십시오

  2. Click on build settings and search for "test host" 여기에 이미지 설명을 입력하십시오

  3. Check those 2 file paths. Chances are that those 2 paths are still pointing at your old project name. 여기에 이미지 설명을 입력하십시오

Hope that helps!


For anybody else having issues with storyboard crashes after copying your project, head over to Main.storyboard under Identity Inspector.

다음으로 현재 모듈이 이름이 바른 올바른 모듈인지 확인하십시오.


이름을 바꾸기 위해 간단한 BASH 스크립트를 사용하고 있습니다.

용법: ./rename.sh oldName newName

#!/bin/sh

OLDNAME=$1
NEWNAME=$2

export LC_CTYPE=C 
export LANG=C
find . -type f ! -path ".*/.*" -exec sed -i '' -e "s/${OLDNAME}/${NEWNAME}/g" {} +

mv "${OLDNAME}.xcodeproj" "${NEWNAME}.xcodeproj"
mv "${OLDNAME}" "${NEWNAME}"

노트:

  1. 이 스크립트는 같은 모든 파일을 무시 .git하고.DS_Store
  2. 이전 이름 ​​/ 새 이름에 공백이 있으면 작동하지 않습니다
  3. 포드를 사용하면 작동하지 않을 수 있습니다 (테스트되지 않음)
  4. 구성표 이름이 변경되지 않습니다 (어쨌든 프로젝트가 실행되고 정상적으로 컴파일 됨)

참고 URL : https://stackoverflow.com/questions/17744319/duplicate-and-rename-xcode-project 관련 폴더

반응형