I can't seem to access preview for any of my views in any of my swift projects at all (using Mac to code and using iPhone 16 pro as preview and simulation, simulation can work), even after restarting Mac and Xcode itself.
The preview section has a popup saying "Cannot preview in this file, unexpected error occured" (for every file), please tell me what is wrong and help me solve it to see the preview, thank you!
details
Swift Student Challenge
RSS for tagAsk questions and connect with other challenge applicants.
Posts under Swift Student Challenge tag
52 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
Hey,
If I were a PhD student enrolled at an accredited academic institution, would I still be eligible to participate in the Swift Student Challenge?
Thank you!
Desarrolle una app en xcode 16 para version minima de ios 16, todo funcionaba bien hasta la version 17 de ios, pero para ios 18 empezaron los problemas, los botones no responden a un toque, se deben sostener con un toque largo para que funcionen, ahora de un momento a otro ya no funciona para ninguna version de ios, los eventos tactiles deben ser prolongados para que se activen, en los botones o elementos que usan el tapgesture, he probado de todo versiones de xcode, versiones de swiftui, dispostivos reales, emuladores de todo y nada funciona, algun consejo o solucion gracias
I am getting issue on my application that my device is jailbroken security message I updated my device 18.2 what the solution
When making a new Swift Playground via Xcode > New > Project > iOS > App Playground, as a .swiftpm package, the settings are very limited, including setting the minimum OS version.
This is incredibly irritating because I can't keep make @available blocks because that would double the size of my code, and I can't use SwiftData (for example) because my app needs to also support iOS 16.
Is there a way to set the minimum OS or some other upload type accepted for Apple so that I can change this simple setting?
Thank you
I want to use Swift language to write code for drawing multiple polygons. I would like to find some examples as references. Can anyone provide example code or tell me where I can see such examples? Thank you!
Following the examples from the official documentation: https://developer.apple.com/documentation/swiftui/adding-a-search-interface-to-your-app
When the user types in the text in the search field, the list is updated with filtered results. How do I cause these changes to be animated?
I tired to put .animated() after the .searchable modifier, the result was what I am looking for, however it also broke the animation of the search field getting/releasing focus.
Hello,
Although the Swift Student Challenge for 2025 has not yet been announced and is not officially taking place, I have a question regarding last year’s rules in the Swift Student Challenge. This is, of course, assuming the rules will be similar if the challenge runs again next year.
I am interested in utilizing CreateML to design a text classifier model. Given the substantial amount of data required for machine learning, am I allowed to outsource data from open-source libraries and/or social media platforms, provided that these resources abide by their terms of service? My primary concern is if I must create my own data as that will be time-consuming and more biased.
Thank you,
Jesse
I have an app which have an Immersive Space view and it needs the user to have a button in the bottom which have a fixed place in front of the user head like a dashboard in game or so but when the user get too close to any3d object in the view it could cover the button and make it inaccessible and it mainly would prevent the app for being approved like that in appstoreconnect I was working before on SceneKit and there was something like camera view Znear and Zfar which decide when to hide the 3d model if it comes too close or gets too far and I wonder if there is something like that in realityView / RealityKit 4.
Here is My Code and the screenshots follows
import SwiftUI
import RealityKit
struct ContentView: View {
@State var myHead: Entity = {
let headAnchor = AnchorEntity(.head)
headAnchor.position = [-0.02, -0.023, -0.24]
return headAnchor
}()
@State var clicked = false
var body: some View {
RealityView { content, attachments in
// create a 3d box
let mainBox = ModelEntity(mesh: .generateBox(size: [0.1, 0.1, 0.1]))
mainBox.position = [0, 1.6, -0.3]
content.add(mainBox)
content.add(myHead)
guard let attachmentEntity = attachments.entity(for: "Dashboard") else {return}
myHead.addChild(attachmentEntity)
}
attachments: {
// SwiftUI Inside Immersivre View
Attachment(id: "Dashboard") {
VStack {
Spacer()
.frame(height: 300)
Button(action: {
goClicked()
}) {
Text(clicked ? "⏸️" : "▶️")
.frame(maxWidth: 48, maxHeight: 48, alignment: .center)
.font(.extraLargeTitle)
}
.buttonStyle(.plain)
}
}
}
}
func goClicked() {
clicked.toggle()
}
}
Hi everyone,
We have a user experiencing a display issue. Here's a screenshot they shared with us. Unlike in the simulator, where we see three icons, their display shows two buttons abbreviated with ellipses. The device is iPhone 12 mini with iOS 17.6.1.
The user isn't using any accessibility settings or large text size. Does anyone know what setting might be causing this? Any advice would be appreciated!
Thanks!
All errors in TranslationError return the same error code, making it difficult to differentiate between them. How can this issue be resolved?
Say you have a SwiftData object that doesn't allow optionals:
@Model
class MySet: Identifiable {
var id: UUID
var weight: Int
var reps: Int
var isCompleted: Bool
var exercise: Exercise
Then you get from your MySet data a list of these MySets and append them into a State:
@State var sets: [MySet]
if let newSets = exercise.sets { //unwrapping the passed exercises sets
if (!newSets.isEmpty) { //we passed actual sets in so set them to our set
sets = newSets
}
And you use that State array in a ForEach and bind the Textfield directly to the data like so:
ForEach($sets){ $set in
TextField("\(set.weight)", value: $set.weight, formatter: NumberFormatter())
.keyboardType(.decimalPad)
TextField("\(set.reps)", value: $set.reps,formatter: NumberFormatter())
.keyboardType(.decimalPad)
}
This will bind whatever is written into the TextField directly to the SwiftData object which is a problem because say you have 50 written and you want to change it to 60 you need to be able to clear the 50 to write the 60 and since the SwiftData object doesn't allow nil it will allow you to remove the 0 but not the 5. Is there anyway to remedy this without having the swiftData object allow optionals for example catching the clearing of the TextField and making it 0 instead of nil when its cleared?
hi
im fairly new to coding.. about a month, just so u know.. 😇
I am going through the tasks in (Swift Playgrounds) and I am currently in (Learning to code 2) the chapter is (Random gems everywhere) and I tried every possible solution to complete it, but to no avail!
any suggestions, comments, or corrections or tips, would be greatly appreciated!
I will attach some screenshots for a reference of what I'm trying to accomplish..
when ios app will get crashed at that time delegate method applicationWillTerminate(_:) is not calling. So which delegate method get call when app is crashed
Hello, Developer team! Does anyone have an idea about the problem I'm facing with the simulator ? I'm learning how to code in SwiftUI and my simulator was working just fine but yesterday I close my laptop the other day and open today and see the code :
import SwiftUI
import SwiftData
@main
struct first_projectApp: App {
var sharedModelContainer: ModelContainer = {
let schema = Schema([
Item.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)
do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()
var body: some Scene {
WindowGroup {
ContentView()
}
.modelContainer(sharedModelContainer)
}
}
I don't know where it comes from . I used IOS 17.5 I try to upgrade to IOS 18 but that didn't fix the problem. Currently I'm seeing 3 errors :
Showing Recent Errors Only
Build target first project of project first project with configuration Debug
Ld /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Products/Debug-iphonesimulator/first\ project.app/first\ project.debug.dylib normal (in target 'first project' from project 'first project')
cd /Users/amedekatamatode/Desktop/calculator/first\ project
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios17.5-simulator -dynamiclib -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator18.0.sdk -O0 -L/Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -L/Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Products/Debug-iphonesimulator -F/Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/EagerLinkingTBDs/Debug-iphonesimulator -F/Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Products/Debug-iphonesimulator -filelist /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/first\ project.build/Debug-iphonesimulator/first\ project.build/Objects-normal/arm64/first\ project.LinkFileList -install_name @rpath/first\ project.debug.dylib -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/first\ project.build/Debug-iphonesimulator/first\ project.build/Objects-normal/arm64/first\ project_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -Xlinker -objc_abi_version -Xlinker 2 -Xlinker -debug_variant -fobjc-link-runtime -fprofile-instr-generate -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/first\ project.build/Debug-iphonesimulator/first\ project.build/Objects-normal/arm64/first_project.swiftmodule -Xlinker -alias -Xlinker _main -Xlinker ___debug_main_executable_dylib_entry_point -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Intermediates.noindex/first\ project.build/Debug-iphonesimulator/first\ project.build/Objects-normal/arm64/first\ project_dependency_info.dat -o /Users/amedekatamatode/Library/Developer/Xcode/DerivedData/first_project-ebsglpjmgwtgzpflkvloohzydjuf/Build/Products/Debug-iphonesimulator/first\ project.app/first\ project.debug.dylib
ld: warning: Could not parse or use implicit file '/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks/SwiftUICore.framework/SwiftUICore.tbd': cannot link directly with 'SwiftUICore' because product being built is not an allowed client of it
Undefined symbols for architecture arm64:
"_main", referenced from:
___debug_main_executable_dylib_entry_point in command-line-aliases-file
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Undefined symbol: _main
Linker command failed with exit code 1 (use -v to see invocation)
I hope someone helps me how to figure it out. Thank you!
I was a Swift Student Challenge winner in 2020 and 2021 and I was wondering if there was somewhere I could receive a confirmation of my winner status?
I’m currently building a petition for an O1 visa, and my attorney told me that the screenshots I have of the website from when I won many years ago would probably not be sufficient as they’re cropped and not of the full screen. I have no way to go back to the old status page or even the events tab in the developer account page since it was removed. Is there somewhere on the developer website I should look? Is there a way to get something sent by Apple to help me out here? I've sent an email to swiftstudentchallenge@ apple.com but haven't received a response just yet so thought I'd ask here too.
I feel like this should be possible somehow, even for just using on a resume for example. It's why I assumed the events tab existed.
In swift if using custom dateFormat like "dd-mm-yyyy" and device follows japanese calendar now get dateForm dateFormatter , expected "30-05-Reiwa6". but dateFormatter return string is "30=05-0006"
Hello everyone,I am a student who is working on my final project of my college.I do not get an official development account since I do not need to put my app on AppStore.
In my project,I need to use the camera of iOS device, and I know I need to add NSCameraUsageDesciption in Info.plist.However, as I add the description in my Info and build my project, it failed and says"Provisioning profile "iOS Team Provisioning Profile: " doesn't include the NSCameraUsageDescription and NSPhotoLibraryUsageDescription entitlements."
I also notice that in the Info.plist file, when I change the property type to entitlements,I just cannot find NSCameraUsageDescription when I add row.
What's the problem?Is this because I am not an official developer?
so my code is:
import UIKit
class CanvasView: UIView {
let originX: CGFloat = 150
let originY: CGFloat = 300
let squareSide: CGFloat = 100
var rubiksCubeDelegate: RubiksCubeDelegate? = nil
var fromCol: Int = -1
var fromRow: Int = -1
override func draw(_ rect: CGRect) {
drawFront()
drawTop()
drawRight()
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let firstTouch = touches.first!
let fingerLocation = firstTouch.location(in: self)
fromCol = Int((fingerLocation.x - originX) / squareSide)
fromRow = Int((fingerLocation.y - originY) / squareSide)
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
let firstTouch = touches.first!
let fingerLocation = firstTouch.location(in: self)
let toCol: Int = Int((fingerLocation.x - originX) / squareSide)
let toRow: Int = Int((fingerLocation.y - originY) / squareSide)
print("V: from (\(fromCol), \(fromRow) to (\(toCol), \(toRow))")
rubiksCubeDelegate?.moveFinger(fromCol: fromCol, fromRow: fromRow, toCol: toCol, toRow: toRow)
}
func drawFront() {
drawsquare(col: 0, row: 0, color: .green)
drawsquare(col: 1, row: 0, color: .orange)
drawsquare(col: 2, row: 0, color: .blue)
drawsquare(col: 0, row: 1, color: .white)
drawsquare(col: 1, row: 1, color: .yellow)
drawsquare(col: 2, row: 1, color: .red)
drawsquare(col: 0, row: 2, color: .green)
drawsquare(col: 1, row: 2, color: .blue)
drawsquare(col: 2, row: 2, color: .orange)
}
func drawTop() {
drawTopParallelogram(col: 0, row: 0, color: .red)
drawTopParallelogram(col: 0, row: 1, color: .blue)
drawTopParallelogram(col: 0, row: 2, color: .green)
drawTopParallelogram(col: 1, row: 0, color: .yellow)
drawTopParallelogram(col: 1, row: 1, color: .red)
drawTopParallelogram(col: 1, row: 2, color: .white)
drawTopParallelogram(col: 2, row: 0, color: .blue)
drawTopParallelogram(col: 2, row: 1, color: .orange)
drawTopParallelogram(col: 2, row: 2, color: .green)
}
func drawRight() {
drawRightParallelogram(col: 0, row: 0, color: .orange)
drawRightParallelogram(col: 1, row: 0, color: .red)
drawRightParallelogram(col: 2, row: 0, color: .red)
drawRightParallelogram(col: 0, row: 1, color: .blue)
drawRightParallelogram(col: 1, row: 1, color: .orange)
drawRightParallelogram(col: 2, row: 1, color: .white)
drawRightParallelogram(col: 0, row: 2, color: .white)
drawRightParallelogram(col: 1, row: 2, color: .blue)
drawRightParallelogram(col: 2, row: 2, color: .green)
}
func drawRightParallelogram(col: Int, row: Int,color: CubeColor) {
colorOf(color: color).setFill()
let topLeftX: CGFloat = originX + 3 * squareSide + CGFloat(col) * squareSide/2
let topLeftY: CGFloat = originY - CGFloat(col) * squareSide/2 + CGFloat(row) * squareSide
let path = UIBezierPath()
path.move(to: CGPoint(x: topLeftX, y: topLeftY))
path.addLine(to: CGPoint(x: topLeftX + squareSide/2, y: topLeftY - squareSide/2))
path.addLine(to: CGPoint(x: topLeftX + squareSide/2, y: topLeftY + squareSide/2))
path.addLine(to: CGPoint(x: topLeftX, y: topLeftY + squareSide))
path.close()
path.fill()
path.stroke()
}
func drawTopParallelogram(col: Int, row: Int,color: CubeColor) {
colorOf(color: color).setFill()
let bottomLeftX: CGFloat = originX + CGFloat(col) * squareSide + CGFloat(2 - row) * squareSide/2
let bottomLeftY: CGFloat = originY + CGFloat(row - 2)*squareSide/2
let path = UIBezierPath()
path.move(to: CGPoint(x: bottomLeftX, y: bottomLeftY ))
path.addLine(to: CGPoint(x: bottomLeftX + squareSide/2,y: bottomLeftY - squareSide/2))
path.addLine(to: CGPoint(x: bottomLeftX + squareSide/2 + squareSide, y: bottomLeftY - squareSide/2))
path.addLine(to: CGPoint(x: bottomLeftX + squareSide, y: bottomLeftY))
path.close()
path.fill()
path.stroke()
}
func drawsquare(col: Int, row: Int,color: CubeColor) {
colorOf(color: color).setFill()
let squareX: CGFloat = originX + CGFloat(col) * squareSide
let squareY: CGFloat = originY + CGFloat(row) * squareSide
let square = UIBezierPath(rect: CGRect(x: squareX, y:squareY, width:squareSide, height:squareSide))
square.fill()
square.stroke()
}
func colorOf(color: CubeColor) -> UIColor {
var c: UIColor = .black
switch color {
case .blue:
c = UIColor.blue
case .green:
c = UIColor.green
case .orange:
c = UIColor.orange
case .red:
c = UIColor.red
case .white:
c = UIColor.white
case .yellow:
c = UIColor.yellow
}
return c
}
}
at "func drawFront() {" it said "Thread 1: breakpoint 1.1 (1)"
can any one help me fix this the app is always pausing
My app has a view that appears from a NavigationLink. The view has a list and a search bar; when a user taps the search bar the keyboard appears correctly. BUT, the entire view, including the navigationBarTitle and the navigationBarBackButton, move upward. This causes the navigationBarTitle and the navigationBarBackButton to move under the notch, where the back button doesn't work. To use the back button the user has to dismiss the keyboard with the return key, which moves the navigationBarTitle and back button downward and then tap the back button.
This cannot be an uncommon situation, but I've spent the morning trying to find a way to prevent the NavigationBarTitle and <back button from moving upward where the user can't use the <back button when the keyboard appears.
Is there a way to too that?