问题
I set a simple tweak using theos following the tutorial here. However when I run make with the headers from here, I get
Making all for tweak WelcomeWagon...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
In file included from Tweak.xm:1:
/opt/theos//include/SpringBoard/SpringBoard.h:7:26: error: UIApplication.h: No such file or directory
cc1objplus: warnings being treated as errors
In file included from /opt/theos//include/SpringBoard/UIApplicationDelegate-Protocol.h:7,
from /opt/theos//include/SpringBoard/SpringBoard.h:9,
from Tweak.xm:1:
/opt/theos//include/SpringBoard/NSObject-Protocol.h:7: warning: duplicate declaration for protocol ‘NSObject’
In file included from /opt/theos//include/SpringBoard/SpringBoard.h:9,
from Tweak.xm:1:
/opt/theos//include/SpringBoard/UIApplicationDelegate-Protocol.h:11: warning: duplicate declaration for protocol ‘UIApplicationDelegate’
/opt/theos//include/SpringBoard/UIApplicationDelegate-Protocol.h:35: error: duplicate property declaration ‘window’
make[2]: *** [obj/Tweak.xm.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [WelcomeWagon.all.tweak.variables] Error 2
After some searching around I also found that some people were using Ryan Petrich's dumped headers, so I emptied the include folder and put his headers in and ran make, with this as the output
Making all for tweak WelcomeWagon...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
In file included from /opt/theos//include/QuartzCore/QuartzCore-Structs.h:11,
from /opt/theos//include/QuartzCore/CAValueFunction.h:9,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreAnimation.h:30,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:9,
from /opt/theos//include/UIKit/UIKit-Structs.h:15,
from /opt/theos//include/UIKit/UIGestureRecognizer.h:6,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UISwipeGestureRecognizer.h:9,
from /opt/theos//include/UIKit/UISwipeGestureRecognizer.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityAdditions.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:12,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:10,
from /opt/theos//Prefix.pch:4,
from <command-line>:0:
/opt/theos//include/IOSurface/IOSurface.h:20:36: error: IOSurface/IOSurfaceAPI.h: No such file or directory
In file included from /opt/theos//include/IOSurface/IOSurface.h:21,
from /opt/theos//include/QuartzCore/QuartzCore-Structs.h:11,
from /opt/theos//include/QuartzCore/CAValueFunction.h:9,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreAnimation.h:30,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:9,
from /opt/theos//include/UIKit/UIKit-Structs.h:15,
from /opt/theos//include/UIKit/UIGestureRecognizer.h:6,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UISwipeGestureRecognizer.h:9,
from /opt/theos//include/UIKit/UISwipeGestureRecognizer.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityAdditions.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:12,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:10,
from /opt/theos//Prefix.pch:4,
from <command-line>:0:
/opt/theos//include/IOSurface/IOSurfaceAccelerator.h:20: error: ‘IOSurfaceRef’ has not been declared
/opt/theos//include/IOSurface/IOSurfaceAccelerator.h:20: error: ‘IOSurfaceRef’ has not been declared
In file included from /opt/theos//include/QuartzCore/QuartzCore-Structs.h:11,
from /opt/theos//include/QuartzCore/CAValueFunction.h:9,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreAnimation.h:30,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:9,
from /opt/theos//include/UIKit/UIKit-Structs.h:15,
from /opt/theos//include/UIKit/UIGestureRecognizer.h:6,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UISwipeGestureRecognizer.h:9,
from /opt/theos//include/UIKit/UISwipeGestureRecognizer.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityAdditions.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:12,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:10,
from /opt/theos//Prefix.pch:4,
from <command-line>:0:
/opt/theos//include/IOSurface/IOSurface.h:27: error: variable or field ‘IOSurfaceFlushProcessorCaches’ declared void
/opt/theos//include/IOSurface/IOSurface.h:27: error: ‘IOSurfaceRef’ was not declared in this scope
In file included from /opt/theos//include/QuartzCore/CAValueFunction.h:9,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/CoreAnimation.h:30,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h:9,
from /opt/theos//include/UIKit/UIKit-Structs.h:15,
from /opt/theos//include/UIKit/UIGestureRecognizer.h:6,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UISwipeGestureRecognizer.h:9,
from /opt/theos//include/UIKit/UISwipeGestureRecognizer.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h:11,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityAdditions.h:10,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibility.h:12,
from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:10,
from /opt/theos//Prefix.pch:4,
from <command-line>:0:
/opt/theos//include/QuartzCore/QuartzCore-Structs.h:196: error: ‘IOSurfaceRef’ does not name a type
In file included from /opt/theos//include/UIKit/UIKit2.h:52,
from /opt/theos//include/MessageUI/MessageUI-Structs.h:8,
from /opt/theos//include/MessageUI/ComposeRecipient.h:9,
from /opt/theos//include/ChatKit/CKMailComposeRecipient.h:6,
from /opt/theos//include/ChatKit/ChatKit.h:41,
from /opt/theos//include/SpringBoard/SpringBoard-Structs.h:13,
from /opt/theos//include/SpringBoard/SpringBoard.h:8,
from Tweak.xm:1:
/opt/theos//include/UIKit/UIImage2.h:85: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:85: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:85: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIImage2.h:86: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:86: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:86: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIImage2.h:91: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:91: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIImage2.h:91: error: expected `;' before ‘)’ token
In file included from /opt/theos//include/UIKit/UIKit2.h:448,
from /opt/theos//include/MessageUI/MessageUI-Structs.h:8,
from /opt/theos//include/MessageUI/ComposeRecipient.h:9,
from /opt/theos//include/ChatKit/CKMailComposeRecipient.h:6,
from /opt/theos//include/ChatKit/ChatKit.h:41,
from /opt/theos//include/SpringBoard/SpringBoard-Structs.h:13,
from /opt/theos//include/SpringBoard/SpringBoard.h:8,
from Tweak.xm:1:
/opt/theos//include/UIKit/UIWindow2.h:19: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:19: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:19: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIWindow2.h:20: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:20: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:20: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIWindow2.h:21: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:21: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:21: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIWindow2.h:116: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:116: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:116: error: expected `;' before ‘)’ token
/opt/theos//include/UIKit/UIWindow2.h:117: error: expected type-specifier before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:117: error: expected `)' before ‘IOSurfaceRef’
/opt/theos//include/UIKit/UIWindow2.h:117: error: expected `;' before ‘)’ token
make[2]: *** [obj/Tweak.xm.o] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [WelcomeWagon.all.tweak.variables] Error 2
Could anyone tell me what I'm doing wrong? Thanks in advance.
回答1:
I found the same problem with current version of Ryan Petrich's dumped headers today.
Finally I find out that the solution is,
Import the dumped Springboard headers
Copy /System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h to /opt/theos/include/IOSurface. The reason is in IOSurface/IOSurface.h!
If you are running OS X Lion or later, you may need to comment out the following lines in /opt/theos/include/IOSurface/IOSurfaceAPI.h:
/* This call lets you get an xpcobject_t that holds a reference to the IOSurface. Note: Any live XPC objects created from an IOSurfaceRef implicity increase the IOSurface's global use count by one until the object is destroyed. */ // xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef aSurface) // IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA); /* This call lets you take an xpcobject_t created via IOSurfaceCreatePort() and recreate an IOSurfaceRef from it. */ // IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t xobj) // IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA);
Give it a try!
回答2:
I just did this today 02/13/2013 and found the above to be somewhat helpful. With a little brains and the help of Google I found that what you need to do is :
1.) Get the headers - use a Google search for "Ryan Petrich's dumped headers" which will lead you to :https://github.com/rpetrich/iphoneheaders
2.) Use git to clone the repo : git clone https://github.com/rpetrich/iphoneheaders
3.) run make ( I found that I needed to run make as sudo make due to the location of theos being installed under /opt. )
4.) For each "error file not found" I copied the include files into my project.
5.) I believe you should end up with the following folders in your project folder : AccountSettings IOKit SpringBoard ActorKit IOSurface TelephonyUI AppSupport JavaScriptCore Tutorial.plist Availability2.h MIME Tweak.xm ChatKit Makefile Tweak.xm.original CoreFoundation MediaPlayer UIKit CoreGraphics Message WebCore DAVKit MessageUI WebKit DataAccess MusicLibrary control Foundation PhotoLibrary obj GraphicsServices QuartzCore theos
6.) You need to do #2 from the answer above "Copy /System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h to /opt/theos/include/IOSurface. The reason is in IOSurface/IOSurface.h!"
7.) You also need to make the edit from the answer above "If you are running OS X Lion, you may need to comment out the following lines in /opt/theos/include/IOSurface/IOSurfaceAPI.h:"
/* This call lets you get an xpcobject_t that holds a reference to the IOSurface.
Note: Any live XPC objects created from an IOSurfaceRef implicity increase the IOSurface's global use
count by one until the object is destroyed. */
// xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef aSurface)
// IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA);
/* This call lets you take an xpcobject_t created via IOSurfaceCreatePort() and recreate an IOSurfaceRef from it. */
// IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t xobj)
// IOSFC_AVAILABLE_STARTING(_MAC_10_7, __IPHONE_NA);
FYI in my IOSurfaceAPI.h these were lines around line number 252/253
回答3:
You don't need to import the dumped Springboard headers.
来源:https://stackoverflow.com/questions/10891846/error-compiling-tweak-in-theos