tvOSBrowser
tvOSBrowser copied to clipboard
Changes to Availability.h
Could you please elaborate on how to redefine __TVOS_UNAVAILABLE and __TVOS_PROHIBITED in Availability.h? I've located the Availability.h file but not sure what to change. I tried setting them to 'available' as below but that globally enables everything and caused too many errors.
#define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,unavailable)
#define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable)
Well, I got it to work finally but following all the instances of __TV_UNAVAILABLE/PROHIBITED that the compiler complained about and deleting them but that probably wasn't a smart thing to do. Should I have done this instead in Availability.h ?
#ifndef __TVOS_UNAVAILABLE
#define __TVOS_UNAVAILABLE 0
#endif
#ifndef __TVOS_PROHIBITED
#define __TVOS_PROHIBITED 0
#endif
This is what you wanted:
#define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,introduced=9.0)
#define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,introduced=9.0)
Thank you ! However, just so I understand, doesn't this enable every instance of those macros instead of just enabling UIWebviews?
I've tried this and it works ok on simulator but when trying to run on apple tv device the web view errors return.... any ideas guys
Availability.h is included in both the Simulator and device SDKs
Yes, I've got it running on the device too. I made some improvements for the cursor movements (and cursor activation method on remote), and will upload to github soon!
Okay, published the changes in a fork on my account.
I made a quick fix to reset the cursor to the centre everytime it re-appears in the toggle. Hope it helps someone. in ViewController.m:
#define CGRectSetPos( r, x, y ) CGRectMake( x, y, r.size.width, r.size.height )
-(void)toggleMode
{
self.cursorMode = !self.cursorMode;
if (self.cursorMode)
{
self.webview.scrollView.scrollEnabled = NO;
self.webview.userInteractionEnabled = NO;
cursorView.hidden = NO;
cursorView.frame = CGRectSetPos( cursorView.frame, CGRectGetMidX([UIScreen mainScreen].bounds), CGRectGetMidY([UIScreen mainScreen].bounds) );
}
else
{
self.webview.scrollView.scrollEnabled = YES;
self.webview.userInteractionEnabled = YES;
cursorView.hidden = YES;
}
}
@jvanakker Thank you for the touchpad/cursor improvements. Nice touch.
May I suggest that for the keyboard entry, you use UIKeyboardTypeEmailAddress
as it adds the .com button which for some reason is missing in the UIKeyboardTypeURL
type.
@frakman1 You're right, that's better! Will change that too in a next version, where I would also like to have page zooming. I know Apple doesn't allow any of this (for now) for the App Store, but it's still fun to play around with and make some improvements never the less.
BTW... Talking about URL input. Long text entry is still very clumsy, even with the new tvOS software (unless you would use keyboard on the remote iOS app of course). So, it would also be nice if speech (or Siri) could be used for text input like this (while spelling the letters), especially now that we have a microphone on the remote. Could't get this on my 4th gen AppleTV. Though I haven't really looked into the SDK if this is possible yet.
Now Xcode 7.1 has been released whats the best way to edit Availability.h as it's locked or is it possible to put the definitions else where cheers
You need to be root to change the file. Just use sudo:
sudo nano /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/Availability.h
Find this: #define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,unavailable) #define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,unavailable)
Change to this: #define __TVOS_UNAVAILABLE_NOTQUITE __OS_AVAILABILITY(tvos,unavailable) #define __TVOS_PROHIBITED_NOTQUITE __OS_AVAILABILITY(tvos,unavailable)
CTRL+O to save changes in the Nano editor. It will ask to save to file. Press return. CTRL+X to exit the Nano editor.
If you open up Availability.h in Xcode, the lines to change should be 272 and 273. Have fun.
Really though, you are just tricking the compiler into letting you use UIWebView. But if you want to compile this app without modifying Availability.h, you can. All you really have to do is instantiate UIWebView without using the header definition. Change the defined type to id and have at it. This does mean you can't use dot notation to access UIWebView properties, though.
Class UIWebViewClass = NSClassFromString(@"UIWebView");
if (UIWebViewClass != Nil) {
self.webview = [[UIWebViewClass alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com"]]];
// ...
[[self.webview scrollView] setBounces:YES];
[[[self.webview scrollView] panGestureRecognizer] setAllowedPressTypes:@[ @(UITouchTypeIndirect) ]];
How come the cursor doesn't click on certain page areas e.g search bars, videos, etc.. Having the command to turn the cursor on/off by clicking on the remote touch area doesn't seem to play well with trying to click on page items. Any updates on the zoom or other capabilities that are being worked on?
Hi, how can you change the Availability.h on the Apple TV pls ? Thanks in advance for the great work
where is Availability.h file ?
For newbies:
sudo vi /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/Availability.h
sudo vi /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/Availability.h
For anyone not familiar with Availability and vi or nano, i have made a fork on my account with the elegant fix suggested by zachhowe (id + NSClassFromString).
No more Availability.h change needed.
Does this work with WKWebView as well?
@sabaggal Last I checked, WebKit.framework isn't public on tvOS, if it even exists at all.
XCODE 8.0 missing “Availability.h” is currently locked because it does not support editing.
The file “Availability.h” could not be unlocked.
Could not add write permission to the parent folder because you do not own it. Try modifying the permissions of the folder in the Finder or Terminal.
HELP PLEASE
As sebastianpopp commented above:
You need to be root to change the file. Just use sudo:
sudo nano /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/usr/include/Availability.h
that will allow editing for the simulator Availability.h and do the same for device Availability.h
With the above Availability.h change, the uiwebview loads properly, I can change its properties, etc. However I cannot seem to get UIWebViewDelegate to work. eg func webViewDidFinishLoad(_ webView: UIWebView) { print("webViewDidFinishLoad") } Is there something else needed in this regard? Thanks.
@jvanakker First thanks for the browser. But after double clicking remote for pointer, and hovering over a link, a single click does nothing. So I cannot drill down from the home page. Please let me know. Thanks.
Hoping someone can help a newbie at this. Really keen to get the browser on Apple TV. I've followed all of the instructions and I still get some errors, it works great in the simulator but doesn't appear on the TV device itself. Attached a screenshot if that helps?
Hoping someone can help a newbie at this. Really keen to get the browser on Apple TV. I've followed all of the instructions and I still get some errors, it works great in the simulator but doesn't appear on the TV device itself. Attached a screenshot if that helps?
Never mind! I fixed it. Turns out I didn't need the _NOTQUITE parts added. Cheers! (Y)
@noblerise what did you end up changing to make it work?
changing to this instead of _NOTQUITE didn't do the trick. Works for iOS 11.x not iOS12
#define __TVOS_UNAVAILABLE __OS_AVAILABILITY(tvos,introduced=9.0)
#define __TVOS_PROHIBITED __OS_AVAILABILITY(tvos,introduced=9.0)
Also having no luck getting this to work on the latest OS. 'UIDataDetectorTypes' is unavailable: not available on tvOS
Go it to work on tvOS 12.0 in SDK 12 they've change a couple of things. UIDataDetectorTypes , and also UIWebview has added a notation API_UNAVAILABLE(tvOS). Just delete those in the required files (Xcode we'll show you given the errors you'll see)
For example here's the UIDataDetectorTypes after removing it:
typedef NS_OPTIONS(NSUInteger, UIDataDetectorTypes) {
UIDataDetectorTypePhoneNumber = 1 << 0, // Phone number detection
UIDataDetectorTypeLink = 1 << 1, // URL detection
UIDataDetectorTypeAddress NS_ENUM_AVAILABLE_IOS(4_0) = 1 << 2, // Street address detection
UIDataDetectorTypeCalendarEvent NS_ENUM_AVAILABLE_IOS(4_0) = 1 << 3, // Event detection
UIDataDetectorTypeShipmentTrackingNumber NS_ENUM_AVAILABLE_IOS(10_0) = 1 << 4, // Shipment tracking number detection
UIDataDetectorTypeFlightNumber NS_ENUM_AVAILABLE_IOS(10_0) = 1 << 5, // Flight number detection
UIDataDetectorTypeLookupSuggestion NS_ENUM_AVAILABLE_IOS(10_0) = 1 << 6, // Information users may want to look up
UIDataDetectorTypeNone = 0, // Disable detection
UIDataDetectorTypeAll = NSUIntegerMax // Enable all types, including types that may be added later
}<REMOVED HERE>;