我刚刚将
Xcode升级到4.5版,但是我现在在尝试在iPhone上运行时遇到此错误:
target specifies product type 'com.apple.product-type.application',but there's no such product type for the 'iphoneos' platform
它在模拟器上工作正常,它曾用于4.4版本.
解决方法
您可能从XCode规范中丢失了应用程序部分
退出XCode并转到(对于MacAppStore中的Xcode):
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications/
在编辑之前备份这两个文件:iPhoneOSPackageTypes.xcspec iPhoneOSProductTypes.xcspec
将此内容覆盖到iPhoneOSPackageTypes.xcspec
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>DefaultBuildSettings</key> <dict> <key>CONTENTS_FOLDER_PATH</key> <string>$(WRAPPER_NAME)</string> <key>DOCUMENTATION_FOLDER_PATH</key> <string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/Documentation</string> <key>EXECUTABLES_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/Executables</string> <key>EXECUTABLE_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>EXECUTABLE_NAME</key> <string>$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)</string> <key>EXECUTABLE_PATH</key> <string>$(EXECUTABLE_FOLDER_PATH)/$(EXECUTABLE_NAME)</string> <key>EXECUTABLE_PREFIX</key> <string></string> <key>EXECUTABLE_SUFFIX</key> <string></string> <key>FRAMEWORKS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/Frameworks</string> <key>INFOPLIST_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/Info.plist</string> <key>INFOSTRINGS_PATH</key> <string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/InfoPlist.strings</string> <key>JAVA_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Java</string> <key>LOCALIZED_RESOURCES_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj</string> <key>PBDEVELOPMENTPLIST_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/pbdevelopment.plist</string> <key>PKGINFO_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/PkgInfo</string> <key>PLUGINS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/PlugIns</string> <key>PRIVATE_HEADERS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/PrivateHeaders</string> <key>PUBLIC_HEADERS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/Headers</string> <key>SCRIPTS_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/Scripts</string> <key>SHALLOW_BUNDLE</key> <string>YES</string> <key>SHARED_FRAMEWORKS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/SharedFrameworks</string> <key>SHARED_SUPPORT_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/SharedSupport</string> <key>UNLOCALIZED_RESOURCES_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>VERSIONPLIST_PATH</key> <string>$(CONTENTS_FOLDER_PATH)/version.plist</string> <key>WRAPPER_NAME</key> <string>$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)</string> <key>WRAPPER_PREFIX</key> <string></string> <key>WRAPPER_SUFFIX</key> <string>.bundle</string> </dict> <key>Description</key> <string>Wrapper</string> <key>Identifier</key> <string>com.apple.package-type.wrapper</string> <key>Name</key> <string>Wrapper</string> <key>ProductReference</key> <dict> <key>FileType</key> <string>wrapper.cfbundle</string> <key>IsLaunchable</key> <string>NO</string> <key>Name</key> <string>$(WRAPPER_NAME)</string> </dict> <key>Type</key> <string>PackageType</string> </dict> <dict> <key>BasedOn</key> <string>com.apple.package-type.wrapper</string> <key>DefaultBuildSettings</key> <dict> <key>GENERATE_PKGINFO_FILE</key> <string>YES</string> </dict> <key>Description</key> <string>Application Wrapper</string> <key>Identifier</key> <string>com.apple.package-type.wrapper.application</string> <key>Name</key> <string>Application Wrapper</string> <key>ProductReference</key> <dict> <key>FileType</key> <string>wrapper.application</string> <key>IsLaunchable</key> <string>YES</string> <key>Name</key> <string>$(WRAPPER_NAME)</string> </dict> <key>Type</key> <string>PackageType</string> </dict> <dict> <key>BasedOn</key> <string>com.apple.package-type.wrapper</string> <key>DefaultBuildSettings</key> <dict> <key>CONTENTS_FOLDER_PATH</key> <string>$(WRAPPER_NAME)/Contents</string> <key>DOCUMENTATION_FOLDER_PATH</key> <string>$(LOCALIZED_RESOURCES_FOLDER_PATH)</string> <key>EXECUTABLES_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>EXECUTABLE_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>FRAMEWORKS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>INFOPLIST_PATH</key> <string>$(WRAPPER_NAME)/ContentInfo.plist</string> <key>INFOSTRINGS_PATH</key> <string>$(LOCALIZED_RESOURCES_FOLDER_PATH)/ContentInfo.strings</string> <key>JAVA_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)</string> <key>LOCALIZED_RESOURCES_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/$(DEVELOPMENT_LANGUAGE).lproj</string> <key>PLUGINS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>PRIVATE_HEADERS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>PUBLIC_HEADERS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>SCRIPTS_FOLDER_PATH</key> <string>$(UNLOCALIZED_RESOURCES_FOLDER_PATH)</string> <key>SHARED_FRAMEWORKS_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>SHARED_SUPPORT_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>UNLOCALIZED_RESOURCES_FOLDER_PATH</key> <string>$(CONTENTS_FOLDER_PATH)</string> <key>WRAPPER_SUFFIX</key> <string></string> </dict> <key>Description</key> <string>In-App Purchase Content</string> <key>Identifier</key> <string>com.apple.package-type.in-app-purchase-content</string> <key>Name</key> <string>In-App Purchase Content</string> <key>ProductReference</key> <dict> <key>FileType</key> <string>folder</string> <key>IsLaunchable</key> <string>NO</string> <key>Name</key> <string>$(WRAPPER_NAME)</string> </dict> <key>Type</key> <string>PackageType</string> </dict> <dict> <key>DefaultBuildSettings</key> <dict> <key>EXECUTABLE_NAME</key> <string>$(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_VARIANT_SUFFIX)$(EXECUTABLE_SUFFIX)</string> <key>EXECUTABLE_PATH</key> <string>$(EXECUTABLE_NAME)</string> <key>EXECUTABLE_PREFIX</key> <string>lib</string> <key>EXECUTABLE_SUFFIX</key> <string>.a</string> </dict> <key>Description</key> <string>Mach-O static library</string> <key>Identifier</key> <string>com.apple.package-type.static-library</string> <key>Name</key> <string>Mach-O Static Library</string> <key>ProductReference</key> <dict> <key>FileType</key> <string>archive.ar</string> <key>IsLaunchable</key> <string>NO</string> <key>Name</key> <string>$(EXECUTABLE_NAME)</string> </dict> <key>Type</key> <string>PackageType</string> </dict> </array> </plist>
以及iPhoneOSProductTypes.xcspec的内容
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>Class</key> <string>PBXBundleProductType</string> <key>DefaultBuildProperties</key> <dict> <key>FRAMEWORK_FLAG_PREFIX</key> <string>-framework</string> <key>FULL_PRODUCT_NAME</key> <string>$(WRAPPER_NAME)</string> <key>GCC_INLINES_ARE_PRIVATE_EXTERN</key> <string>YES</string> <key>LIBRARY_FLAG_NOSPACE</key> <string>YES</string> <key>LIBRARY_FLAG_PREFIX</key> <string>-l</string> <key>MACH_O_TYPE</key> <string>mh_bundle</string> <key>STRIP_STYLE</key> <string>non-global</string> <key>WRAPPER_EXTENSION</key> <string>bundle</string> <key>WRAPPER_NAME</key> <string>$(WRAPPER_PREFIX)$(PRODUCT_NAME)$(WRAPPER_SUFFIX)</string> <key>WRAPPER_PREFIX</key> <string></string> <key>WRAPPER_SUFFIX</key> <string>.$(WRAPPER_EXTENSION)</string> </dict> <key>DefaultTargetName</key> <string>Bundle</string> <key>Description</key> <string>Generic bundle</string> <key>HasInfoPlist</key> <string>YES</string> <key>HasInfoPlistStrings</key> <string>YES</string> <key>IconNamePrefix</key> <string>TargetPlugin</string> <key>Identifier</key> <string>com.apple.product-type.bundle</string> <key>IsWrapper</key> <string>YES</string> <key>Name</key> <string>Bundle</string> <key>PackageTypes</key> <array> <string>com.apple.package-type.wrapper</string> </array> <key>Type</key> <string>ProductType</string> </dict> <dict> <key>BasedOn</key> <string>com.apple.product-type.bundle</string> <key>Class</key> <string>PBXApplicationProductType</string> <key>DefaultBuildProperties</key> <dict> <key>CODE_SIGNING_ALLOWED</key> <string>YES</string> <key>ENTITLEMENTS_ALLOWED</key> <string>YES</string> <key>GCC_INLINES_ARE_PRIVATE_EXTERN</key> <string>YES</string> <key>GCC_SYMBOLS_PRIVATE_EXTERN</key> <string>YES</string> <key>INSTALL_PATH</key> <string>$(LOCAL_APPS_DIR)</string> <key>MACH_O_TYPE</key> <string>mh_execute</string> <key>PROVISIONING_PROFILE_required</key> <string>YES</string> <key>RESOURCE_RULES_required</key> <string>YES</string> <key>STRIP_STYLE</key> <string>all</string> <key>WRAPPER_EXTENSION</key> <string>app</string> <key>WRAPPER_SUFFIX</key> <string>.$(WRAPPER_EXTENSION)</string> </dict> <key>DefaultTargetName</key> <string>Application</string> <key>Description</key> <string>Application</string> <key>IconNamePrefix</key> <string>TargetApp</string> <key>Identifier</key> <string>com.apple.product-type.application</string> <key>Name</key> <string>Application</string> <key>PackageTypes</key> <array> <string>com.apple.package-type.wrapper.application</string> </array> <key>SupportsZeroLink</key> <string>YES</string> <key>Type</key> <string>ProductType</string> <key>Validation</key> <dict> <key>AdditionalValidationClass</key> <string>XCiPhoneOSPlatformPlugin</string> <key>Checks</key> <dict> <key>!( $(VALIDATE_PRODUCT) == NO && $(CODE_SIGN_IDENTITY) == 'iPhone Distribution' )</key> <string>The Validate Built Product build setting was not enabled when building for Distribution.</string> </dict> <key>ValidationToolSpec</key> <string>com.apple.build-tools.platform.validate</string> </dict> </dict> <dict> <key>Class</key> <string>PBXBundleProductType</string> <key>DefaultBuildProperties</key> <dict> <key>FULL_PRODUCT_NAME</key> <string>$(WRAPPER_NAME)</string> </dict> <key>Description</key> <string>In-App Purchase Content</string> <key>HasInfoPlist</key> <string>YES</string> <key>HasInfoPlistStrings</key> <string>NO</string> <key>Identifier</key> <string>com.apple.product-type.in-app-purchase-content</string> <key>IsWrapper</key> <string>YES</string> <key>Name</key> <string>In-App Purchase Content</string> <key>PackageTypes</key> <array> <string>com.apple.package-type.in-app-purchase-content</string> </array> <key>Type</key> <string>ProductType</string> </dict> <dict> <key>AlwaysPerformSeparateStrip</key> <string>YES</string> <key>Class</key> <string>PBXStaticLibraryProductType</string> <key>DefaultBuildProperties</key> <dict> <key>CODE_SIGNING_ALLOWED</key> <string>NO</string> <key>EXECUTABLE_EXTENSION</key> <string>a</string> <key>EXECUTABLE_PREFIX</key> <string>lib</string> <key>EXECUTABLE_SUFFIX</key> <string>.$(EXECUTABLE_EXTENSION)</string> <key>FRAMEWORK_FLAG_PREFIX</key> <string>-framework</string> <key>FULL_PRODUCT_NAME</key> <string>$(EXECUTABLE_NAME)</string> <key>GCC_ENABLE_SYMBOL_SEPARATION</key> <string>NO</string> <key>INSTALL_PATH</key> <string>/usr/local/lib</string> <key>LIBRARY_FLAG_NOSPACE</key> <string>YES</string> <key>LIBRARY_FLAG_PREFIX</key> <string>-l</string> <key>MACH_O_TYPE</key> <string>staticlib</string> <key>PRIVATE_HEADERS_FOLDER_PATH</key> <string>/usr/local/include</string> <key>PUBLIC_HEADERS_FOLDER_PATH</key> <string>/usr/local/include</string> <key>REZ_EXECUTABLE</key> <string>YES</string> <key>SEPARATE_STRIP</key> <string>YES</string> <key>STRIP_STYLE</key> <string>debugging</string> </dict> <key>DefaultTargetName</key> <string>Static Library</string> <key>Description</key> <string>Static library</string> <key>IconNamePrefix</key> <string>TargetLibrary</string> <key>Identifier</key> <string>com.apple.product-type.library.static</string> <key>Name</key> <string>Static Library</string> <key>PackageTypes</key> <array> <string>com.apple.package-type.static-library</string> </array> <key>Type</key> <string>ProductType</string> </dict> </array> </plist>
重新启动XCode,然后清理您的项目并为您的设备再次构建它.