I'm getting a compile error in XCode where a file that I've removed from the project is showing up as a Duplicate Interface definition for class 'class_name' and it shows the hierarchy of dependencies and ultimately arrives at the header file of the class in question. But that header file doesn't actually exist in the project hierarchy. In the file location section above the header file's code it just shows class_name.h > #interface class_name rather than every other file in the project: project_name > group_name > class_name.h > No Selection
Doing a search for this object type (cmd+shift+O) and global search turn up no instance of this header file existing in the project. I've cleaned, exited xcode, rebooted, even checked the proj file for instances of this class, but it's not there.
I had the path to the old location of my class in my project's "Header Search Paths" so it was seeing the file twice.
First step: properly manage your xcode Header Search Path, delete the unused old Search path
Second step: choose product-->clean
Related
I am working with the Swift Package Manager. I have a project which I can successfully build via "swift build". I have created an Xcode project via "swift package generate-xcodeproj". When I open the project in Xcode it builds successfully.
The Xcode project includes two modules A and B.
Module A has the following map:
module ModuleA {
umbrella header "/Users/Robert/Temp/MyProject/Sources/ModuleA/include/ModuleA.h"
link "ModuleA"
export *
}
Module B depends upon A and has the following import:
import ModuleA
So far so good; everything builds successfully. Now I want to change the module map so that it uses a relative path, such as:
module ModuleA {
umbrella header "ModuleA.h"
link "ModuleA"
export *
}
However, when I do that I cannot get Module B to build: Error - Umbrella header 'ModuleA.h' not found. I have tried everything that I can think of in Build Settings -> Search Paths -> Header Search Paths and User Header Search Paths. I've found similar issues online, here and elsewhere, and have tried what I read but so far no go.
This has reached the hair pulling stage. Any advice will be much appreciated!
My guess is you're modifying the generated modulemap. Create a modulemap file at /Users/Robert/Temp/MyProject/Sources/ModuleA/include/module.modulemap containing:
module ModuleA {
umbrella header "ModuleA.h"
link "ModuleA"
export *
}
Run $ swift package clean to remove the old generated modulemap in .build directory and $ swift build to confirm that the custom modulemap works.
Then delete the generated Xcode project and re-generate it.
If you have an Xcode project and want to add a file (say test.txt) to the project, you simply just drag and drop the file into the Xcode project and are asked if you want to "Copy items if needed" (which in this case I would do). Then you can access the file with:
[[NSBundle mainBundle] pathForResource:#"test" ofType:#"txt"];
Now with a Xcode project created via CMake (via CMakeLists.txt), how do I do the same thing? That is, have the test.txt file available inside the Xcode project just as if I did with the above method. Bonus points if you can make a group (AKA folder) show up inside of the Xcode project with the file inside.
I typically add it as a Resource, but you could also just add it as a regular ol' source file:
# This will be our group of resource files
set(project_RESOURCE_FILES
test.txt
)
# Set properties for this group of files
set_source_files_properties(
${project_RESOURCE_FILES}
PROPERTIES
HEADER_FILE_ONLY TRUE # Since it's just a text file, it doesn't need compiled
# MACOSX_PACKAGE_LOCATION Resource <- only do this if you need to copy the file!
)
# Bonus points unlocked :)
source_group(
"Resources" FILES ${project_RESOURCE_FILES}
)
# Append your resources to the source files you declared.
list(APPEND
project_SOURCE_FILES
${project_RESOURCE_FILES}
}
I'm attempting to write a Ruby script that will delete certain files from the Xcode project. I can find the files based on the absolute path and remove them from the project using the remove_from_project method of PBXFileReference. However this leaves source files (e.g. .m or .swift files) in the "Compile Sources" build phase of whatever target(s) it is a member of, but without a name.
I know I need to also remove the file from the target(s) but there seems to be no easy link between a PBXFileReference and a target (PBXNativeTarget).
From what I can make out I need to iterate through each of the project's targets, then iterate through the files or files_references of that target's source_build_phase looking for the PBXFileReference I already have.
Is this correct or am I missing some obvious link such e.g. file_ref.target_memberships?
if (object.is_a?(Xcodeproj::Project::Object::PBXFileReference))
if (!object.real_path.exist?)
object.remove_from_project
end
end
project.save(project_path)
Not sure when this was introduced, but as of xcodeproj version 1.15.0, you can can get the build files associated with a file reference with:
file_ref.build_files
From the documentation:
Method: Xcodeproj::Project::Object::PBXFileReference#build_files
#build_files ⇒ Array<PBXBuildFile>
Returns the build files associated with the current file reference.
Returns:
(Array<PBXBuildFile>) — the build files associated with the current file reference.
Seems like this should do the trick:
file_ref.build_files.each { |file| file.remove_from_project }
I'm using an assembly that needs an external configuration file to be in bin folder to work properly. It seems that new way to do it in MVC 6 is to include reference in project.json file. Despite the detailed project.json docs I had no success in it.
The project.json file should contain a "resource" definition with your config file. You can then access the resource using a manifest resource.
project.json
{
...
"resource": "bin/somefile.config",
...
}
This can also include wildcards and arrays of values if necessary.
*.cs
string resourceName = "ProjectName.bin.somefile.config";
Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
Note that the config file included slashes without a project name, but the resulting resource name includes the project name and converts slashes to dots.
Troubleshooting
If you are getting back null for your resource stream, it can help to set a breakpoint and examine the output of Assembly.GetExecutingAssembly().GetManifestResourceNames().
When I try to use "resource" in the project.json and then compile my project the output window indicates the following:
warning DOTNET1015: The 'resource' option is deprecated. Use 'embed' in 'buildOptions' instead.
So I guess that's the preferred approach now.
In my Android Studio project, I added the following build type to the build.gradle file:
jnidebug.initWith(buildTypes.debug)
jnidebug {
packageNameSuffix ".jnidebug"
jniDebuggable true
}
The documentation at:
http://tools.android.com/tech-docs/new-build-system/user-guide
says:
For each Build Type, a new matching sourceSet is created, with a
default location of src/<buildtypename>/
But when I resync gradle, the source code folder src/jnidebug never gets created. What am I doing wrong?
The documentation says that for each build type, a source set (which is a logical concept/domain object) is created and configured with a default location. It doesn't say that a source directory is created. You'll probably have to create the directory yourself. (Android Studio could certainly help with that, so perhaps file a feature request.)