Swift Playgrounds

RSS for tag

Learn and explore coding in Swift through interactive learning experiences on the Swift Playgrounds app for iPadOS and macOS.

Posts under Swift Playgrounds tag

94 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Invalid code signature problem with Xcode12
I'm practicing a swift 5 class, and have this issue: Could not launch “I AM RICH” Domain: IDEDebugSessionErrorDomain Code: 3 Failure Reason: The operation couldn’t be completed. Unable to launch com.superdie.I-AM-RICH because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user. User Info: {     DVTRadarComponentKey = 855031;     RawLLDBErrorMessage = "The operation couldn\U2019t be completed. Unable to launch com.superdie.I-AM-RICH because it has an invalid code signature, inadequate entitlements or its profile has not been explicitly trusted by the user."; } I'm not sure what can I do, some help would be nice :)
24
5
52k
Aug ’23
Get Started with Apps Stuck in Playgrounds
The “Get Started with Apps” in Playgrounds looks great but it won’t allow me to advance to the next activity. It seems to think that my solution is incorrect, but what I did matches the solution provided in the “hint.” This could be corrected by either allowing for more variety in the responses, or by allowing the user to advance to the next activity regardless of whether the response they provided was correct.
10
2
2.6k
1w
"public headers ("include") directory path for 'Guide' is invalid or not contained in the target" error
Hi, I have a problem with making a swift playgrounds app walkthrough. I followed the steps exactly and modified my Package.swift a bit (in the targets section): .executableTarget(name: "App", dependencies: ["Guide"], path: "App"),         .target(             name: "Guide",             path: "Guide",             resources: [             .process("Guide.tutorial"),             ]) Now when I open the project in Playgrounds I get this error: public headers ("include") directory path for 'Guide' is invalid or not contained in the target Any help would be appreciated. Thanks
2
0
2.3k
Nov ’23
NavigationSplitView how to disable the side bar, to make it like the reminder app in iPad?
I want to make it like this How to disable the button that open the side bar, I only need the content and the detail view. I don't need the sidebar view. Below is my code import SwiftUI @available(iOS 16.0, *) struct Screen: View { @ObservedObject var userData = UserData() @State private var isIntroShown = true @State var Itema: Bool = false @State private var showFoodDetail = false @State var rb: Bool = false @State var Setting: Bool = false @State var Recipe: Bool = false @Environment(\.defaultMinListRowHeight) var minRowHeight @Environment(\.colorScheme) var colorScheme @State private var searchText = "" private let adaptiveColumns = [ GridItem(.adaptive(minimum: 170)) ] var columns = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2) var filteredRooms: [Room] { if searchText.isEmpty { return userData.rooms } else { return userData.rooms.filter { room in let foodNames = room.food.map { $0.name.lowercased() } return room.name.lowercased().contains(searchText.lowercased()) || foodNames.contains { $0.contains(searchText.lowercased()) } } } } @State private var columnVisibility = NavigationSplitViewVisibility.doubleColumn var body: some View { NavigationSplitView (columnVisibility: $columnVisibility){ } content: { ScrollView{ GridView() .padding(.horizontal) .padding(.bottom, 20) }.toolbar { ToolbarItem(placement: .bottomBar){ Button(action:{self.Itema = true}) { HStack { Image(systemName: "plus.circle.fill").resizable().frame(width: 20, height: 20).foregroundColor(.white) Text("New Item").foregroundColor(.white).bold() } } .sheet(isPresented: self.$Itema){ NewItem(userData: self.userData) } } ToolbarItem(placement: .bottomBar){ Button(action:{self.rb = true}) { HStack { Text("New Room").foregroundColor(.white) } } .sheet(isPresented: self.$rb){ NewRoom(userData: self.userData) } } ToolbarItem(placement: .navigationBarTrailing){ Button(action:{self.Setting = true}) { HStack { Image(systemName: "gear").foregroundColor(.white) } } .sheet(isPresented: self.$Setting){ NavigationView { NewItem( userData: userData) .navigationBarItems(trailing:Button(action: { self.Setting = false }){ Text("Done") } ) } } } } .background(Color(red: 203/255, green: 237/255, blue: 207/255)) } detail: { ZStack { Text("") } .frame(maxWidth: .infinity, maxHeight: .infinity) .background(Color(red: 220/255, green: 247/255, blue: 234/255)) } .searchable(text: $searchText) } }
1
1
1.1k
Jul ’23
Making a .swiftpm app iPad only?
Is there a way to make a .swiftpm app only available on the iPad? I can see where I would restrict it in the autogenerated Package.swift, but there's nowhere in the Swift Playgrounds or Xcode 14 interface that I can find that will let me restrict it to iPad only. It's causing my app to get rejected by the App Store team, as the iPhone version is too crowded... but it's designed for iPad... I just need to be able to specify that somewhere...
2
0
1.3k
Aug ’23
Swift Playgrounds: Unable to Resolve Package ‘Graphics’ and ‘unzip’ Executable Not Found Error
When I import a package in Swift Playgrounds on my iPad, I receive the following error: This package interactions with libgit2, and it don’t have any release in the origin repository, so I find a existing fork which have release. Playgrounds version: 4.3.1(1727.53) Is it means that I install a software that supports unzip on iPad?
0
0
674
Aug ’23
Not able to reference classes/structs in Swift playground sources
I have to admit that this is strange for me. Though I have been using playgrounds for years, but I only write small pieces of code to test simple ideas, and I never used another source file. Today I want to add a new struct in Sources folder. To my surprise, I am not able to reference the struct in the main playground file. Sources/testlets.swift: struct Dummy { var name: String } MyPlayground: var box = Dummy(name: "abc") // error: /.../MyPlayground.playground:22:11 Cannot find 'Dummy' in scope
2
0
617
Aug ’23
Converting a .swiftpm app to a .xcodeproj-based one?
I've decided I want my app, which has been shipped to the App Store, to support CloudKit, but it's a .swiftpm app (so I could work on it on the go on an iPad and Swift Playgrounds). I've taken a half-hearted stab at it (there's more pressing stuff to work on and this is a nice to have for the moment), but is there a way to set up a new workspace in Xcode where I have two targets: a .swiftpm version of the app and a .xcodeproj app so I can enable CloudKit for my app and also ship it to the App Store with the same identifier?
0
1
574
Aug ’23
Swift can't read the textDocumentProxy.documentContextBeforeInput after entering a newline
I am typing string text on textDocumentProxy in a custom keyboard app. The input text includes newlines and punctuation letters, but when I try to edit the textDocumentProxy field, the textDocumentProxy.documentContextBeforeInput in case a newline \n is included, it does not return full content before input. I placed the cursor on after the good morning word center, I got only good string text. The remaining "hi folks", words do not return. Here are some examples I have tried. var inputText = "Hi folks, Good morning to everyone " var txtBeforeCursor = textDocumentProxy.documentContextBeforeInput ?? "" print("Before Cursor text : ",txtBeforeCursor) Output is: Before Cursor text : Good
0
0
583
Aug ’23
:thread return -x Error Encountered a crash
Im new to Xcode getting this error in this playground, can someone help me here... This was In a playground btw Thanks, struct Digit { var number : Int init(_ n: Int){ self.number = n } mutating func changeNumberTo(_ n:Int) { self.number = n } func otherFunction(_ f: ()->()) { } mutating func callAnotherFunction() { otherFunction { self.changeNumberTo(345) // * } } } var d = Digit(123) // Digit is a struct print(d.number) //123 var d2 = d //Assignment! d2.number = 42 print(d.number) enum Node { case none(Int) indirect case left(Int, Node) indirect case right(Int, Node) indirect case both(Int, Node, Node) }
2
0
434
Sep ’23
Any approaches to Swift Playgrounds on macOS Monterey?
Hi, dear community, I recently updated my old Macbook pro(model 2016) to Monterey(which is the latest macOS that support 2016 model), but the Swift Playgrounds on AppStore requires macOS 13. Is there any way I can get the app, just like Xcode? Xcode provides an alternative way to download the xip file of an older version, but playgrounds does. Many thanks in advance, any help will be appreciated!
1
0
627
Oct ’23
XCode 15 bug - Playground cannot find file inside Resources
I have the simplest Playground to display image. I have images inside Resources. Somewhat it does not work and I am really confused. I am using macOS XCode. I think on iPad Swift Playground this might work. import SwiftUI import PlaygroundSupport struct ContentView: View { var body: some View { Image("image1") .resizable() .frame(width: 512, height: 512) } } let hostingController = UIHostingController(rootView: ContentView()) PlaygroundPage.current.liveView = hostingController
2
1
705
Sep ’23
Swift Playgrounds beta with support for iOS 17 and macOS 14 expired!
Since Swift Playgrounds was able to submit Apps to the AppStore ,Apple stated that it can be used to develop apps without having to use Xcode. But if you do so you are lost: The Testflight beta versions of Swift Playgrounds with API support for iOS 17 and macOS 14 have expired one week before the new systems become/became available and there is still no final version! If you used Playgrounds to develop an iOS 17 ready version of your app you can't do anything now and that at a time where the users get their hands on the new OS. That is really bad.
3
3
864
Oct ’23