Getting error when trying to use AVPictureInPictureController in iOS 13 or tvOS 13 - ios13

I have small app which runs on iOS and tvOS where I’m displaying a video in UIView.It does support iOS 12 and tvOS 12.
Now want to show PIP for tvOS hence trying to use AVPictureInPictureController gives error “Use of undeclared identifier 'AVPictureInPictureController”.
Even though deployment target set to tvOS 13. In Xcode, capabilities -> Background mode -> enabled “ Audio,Airplay and Picture In Picture”.
This basic code gives error.
#import <AVKit/AVKit.h>
if ([AVPictureInPictureController isPictureInPictureSupported]) {
// code
}
Any other settings missing or something else I need do ?
Thanks

Not supported in tvOS, as stated in Apple's documentation
SDKs
iOS 9.0+
macOS 10.15+
Mac Catalyst 13.0+

POSSIBLITY OF ISSUES DUE TO THE GAPS IN IMPLEMENTATION :
Experince with the AVPlayerViewController:
Initially make Sure that we set Playback audio category, Generally when we use a AVPlayerViewController to play video content. PIP mode will automatically get invoked if the developed application enters background , but only if satisfies the below mentioned condition,First one is the Player which we are using should be in Full Screen mode,the second is we should make sure that the Video Should be Playing in it and third one is PIP Should be supported by the device and last of all write delegate method to restore our player UI when the user returns from Picture in Picture mode.
Implmentation with _AVPictureInPictureController :
You can find an working example in the below thread.
How to display AVPictureInPictureController?
Drilling down the issue:
In order to confirm the undeclared error was not due to the gaps in implementation and it was due to environmnet in Xcode, Download the source and then add the Sources folder inside another folder in your workspace.Add the folder using "Add Files to ..." option and now verify inside xcode.
POSSIBLITY OF ISSUE DUE TO REFRESH IN THE XCODE
Try Fix By Approach 1
Include the class explicitly in header and/or body - instead of the *.pch file. Then this error might go away. Also deleting the derived data workes once in a while. Did you change the location in preferences recently by any chance. Some get this error when they use a ramdisk for derived data and then they go back to default. This is the most annoying case - since it causes this error to appear then in almost every file.
Try Fix By Approach 2
Sometime a simple solution might help delete one of the #import lines from the pch file and recompile which will fail as expected.Then put the deleted line back in, recompiled and it compiled normally with all the false errors gone.
POSSIBLITY OF ISSUE DUR TO XCODE ERROR CACHE, FOLLOW THE BELOW STEPS
Clean Build : Command-Option-Shift-K to clean out the build folder.
Reset Simulator : choose iOS Simulator > Reset Content and Settings
Restart Xcode
Delete your DerivedData folder in ~/Library/Developer/Xcode/DerivedData
Restart Computer
Delete the /var/folders in a very targetted way.
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
Source:
How to Empty Caches and Clean All Targets Xcode 4 and later
Xcode "Use of undeclared identifier" errors, compiles/runs just fine
Use of undeclared identifier in Xcode 9.0
https://developer.apple.com/documentation/avkit/adopting_picture_in_picture_in_a_standard_player

To create a simple video player
First, you'll need to implement a basic video player in your project's ViewController.m file, like so:
#import "ViewController.h"
#import <AVKit/AVKit.h>
#interface ViewController ()
#property(nonatomic) AVPlayerViewController *playerViewController;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor blackColor];
// Create a stream video player.
AVPlayer *player = [[AVPlayer alloc] init];
self.playerViewController = [[AVPlayerViewController alloc] init];
self.playerViewController.player = player;
// Attach video player to view hierarchy.
[self addChildViewController:self.playerViewController];
self.playerViewController.view.frame = self.view.bounds;
[self.view addSubview:self.playerViewController.view];
[self.playerViewController didMoveToParentViewController:self];
}
#end
For further help go through https://help.apple.com/xcode/mac/8.0/#/dev51a648b07

Related

Property 'downloadURL' not found on object of type 'FIRStorageMetadata *' - Getting this error when trying to build a Flutter project

I'm trying to build a Flutter project on Xcode with firebase installed. I'm getting the following error: Property 'downloadURL' not found on object of type 'FIRStorageMetadata *'
This is being caused by the following section in the FirebaseStoragePlugin.m file:
NSString *path = call.arguments[#"path"];
NSDictionary *metadataDictionary = call.arguments[#"metadata"];
FIRStorageMetadata *metadata;
if (![metadataDictionary isEqual:[NSNull null]]) {
metadata = [self buildMetadataFromDictionary:metadataDictionary];
}
FIRStorageReference *fileRef = [[FIRStorage storage].reference child:path];
[fileRef putData:data
metadata:metadata
completion:^(FIRStorageMetadata *metadata, NSError *error) {
if (error != nil) {
result(error.flutterError);
} else {
// Metadata contains file metadata such as size,
// content-type, and download URL.
NSURL *downloadURL = metadata.downloadURL; <---------------- This line
result(downloadURL.absoluteString);
}
}];
}
Since I didn't generate this code, I don't particularly want to edit it as it should really be working out of the box. I've tried to change the method to see whether later versions of Firebase might only accept another function but to no avail. What shall I do in this situation? Should I perhaps try to rebuild the project with a higher version of Firebase or is there a one line fix?
The downloadURL was removed from the StorageMetadata class in May 2018. If your native iOS code still uses that, it's high time to find an updated SDK or update your code to match the documentation on uploading a file and getting its download URL.
If you're using the FlutterFire binding libraries, upgrade to the latest version (as I definitely don't see any reference to metadata.downloadURL in its current code base). If you're using another library, check if the latest version of that solves the problem - or otherwise consider switching to the FlutterFire libraries as those are quite actively maintained.

NSLog not printing to console

