Hi!
I'm participating in the Swift Student Developer competition this year, which requires developers to present a Swift Playground to Apple. I'm used to making normal Xcode projects, and am having trouble finding a Swift Playgrounds version of the Copy Bundle Resources build phase (I don't think it is possible to edit build phases in a Swift Playground).
I created a '.usdz' file from a 3D model I designed using Reality Converter and added it to the root of my Swift Playground project. I access the file programmatically from the App Bundle like so (fileName is a non-nullable String):
guard let path = Bundle.main.path(forResource: fileName, ofType: "usdz") else { fatalError("Couldn't find the USDZ file.") }
At runtime, this throws the Couldn't find the USDZ file error, as the file isn't being copied to the App Bundle.
In a normal Xcode project, according to this StackOverflow question, I can get xcodebuild to copy my file over by specifying it in the Copy Bundle Resources build phase, however, in a Swift Playground (required by Apple), I am restricted from modifying Xcode's buildphases (the option is not present when clicking on the default target - the only options are General, Signing & Capabilites and Package Dependencies).
How can I ensure that resources are copied over to the App Bundle at buildtime in a Swift Playground?
If this is not possible, are there any other options besides using the Bundle.main.path API for accessing the USDZ file (to load a QuickLook preview) at runtime?
QuickLook
RSS for tagCreate previews of files to use inside your app or perform simple edits on previews using QuickLook.
Posts under QuickLook tag
46 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Is there any way to identify if the QLPreviewController is in markup mode? I have a custom QLPreviewController which is used to preview and edit images in my app. I need to identify when entering the markup mode and make some changes in the navigation bar based on this. But I could not find any variable or delegate methods to identify this.
Any help will be appreciated.
I am creating a MacOS app embedding the QuickLook extension in it.
The other day, I uploaded it to App Store Connect and had it reviewed.
But it was rejected due to the following reason.
Your app incorrectly implements sandboxing, or it contains one or more entitlements with invalid values. Please review the included entitlements and sandboxing documentation and resolve this issue before resubmitting a new binary.
com.apple.security.temporary-exception.files.absolute-path.read-only /
This entitlement is also included in my app's meta data on my account page of App Sore Connect. Including it, I can find the following two entitlements related to "temporary-exception" in the meta data.
com.apple.security.temporary-exception.files.absolute-path.read-only: ( "/" )
com.apple.security.temporary-exception.mach-lookup.global-name: ( "com.apple.testmanagerd", "com.apple.dt.testmanagerd.runner", "com.apple.coresymbolicationd" )
To tell the truth, about Sandbox entitlements for QuickLook extension, what I intentionally set on the Xcode project are the next two items only. And actually I have not ever recognized that the entitlements related to "temporary-exception" above are included in my app's bundle.
com.apple.security.app-sandbox: true
com.apple.security.files.user-selected.read-only: true
I think these "temporary-expection" entitlements are essential ones for the QuickLook extension and it looks like that Xcode automatically attached them in the process of creating app's build. If they are forced to be attached by getting the QuickLook extension sandboxed, I don't know what I should do.
Although I explained my thought to the reviewer, but I could not change the situation. Is there no way to get solution besides removing the QuickLook extension from my app ?
Can a customized Pages document be created and integrated into an Apple Multiplatform App?
HI, I'm new to IOS Dev.
I am developing an app with AR function. I found there are a few tutorials about AR Quick Look. However, they're all use storyboard. Is there any way to use swift ui to demonstrate AR Quick Look.
ContentView.swift
import SwiftUI
//import QuickLook
//import ARKit
struct ContentView: View {
@State private var isPresented = false
var body: some View {
VStack {
Button {
isPresented = true
print("click")
} label: {
Text("Click to AR")
.font(.title)
.fontWeight(.bold)
.padding()
.background()
.cornerRadius(16)
}
.sheet(isPresented: $isPresented) {
ARView()
}
.padding()
}
}
}
#Preview {
ContentView()
}
ARView.swift
import SwiftUI
struct ARView: UIViewControllerRepresentable {
func makeUIViewController(context: Context) -> QuickViewController {
QuickViewController()
}
func updateUIViewController(_ uiViewController: QuickViewController, context: Context) {
uiViewController.presentARQuickLook()
}
typealias UIViewControllerType = QuickViewController
}
QuickViewController.swift
import UIKit
import QuickLook
import ARKit
class QuickViewController: UIViewController, QLPreviewControllerDelegate,
QLPreviewControllerDataSource {
// 有幾個模型要呈現
func numberOfPreviewItems(in controller: QLPreviewController) -> Int {
return 1
}
// 顯示模型
func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> QLPreviewItem {
let url = Bundle.main.url(forResource: "bear", withExtension: "usdz")!
// Load file url
let preview = ARQuickLookPreviewItem(fileAt: url)
return preview
}
func presentARQuickLook() {
let previewController = QLPreviewController()
previewController.dataSource = self
present(previewController, animated: true)
print("Open AR model!")
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
Is it possible to somehow support copy/update edit modes when using quickLookPreview modifier, like in QLPreviewController? After pressing 'Done' it only allows me to discard or save to files instead.