Adding an existing implementation file to an Xcode project will not work

When I write most of my code using MacVIM, I need to add new files to the Xcode project in order to compile them into an executable. However, today I included an implementation file (.m) that Xcode will not allow to add. It looks light gray in the corresponding search box, as if it was already included in the project, but when I try to build, I get a linker error stating that the symbol defined by this implementation file cannot be found. The corresponding header file can be added without problems.

Any idea what could cause this problem?

Btw. I deleted the previous version of the same file from the Classes tree earlier, as well as many others that were successfully added.

+3
source share
5 answers

I think I once saw a similar problem with the old version of Xcode. IIRC, as I decided, it was:

  • rename the source file (temporarily)
  • add renamed file to project
  • do "Save As ..." in the renamed file to return it to its original name
+4
source

The file is probably already present in your project, but not in the target you are creating. Use the "Detailed view" and "Search bubble" to find it, "Get information" and on the "Targets" tab of the information window, select the checkbox for the goal you are creating.

( ) , , , , .

0

, pbxuser .xcodeproj . , , . .

:

  • XCode

  • "" > " " . .

  • "..." .

0

Xcode 4, , :

1) " " ( myfile.m Xcode)

2) Click the menu item "View" => "Utilities" => "Show file inspector" (or use the shortcut "Alt + Command + 1")

3) There is one section "Target Membership", check the desired object

0
source

I fixed this by deleting the .xcuserstate file and restarting the project. I am using a workspace file for everything that is worth it.

You can find any and all link files through

grep -r -h [NameOfFileThatYouAreTryingToAdd] *

from the project directory.

0
source

Source: https://habr.com/ru/post/1743037/


All Articles