Skip to content

Instantly share code, notes, and snippets.

@sampattuzzi
Last active August 23, 2017 15:21
Show Gist options
  • Save sampattuzzi/67351a844a597a13915a3ff6e4082988 to your computer and use it in GitHub Desktop.
Save sampattuzzi/67351a844a597a13915a3ff6e4082988 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import fileinput
import glob
import os
project_files = glob.glob("*.uproject")
if len(project_files) != 1:
print "We are not in the root of a project."
os.exit(-1)
project_name = project_files[0].replace(".uproject", "")
xcode_game_project_file = "./Intermediate/ProjectFiles/" + project_name + ".xcodeproj/project.pbxproj"
xcode_engine_project_file = "./Intermediate/ProjectFiles/UE4.xcodeproj/project.pbxproj"
replace_headers = False
for line in fileinput.input([xcode_game_project_file, xcode_engine_project_file], inplace=True, backup='.bak'):
line = line.replace("\n", "")
if "USER_HEADER_SEARCH_PATHS" in line and "(" in line:
assert not replace_headers
replace_headers = True
line = line.replace("(", '"')
print line
continue
if replace_headers and ");" in line:
replace_headers = False
line = line.replace(");", '";')
print line
continue
if replace_headers:
line = line.replace('"', r'\"')
line = line.replace(",", "")
print line

The solution given is a bit out of date. If you try to move the "Epic Games" directory to remove the space and symlink it, it will cause lots of errors when launching projects of generating XCode projects.

Just to recap, the problem is that Unreal generates the XCode project in the wrong format. It leads XCode to believe that the space in the path is indicating a new path. So XCode cannot find the files to index for autocomplete.

The least fragile thing to do is fix the XCode project itself. However, doing this manually is a pain as it's a very long list of include files. So I created a script that will update the project for you. Here's how to use it:

  1. Download the python file
  2. Save it at the root of you project.
  3. Open a terminal an cd to the project root.
  4. Run python ./fix_xcode_autocomplete.py
  5. Open the XCode workspace.
  6. Open the game project.
  7. Select the Project target -> "Build Settings" -> Double click "User Header Search Paths"
  8. Check the list is populated correctly and close by clicking away.

Your indexing should now begin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment