Retrieving finder comment of a file in iOS application - ios

I am trying to use the finder comment field of a file stored in the folder of my iOS application (I'm talking about local storage, not in the cloud). The function MDItemCreate that would enable me to do so easily is not available in iOS applications apparently, which must be why the build currently fails with the error warning : "Cannot find 'MDItemCreate' in scope". Apple documentation in fact states that this method is only available on MacOS.
I have tinkered with FileManager but it doesn't grant access to comments.
This topic seems related but the solution is quite opaque to me.
My understanding of Swift is rather limited, if you would be so kind as to provide a simple and detailed answer I'd be much grateful.
With thanks,
Julien

I'm not completely certain, but messages like "Cannot find 'X' in scope" are often due to a forgotten import statement. MDItemCreate(_:_:) (docs) seems to be part of the Core Services framework, which has been part of iOS since iOS 12. Have you imported the framework?
You can do this (at the top of your .swift file) as follows:
import CoreServices

Related

macOS, iOS & tvOS documentation missing imports?

I'm looking into iOS/tvOS docs for GCKeyboard & GCMouse types.
However Apple docs seem to be missing basic info such as what I import to use a type. For example C# docs always show what libraries are needed on MS websites for types. So do Googles Android docs. I'm not seeing this on Apples docs here: https://developer.apple.com/documentation/gamecontroller/gckeyboard
Is there an easy way in ObjC or Swift to check where a type is from?
Does Apple provide any way to lookup what source file I should import for a type? How do people normally go about these lacking docs with xCode dev work?
Apple do indicate on its doc on which framework the class/object that the document referred to is relevant. See my picture for details. Its has a documentation hierarchy from the framework down to the objects and apis within it.
Specifically for GameController framework you’d use the following import
import GameController
A nice anecdote:
In older class and objects it is also customary to add the initials of the framework/library as a prefix for the name. In this case GC(i.e game contoller)Keyboard. Or UI(UIKit)ViewController. With newer libraries like SwiftUI and Combine they have stopped using the prefix.
The prefix was used due to legacy Objetive-C limitation for namespace.

Google Flatbuffer iOS

Currently, I got a task to explore google flatbuffers on iOS and OSX. I explored the documentation provided by Google.
Also found some libraries on Github on swift language like FlatBuffersSwift and others that implement the flatbuffers.
So, I have mainly two concerns on that
Will Apple approve my app if I used this in my iOS application?
Is it possible to create schema on runtime from JSON ? or we must manually create schemas (.fbs) and use flatc library for creating model binaries (like .swift) files.
Any help please
Thanks in advance
1) There's nothing in the Apple approval process that has to do with your choice of serialization library.
2) To get the benefits of this library, you want to create a schema and generate code for it ahead of compilation time. If your use case is so dynamic that you want to be able to do everything at runtime, you're probably better off with a good JSON library.

Semantic Issue: Cannot find the protocol declaration for ‘ARSessionDelegate’

Do anyone know the workaround for the build error on Xcode?
All suggestions are welcomed.
E.G: Impossible in that way, Possible with Objective-C, not Swift
Environment:
Swift:3.2, Xcode:9.2, Unity:2017.3.0f1, iOS:11.2.1
Condition:
I’m trying to make Native Plugin for Unity using Swift like this.
Unity C# -> Objective-C -> Swift
For now, I could access the iPhone camera roll from Unity.
The Project Name is GetDepthSample here.
Error Detail:
As soon as I add ARSessionDelegate on the class definition, I got the following error.
CameraRollSample.swift
Other Information:
GetDepthSample-Swift.h (generated automatically on Xcode) shows the following error.
GetDepthSample-Swift.h
It’s possible to jump to Definition of the protocol ARSessionDelegate.
Not only ARSessionDelegate but also MetalKit shows the similar error.
The original Unity Project
https://github.com/wapa5pow/CameraRollSample
Many thanks!
Looking at the header that you posted in the comment, it seems to me that maybe you need to include the ARKit framework in the project settings in Xcode. Although this generally tends to work automatically clearly something in your setup has that missing.

Generic implementation of 3rd party Libraries and Frameworks in Swift

I see there’s many libraries, open source, like Cocos2d, ShareKit, FormatterKit, etc. that seems up to date. (Check GitHub).
But still, implementation, snippets, samples and manual are intended to be written in Objective-C.
But, a method is a method… I think… If I get an instance of any framework/library of these and I call the method in a full Swift enviroment, would I be affected behind the scenes?
After June WWDC Swift gonna get serious, Apple is pushing hard, I’m just getting ready for the move and I don’t want my Apps to implement a soon-to-be deprecated library implementation in Objective-C.
I do not understand your question so much that I will regard your question as "Is it possible to use the Objective-C&Swiftin the same project?"
Yes, Apple claimed that developers can use Bridging-Header to implement double languages development, whatever your main developing language is ObjC or Swift. The specific details and theories about it you shall check from there.
Next I want to tell you some errors occurred in my project when I used Bridging-Header.
I always meet this kind of problem like import 'file not found'. I think you can try to check your file&folder hierarchy. Such as you have a root folder named Project, as is often the case, there is another Project in your previous Project, the root folder.
And Checking the Objective-C Bridging Header in the Build Setting. Sometime error can occurred for Project/Project/Bridging-Header.h. And the error can be corrected by changing the definition as Project/Bridging-Header.h.
If the location of Bridging-Header.h is not matching with the definition in the Build Setting, the error like import file not found will occur.
I just tell your my solution for Bridging issue I already met, I hope it can help you.

Whirlyglobe private API complain during app submission

I have a simple app which uses whirlyglobe framework (2.2). Otherwise, it is pretty basic program with Apple frameworks.
When I tried to validate the app (and during the distribution, Xcode complains that my app is using private API; specifically it calls "rootElement", and "attributeForFont:". I suspect these functions are part of WhilyGlobe component distribution.
What is the easiest way to remove those files from the framework? Do I need to have the source and compile the framework myself? Or is there a simpler way?
Solved. Here is what I did:
1) Searched in github repository of WhirlyGlobe and found the file that uses the functions which caused issue.
2) I did not need the functionality provided by the file that had the functions.
3) Removed the references (class instantiation) to the file from my project.
That's actually part of the KissXML framework and the implementation is in there. I suspect Apple's test is in error.
In any case, if you're not using the WMS functionality, you can probably drop it out just fine.

Resources