我有一个简单的 Xcode 项目,其中包含一个 C++ 类。但是,当我尝试在 Xcode 中构建该项目时,我收到以下错误消息:
error: unable to spawn process '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' (No such file or directory) (in target 'iOSStaticLibrary' from project 'iOSStaticLibrary')
此外,还会发出以下警告:
warning: Could not read serialized diagnostics file: error("Failed to open diagnostics file") (in target 'iOSStaticLibrary' from project 'iOSStaticLibrary')
我不知道如何将实际项目附加到我的帖子中。它仅包含 3 个文件,因此,我将在下面发布相关文件名和内容。
为了重现问题,在指定文件夹中创建3个文件并添加相应的内容。
文件ARM64/Debug/iOSStaticLibrary.xcodeproj/project.pbxproj
:
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
3b051b2877334f3891e05fbf /* iOSStaticLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 810f8ddb516f4fd9aae95391 /* iOSStaticLibrary.cpp */; settings = {COMPILER_FLAGS = "-c -Wall -Wswitch -W\"no-deprecated-declarations\" -W\"empty-body\" -W\"bool-conversion\" -W\"constant-conversion\" -W\"shorten-64-to-32\" -W\"enum-conversion\" -W\"int-conversion\" -W\"return-type\" -Wparentheses -W\"no-pointer-sign\" -W\"no-format\" -Wuninitialized -W\"unreachable-code\" -W\"unused-function\" -W\"unused-value\" -W\"unused-variable\" -O0 -fno-strict-aliasing -fwritable-strings -fno-threadsafe-statics -fno-exceptions -std=gnu++11 -x c++"; }; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
0e5228c6fe3a40ef9446f1d3 /* libiOSStaticLibrary.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libiOSStaticLibrary.a; sourceTree = BUILT_PRODUCTS_DIR; };
810f8ddb516f4fd9aae95391 /* iOSStaticLibrary.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = iOSStaticLibrary.cpp; path = ../../../iOSStaticLibrary.cpp; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
c8f1fdfa1a1a4cf2af0a7098 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
20adea7cddb14f79ab5df50b /* Products */ = {
isa = PBXGroup;
children = (
0e5228c6fe3a40ef9446f1d3 /* libiOSStaticLibrary.a */,
);
name = Products;
sourceTree = SOURCE_ROOT;
};
cb87a76375d04d85a8368aa7 = {
isa = PBXGroup;
children = (
810f8ddb516f4fd9aae95391 /* iOSStaticLibrary.cpp */,
20adea7cddb14f79ab5df50b /* Products */,
);
sourceTree = "\"<group>\"";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
3488e49fcf514802b7be61b6 /* iOSStaticLibrary */ = {
isa = PBXNativeTarget;
buildConfigurationList = 67256f7dc92b42baa13ec8d3 /* Build configuration list for PBXNativeTarget "iOSStaticLibrary" */;
buildPhases = (
7baf7bfde3004dd493908ddd /* Sources */,
c8f1fdfa1a1a4cf2af0a7098 /* Frameworks */,
);
buildRules = (
);
dependencies = (
);
name = iOSStaticLibrary;
productName = iOSStaticLibrary;
productReference = 0e5228c6fe3a40ef9446f1d3 /* libiOSStaticLibrary.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
ee73158d3505468a8fdc43b9 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = MyOrganizationName;
TargetAttributes = {
3488e49fcf514802b7be61b6 = {
CreatedOnToolsVersion = 6.1;
};
};
};
buildConfigurationList = 33fd7959eb644d189bbaa7f7 /* Build configuration list for PBXProject "iOSStaticLibrary" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = cb87a76375d04d85a8368aa7;
productRefGroup = 20adea7cddb14f79ab5df50b /* Products */;
projectDirPath = "\n\n ";
projectRoot = "\n\n ";
targets = (
3488e49fcf514802b7be61b6 /* iOSStaticLibrary */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
7baf7bfde3004dd493908ddd /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3b051b2877334f3891e05fbf /* iOSStaticLibrary.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
1cbb1a8c7cbf4c2699369b65 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Debug;
};
fda96981947c4c2cb659f3e3 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_CXX_LIBRARY = "libc++";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
};
name = Debug;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
33fd7959eb644d189bbaa7f7 /* Build configuration list for PBXProject "iOSStaticLibrary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
1cbb1a8c7cbf4c2699369b65 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
67256f7dc92b42baa13ec8d3 /* Build configuration list for PBXNativeTarget "iOSStaticLibrary" */ = {
isa = XCConfigurationList;
buildConfigurations = (
fda96981947c4c2cb659f3e3 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
};
rootObject = ee73158d3505468a8fdc43b9 /* Project object */;
}
文件iOSStaticLibrary.h
class iOSStaticLibrary
{
public:
iOSStaticLibrary();
~iOSStaticLibrary();
};
文件iOSStaticLibrary.cpp
:
#include "iOSStaticLibrary.h"
iOSStaticLibrary::iOSStaticLibrary()
{
}
iOSStaticLibrary::~iOSStaticLibrary()
{
}
我的假设是 project.pbxproj 中的某些内容不是应有的。这个文件是由代码生成器生成的,而不是由 Xcode 本身生成的,所以很可能就是这种情况。
但是,对于我的生活,我无法弄清楚出了什么问题。