Post

Replies

Boosts

Views

Activity

Reply to Adding External Files to an Xcode Project
I tried what you described and found that Xcode 12 (12.3, actually) imports the folder as resources even if it contains .swift files. You should better send a feedback - https://developer.apple.com/bug-reporting/ soon. Is there a workaround? Until fixed, you may need to choose each source file when adding. (Cmd-click or Cmd-A would work when choosing.) UPDATE Have you tried using Create Group instead of Create folder references? You can change the Location of the Group to Absolute Path if you prefer.
Dec ’20
Reply to Slow xcode
How much memory does your iMac have? As far as I checked the specs of 2017 iMac, it should have enough resources to run Xcode. I also tried to initialize the mac What do you mean by initialize? Did you re-installed macOS and removed all the apps?
Dec ’20
Reply to Filter array by String
Do you know how to write the little more complex code? You can try something like this: struct ResultView: View { &#9;&#9;@State var websites : [Website] &#9;&#9;@Binding var text : String &#9;&#9;@State var groupedArray : [String: [Website]] = [:] &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;List{ &#9;&#9;&#9;&#9;&#9;&#9;ForEach(filteredKeys(byName: text), id: \.self){key in //<- &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Section(header: Text(key)) { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;ForEach(groupedArray[key]!.filter{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;text.isEmpty || $0.name.contains(text) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}, id: \.self) {website in &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;NavigationLink( &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;destination: WebView(website: website, url: URL(string: website.url)), &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;label: { &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Text(website.name) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Spacer() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;if website.image != ""{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;RemoteImage(url: website.image).frame(width: 25, height: 25, alignment: .center) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}else{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;Loader() &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;}) &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;}.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height, alignment: .center) &#9;&#9;&#9;&#9;.navigationBarTitle("Results") &#9;&#9;&#9;&#9; &#9;&#9;&#9;&#9;.colorScheme(.light) &#9;&#9;&#9;&#9;.onAppear { &#9;&#9;&#9;&#9;&#9;&#9;groupedArray = Dictionary( &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;grouping: websites, &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;by: {$0.name.first?.uppercased() ?? ""} &#9;&#9;&#9;&#9;&#9;&#9;).mapValues{$0.sorted()} &#9;&#9;&#9;&#9;} &#9;&#9;} &#9;&#9; &#9;&#9;private func filteredKeys(byName text: String) -> [String] { &#9;&#9;&#9;&#9;return groupedArray.filter {(key, value) in &#9;&#9;&#9;&#9;&#9;&#9;value.contains{ &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;text.isEmpty || $0.name.contains(text) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;}.map {(key, _) in key}.sorted() &#9;&#9;} &#9;&#9; } (Sorry, not tested and may need some fixes. And some || are not shown as always, you need to find where to fill in.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Slow xcode
I reinstalled macOS Seems your Mac has some damages. Even on a higher spec machines showing the preview of "Hello world" may take minutes. How long will it take on your Mac? Hours? Or not able to show even waiting for days?
Dec ’20
Reply to Slow xcode
I also performed the SOS of the disk but everything is ok Seems all what I can think of are over. A few minutes for preview of "Hello world" is quite normal, but 20 minutes is very rare... Better keep this thread open and wait for someone who has experienced the same issue. Hope your issue will be solved soon. And when solved, please share your experience.
Dec ’20
Reply to Only iOS 14+ getting crash and not able to know exact reason
It is very hard to know exact reason without having an executable project, but something I find in the crash log: The crash occurred in Thread 2, which is NOT the main thread. There are several UIKit trace output in Thread 2. So, the first thing you should check is a thread problem. Aren't you triggering some UI updates within a non-main thread? Examine somewhere near [QMUIToastContentView setCustomView:]. This sort of thread problems may happen only on specific new environment (for example, when running on iOS 14+ devices), but it just depends on implementation and runtime details and should be fixed also for old environments. Anyway, you should better check UI updates within a non-main thread first.
Topic: UI Frameworks SubTopic: UIKit Tags:
Dec ’20
Reply to No ObservableOblect
Sorry if I can't provide the necessary files You have no need to be sorry, in many cases, it is hard to choose necessary files, unless you know the solution. It is very nice you have shown it by request. Thanks for showing the code. Seems your problem is that you are not passing an instance of EnvironmentObject using .environmentObject modifier. (Doing such in preview, does not work for the actual app.) When you use @EnvironmentObject in a view, you need to instantiate the object and pass it to the view (or a ancestor of the view) using .environmentObject, as found in your Home_Previews. Please try adding .environmentObject into your ContentView: struct ContentView: View { &#9;&#9;var body: some View { &#9;&#9;&#9;&#9;Home() &#9;&#9;&#9;&#9;&#9;.environmentObject(processStatus()) &#9;&#9;} } In Swift, type names should start with Capital letter. Your processStatus looks a little bit odd. (This is not critical, but you should better follow the most famous coding rule of Swift.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to SwiftUI tutorial
Sharing some bug info (including documentations and tutorials) would be valuable and be appreciated, but this is not the right place to request correction. You can send a feedback using Apple's Feedback Assistant - https://developer.apple.com/bug-reporting/. Have you sent one for this issue already?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Fatal error: Unexpectedly found nil while unwrapping an Optional value
what that means It means that something was nil where it should not be. how I can fix the error Check all the place you use Implicitly Unwrapped Optional type (!) and forced unwrapping (!). In your code shown, there are no forced unwrappings, so you may have some properties with Implicitly Unwrapped Optional type. I guess your treeImageView is declared as var treeImageView: UIImageView!, but it is not given a value. If it is an @IBOutlet, check if it is properly connected in the storyboard. One more, you need to check if you instantiated your view controller properly.
Topic: Programming Languages SubTopic: Swift Tags:
Dec ’20
Reply to Xcode on a old macbook pro
You can download older versions of Xcode from More Downloads page - https://developer.apple.com/download/more/. The latest version available for High Sierra is Xcode 10.1 . But, please remember, if you want to develop iOS apps for App Store, you need to use Xcode 11.x (with iOS SDK 13), and will need Xcode 12.x (with iOS SDK 14) starting April 2021.
Dec ’20
Reply to How to access custom properties from touched nodes when using an SKSpriteNode subclass?
You need to tell Swift compiler that the node actually is your custom class: &#9;&#9;override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { &#9;&#9;&#9;&#9;guard let touch = touches.first else { return } &#9;&#9;&#9;&#9;let location = touch.location(in: self) &#9;&#9;&#9;&#9;let touchedNodes = nodes(at: location) &#9;&#9;&#9;&#9;for node in touchedNodes { &#9;&#9;&#9;&#9;&#9;&#9;if let gift = node as? Gift { //<- Check if node is a Gift or not. &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;print(gift.giftColor) &#9;&#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;} &#9;&#9;}
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20
Reply to Strange object construction behaviour
First of all, SwiftUI apps should not depend on when or how many times init is called or body is evaluated for App and Views. In SwiftUI, struct like App or View is just a template of actually shown objects, and very similar to Storyboard of UIKit or XAML of WPF. (Hope you know any of them.) To control the initialization of class objects, you can use @StateObject, but please care about using it correctly. And in cases you want some global var of class objects, environmentObject may be one option to work with, but many things depend on the details how you want to use it. @main struct MyApp : App { &#9;&#9;@StateObject public var obj = MyClass() &#9;&#9;var body: some Scene { &#9;&#9;&#9;&#9;WindowGroup { &#9;&#9;&#9;&#9;&#9;&#9;ContentView(obj: self.obj) &#9;&#9;&#9;&#9;} &#9;&#9;} }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’20