I have an Xcode project I've been working on for months. I've never had a problem with NSLog, but after upgrading to Xcode 4.2 nothing will log to the console. I even tried throwing this in viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(#"Can anyone hear me?");
And nothing. Is anyone else having this problem or know a solution?
Well, this is embarrassing. The console got deactivated somehow and I was actually watching the variables window. Pressing Shift +  + C did the trick.
Many thanks to Robert King on this thread:
https://devforums.apple.com/message/565880#565880
This is a bug of Xcode8 + iOS10, we can solve it in this way:
When on simulator, add the Name OS_ACTIVITY_MODE and the Value
Variables disable and check it (Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment).
When on device, only add OS_ACTIVITY_MODE and check it(don't add the Value). You'll see the NSLog in the Xcode8 Console.
In iOS10, a lot of system logging is displayed on the console. This can be disabled by including the OS_ACTIVITY_MODE = disabled in the Run Arguments for your scheme
However for iOS10, NSLog messages will not be displayed anymore.
In lower iOS versions the messages will still be displayed. So maybe for most test cases you can use a lower iOS version.
Otherwise you can include a Swift function which prints (print function) your text, this is working okay in iOS10.
Tested on iOS10.0.2 and iOS9.3
My issue is that I have Debugger Output selected. Once I changed it to either All output or target output NSLogs appear fine.
In case this confuses you its on the left of the Debug area.
I had the same issue.
The trick is to search and remove the below mentioned line from the project.
#define NSLog(...)
Search the entire project and remove it.
I just experienced this, so here's another thing to check.
-> Make sure you don't have anything typed in the Filter field below the Log Output. So, in my case I was searching for a term in the logger and forgot to delete the searched terms out of the Filter text field. DOH!
My issue was that I'd accidentally severed the referencing outlet from App Delegate (delegate - file's owner).

How can I programmatically add build files to Xcode4?

I've been trying to figure out how to programmatically add files to an Xcode4 project and it seemed like AppleScript would be the way to go, however I'm running into "missing value" errors.
Here's the code I've got:
tell application "Xcode"
set theProject to first project
set theTarget to first target of theProject
set theBuildPhase to compile sources phase of theTarget
tell first group of theProject
set theFileRef to make new file reference with properties {full path:"/Users/jeff/Projects/XcodeTest/XcodeTest/MyViewController.h", name:"MyViewController.h", path:"XcodeTest/MyViewController.h", path type:group relative}
add theFileRef to theProject
end tell
--tell theBuildPhase to make new build file with properties {build phase:theBuildPhase, name:"MyViewController.h", file reference:theFileRef, target:theTarget, project:theProject}
end tell
I've tried the commented-out line instead of the add-command as well, but that doesn't work either (I get "missing value").
The 'add' error is:
error "Xcode got an error: file reference id \"251AD3431432472E006E300F\" of Xcode 3 group id \"251AD32C14324645006E300F\" of project \"XcodeTest\" of workspace document \"XcodeTest.xcodeproj/project.xcworkspace\" doesn’t understand the add message." number -1708 from file reference id "251AD3431432472E006E300F" of Xcode 3 group id "251AD32C14324645006E300F" of project "XcodeTest" of workspace document "XcodeTest.xcodeproj/project.xcworkspace"
The "make new reference" does add the file to the list of files in Xcode, but I also need it to be added to the project target so that I can add actions and outlets to the file from Xcode w/o having to first check the checkbox to add it to the "target membership".
I ended up sending this question to the devs on the xcode developer list and the response I got was effectively "you can't".
This appears to be completely broken in Xcode4, but I've seen a project that does it. I think what they are doing is parsing and modifying the "project.pbxproj" file directly. (this file is hidden inside the xcodeproj bundle)
The file is a GUID soup, but once you look at it for a while it seems possible to safely modify it, especially if you are only adding stuff.
Edit:
Found this stackoverflow answer that might help.
Tutorial or Guide for Scripting XCode Build Phases
There is a poorly documented user defined build setting that can be added. Files can be both excluded and included from compilation
Go to your target's Build Settings > Tap the + button > Add User-Defined Setting
The key is either INCLUDED_SOURCE_FILE_NAMES or EXCLUDED_SOURCE_FILE_NAMES
The value is a space separated list of file paths
See reference:
http://lists.apple.com/archives/xcode-users/2009/Jun/msg00153.html

QAbstractItemModel testing using modeltest

I'm looking for a good tutorial on how to use modeltest to test models based on QAbstractItemModel. I don't know how to interpret debug messages that are displayed.
Also I'm having trouble configuring modeltest project to work with my app in QtCreator. Including the .pri/.pro doesn't work. I get an error saying "No rule to mage target ..". After fixing paths in modeltest/modeltest.pro file it starts to compile. But i get this wierd assertion
ASSERT: "QTest::testLogger" in file c:\ndk_buildrepos\qt-desktop\src\testlib\qtestlog.cpp, line 232
Any ideas why this happens ?
My modeltest folder is located inside my project. I added following line at the end of my *.pro file
include(modeltest/modeltest.pri)
The modeltest.pri file contains the following
load(qttest_p4)
SOURCES += modeltest/modeltest.cpp modeltest/dynamictreemodel.cpp
HEADERS += modeltest/modeltest.h modeltest/dynamictreemodel.h
I modified my code to use modeltest this way
model = new TasksModel(this);
new ModelTest(model, this);
ui->treeView->setModel(model);
TasksModel is my implementation of QAbstractItemModel model.
ui->treeView is the widget that displays data.
No other modifications where made while integrating modeltest with my app.
Qt version is 4.7.
This will sound a little overgeeky - but it is, in fact, what the ModelChecker dev intended for you to do ;) When you hit one of the asserts, go to the point in the code where it is hit and read the comments which are written along with it. The entire thing is extremely heavily commented, and describes what is breaking and likely reasons why. This is by far easiest to do if you run your app through a GUI debugger, such as that included in for example KDevelop, Qt Creator or Visual Studio.
The reason you are getting this error is because you aren't actually using the ModelTest inside a proper QTestLib test case. If you take a look at /tests/auto/modeltest (where you presumably got the modeltest class in the first place), you can see how to properly construct a test case using the ModelTest.

Xcode 4 disable "fix-it" popup

I'm fine with Xcode 4 telling me that I have an error. But that pop-up pretty much always has the wrong solution. Is there any way I can get rid of it permanently?
From what I've seen, it looks like you may need to disable the various types of warnings one by one. A list is found here:
http://developer.apple.com/library/mac/#documentation/DeveloperTools/gcc-4.0.1/gcc/Warning-Options.html#Warning-Options
To change them:
Bring up the project navigator and choose your project. In the main window that appears, choose "All". Under the section "LLVM compiler 2.0 - Warnings", choose "Other Warning Flags". Add the flag "Wno-idiomatic-parentheses" for both "Debug" and "Release." Now clean and recompile ( from if(self = [super init]) - LLVM warning! How are you dealing with it?)
I noted in the apple dev link that the following option should inhibit all warnings:
-w Inhibit all warning messages.

Resources