For the project I'm working on I needed to unzip certain files. For this, I found the library SSZipArchive. I included this in Xcode 4.2 (Right-click on the Classes folder->Add files to project, with in the dialogue the "Copy items into destination group's folder"-checkbox checked). I include the libz library (I've tried both libz and zlib1.2.5). I try to compile and suddenly I've got 20 errors:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:311:1: error: expected identifier or '(' [1]
@class NSString, Protocol;
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:313:19: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT NSString *NSStringFromSelector(SEL aSelector);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:314:44: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:316:19: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT NSString *NSStringFromClass(Class aClass);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:317:43: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT Class NSClassFromString(NSString *aClassName);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:319:19: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:319:50: error: unknown type name 'Protocol' [1]
FOUNDATION_EXPORT NSString *NSStringFromProtocol(Protocol *proto) NS_AVAILABLE(10_5, 2_0);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:320:19: error: unknown type name 'Protocol' [1]
FOUNDATION_EXPORT Protocol *NSProtocolFromString(NSString *namestr) NS_AVAILABLE(10_5, 2_0);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:320:50: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT Protocol *NSProtocolFromString(NSString *namestr) NS_AVAILABLE(10_5, 2_0);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:324:30: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:324:53:{324:53-324:76}: error: format argument not an NSString [3]
FOUNDATION_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
^~~~~~~~~~~~~~~~~~~~~~~
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:85:49: note: instantiated from:
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:325:31: error: unknown type name 'NSString' [1]
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0);
^
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:325:63:{325:63-325:86}: error: format argument not an NSString [3]
FOUNDATION_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0);
^~~~~~~~~~~~~~~~~~~~~~~
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:85:49: note: instantiated from:
#define NS_FORMAT_FUNCTION(F,A) __attribute__((format(__NSString__, F, A)))
These are all errors in the core library, so probably something went wrong with including the library in Xcode. I managed to narrow down the culprit to the minizip library that SSZipArchive uses (if I remove that library, the errors disappear and the compiler runs like it should), but I'm pretty stumped on why this causes the compiler to have so many issues.
After a lot of headaches, I figured out what was the problem. It turned out to be _Prefix.pch. I totally looked over it, but it turns out that I had the following line there:
#import "someclass.h"
This class was being loaded in with the .c-files of the minizip library, resulting in Objective-C headers being included in .c-files, which was something that XCode did not like. Wrapping these statements in an #ifdef statement fixed the problem:
#ifdef __OBJC__
#import "someclass.h"
#endif
Refer to below link thats works with both iphone as well mac applications. Archive and Unarchive from app
来源:https://stackoverflow.com/questions/9005097/how-do-you-include-ssziparchive-for-ios-5