Post

Replies

Boosts

Views

Activity

Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
What is crashing: Xcode or your project? If Xcode is crashing, start by narrowing down the problem. Can you create new projects? Can you open other projects? If you can create new projects and open other projects, you know the problem is with the one project. If your project is crashing when you run it, create an exception breakpoint by choosing Debug > Breakpoints > Create Exception Breakpoint in Xcode. When your app crashes, the exception breakpoint will show you where in your code the app crashes. You will have to post your code for anyone to provide additional help to solve the crashing problem.
Aug ’23
Reply to Use multiple @Observable inside each other using @Enviroment
I have not used the new @Observable stuff yet, but I am pretty sure that @Environment is used in SwiftUI views, not in view models. What happens if you add the categories view model as a regular property of the NotesViewModel class without any property wrappers? @Observable class NotesViewModel { var notes: [Note] = [] var categoriesViewModel: CategoriesViewModel func foo(){ /// Thread 1: Fatal error: No Observable object of type CategoriesViewModel found. A View.environmentObject(_:) for CategoriesViewModel may be missing as an ancestor of this view. print(categoriesViewModel.categories.count) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to How to store custom binary data in app?
Place the binary files in the app target's Copy Bundle Resources build phase to add the files to the app bundle. Open the project editor by choosing the project from the left side of the project window. Select the app target from the target list on the left side of the project editor. Click the Build Phases button at the top of the project editor. Click the disclosure triangle next to the Copy Bundle Resources build phases to see the files that are in the build phase. Click the Add button below the file list to add the binary files to the build phase.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’23
Reply to Permission to read a local file
To create an app you can copy to other Macs, create an archive of your project and export it. In Xcode choose Product > Archive to create the archive. After creating the archive you can access it from Xcode's Organizer window. Choose Window > Organizer in Xcode to open the Organizer window. Select Archives from the left side of the Organizer to show the archives. You may have to choose your project from a menu above the Archives item on the left side of the window. Select your archive from the list and click the Distribute App button. A sheet opens asking for a method of distribution. Select Copy App because you do not have a paid developer account. Click the Next button. Choose a location to save the archived app and click the Export button. Now you have an app file you can run like any other app on your Mac and copy to other Macs.
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’23
Reply to error: Failed with exit code exited with status 1 error in Xcode14.3.1
You have a code signing error. What are the code signing settings for your project? Select your project from the left side of the project window to open the project editor. Select your app target from the target list on the left side of the project editor. Click the Signing & Capabilities button at the top of the project editor. Does your app have automatic or manual code signing? Are the provisioning profile and signing certificates correct? Xcode also has code signing build settings. Click the Build Settings button at the top of the project editor to access the build settings. The code signing build settings are in the Signing section. Are the values for those build settings what you expect them to be?
Jul ’23
Reply to Permission to read a local file
Are you making an app for yourself or for other people to use? If you are making an app for other people and want to play an audio file, you should bundle the file with the app and load and play the file from the app bundle. Using the app bundle is better than relying on a file being in the Downloads folder. macOS has privacy preferences in the Security & Privacy section of its Settings/System Preferences app. You can give an app full disk access or give an app access to specific folders. If you are making an app for yourself, use these settings to give your app permission to access what you need on the file system. You can give a sandboxed app access to the Downloads folder from the File Access section of the App Sandbox settings in Xcode.
Topic: App & System Services SubTopic: Core OS Tags:
Jul ’23
Reply to error: Failed with exit code exited with status 1 error in Xcode14.3.1
I tried solution mentioned in support page. But it is not working out. What specifically is the solution you tried that did not work? Xcode's issue navigator will show the build errors in your project. Press Cmd-4 in Xcode to open the issue navigator. What are the build errors the issue navigator shows? If the only build error the issue navigator shows is Error: Failed with exit code exited with status 1, clean the build folder by choosing Product > Clean Build Folder in Xcode. After cleaning the build folder, build the project again. Are you using CocoaPods in your project? Using them can cause build errors where you would need to update the pods.
Jul ’23
Reply to Why must I wrap a call to call to an async/await method in a Task?
You have to wrap calls to async functions in a Task block if the function or closure where you make the call does not support Swift's async await syntax. If you are getting build errors if you remove the Task block, it's a sign the function or closure does not support the async await syntax. See the following article for additional explanation: https://www.swiftdevjournal.com/fixing-the-async-call-in-a-function-that-doesnt-support-concurrency-error-in-swift/ SwiftUI has a .task modifier you can use to make an async call from a SwiftUI view. You may be able to use it to avoid having to wrap your button code in a Task block. See the following article for an introduction to the .task modifier: https://www.hackingwithswift.com/quick-start/concurrency/how-to-run-tasks-using-swiftuis-task-modifier
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Xcode 15 no storyboard
What type of project did you create? The multi-platform app projects use SwiftUI so there's no option to choose a storyboard for the user interface. If you create an iOS or Mac app project, there should be an Interface menu where you can choose to use a storyboard for the app's user interface.
Jul ’23
Reply to Xcode debugging breakpoints only show stack trace without corresponding line.
What appears in Xcode's editor instead of your source code? If you see a bunch of assembly language code in Xcode's editor, look for a function you wrote in the stack trace and click that function. Xcode should take you to that function in your code. If that does not help, you have to provide more details on what you are doing, such as the following: The version of Xcode you are using The type of Xcode project you created What kind of breakpoints you set: line, symbolic, or exception.
Jul ’23
Reply to FirstTimeDebugging - compile warning
The following condition: if false Will never be true so the code inside the if block print("Will this line of code ever be reached") someMethod() Will never execute. I have not read the book you are following. But it looks like the point of that code is to quiz you on whether the code in the if block will ever be reached, and not to build without any warnings. If you want to remove the warning, provide a condition that could be true or false or remove the if statement and the braces. But I think removing the warning defeats the point of the exercise.
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’23
Reply to App Development For Newbie
Are you asking if an app you created with Xcode 13 and the iOS 15 SDK will run on iOS 16? If so, the answer is Yes, the app will run on iOS 16. You can make apps that support iOS 15 with Xcode 14. Set the deployment target, the minimum OS the app will run on, to iOS 15, and the app will run on iOS 15+ as long as you don't use anything Apple added in iOS 16. The following article provides screenshots and other details on supporting older versions of iOS: https://www.swiftdevjournal.com/supporting-older-versions-of-ios-and-macos/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
The answers to the following Stack Overflow question may help you solve your problem with Xcode crashing when opening a specific project: https://stackoverflow.com/questions/4455903/xcode-crashing-when-opening-project-file
Replies
Boosts
Views
Activity
Aug ’23
Reply to Unexpected crashes on Xcode 14.3 (SIGTRAP)
What is crashing: Xcode or your project? If Xcode is crashing, start by narrowing down the problem. Can you create new projects? Can you open other projects? If you can create new projects and open other projects, you know the problem is with the one project. If your project is crashing when you run it, create an exception breakpoint by choosing Debug > Breakpoints > Create Exception Breakpoint in Xcode. When your app crashes, the exception breakpoint will show you where in your code the app crashes. You will have to post your code for anyone to provide additional help to solve the crashing problem.
Replies
Boosts
Views
Activity
Aug ’23
Reply to Use multiple @Observable inside each other using @Enviroment
I have not used the new @Observable stuff yet, but I am pretty sure that @Environment is used in SwiftUI views, not in view models. What happens if you add the categories view model as a regular property of the NotesViewModel class without any property wrappers? @Observable class NotesViewModel { var notes: [Note] = [] var categoriesViewModel: CategoriesViewModel func foo(){ /// Thread 1: Fatal error: No Observable object of type CategoriesViewModel found. A View.environmentObject(_:) for CategoriesViewModel may be missing as an ancestor of this view. print(categoriesViewModel.categories.count) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to How to store custom binary data in app?
Place the binary files in the app target's Copy Bundle Resources build phase to add the files to the app bundle. Open the project editor by choosing the project from the left side of the project window. Select the app target from the target list on the left side of the project editor. Click the Build Phases button at the top of the project editor. Click the disclosure triangle next to the Copy Bundle Resources build phases to see the files that are in the build phase. Click the Add button below the file list to add the binary files to the build phase.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Permission to read a local file
To create an app you can copy to other Macs, create an archive of your project and export it. In Xcode choose Product > Archive to create the archive. After creating the archive you can access it from Xcode's Organizer window. Choose Window > Organizer in Xcode to open the Organizer window. Select Archives from the left side of the Organizer to show the archives. You may have to choose your project from a menu above the Archives item on the left side of the window. Select your archive from the list and click the Distribute App button. A sheet opens asking for a method of distribution. Select Copy App because you do not have a paid developer account. Click the Next button. Choose a location to save the archived app and click the Export button. Now you have an app file you can run like any other app on your Mac and copy to other Macs.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to error: Failed with exit code exited with status 1 error in Xcode14.3.1
You have a code signing error. What are the code signing settings for your project? Select your project from the left side of the project window to open the project editor. Select your app target from the target list on the left side of the project editor. Click the Signing & Capabilities button at the top of the project editor. Does your app have automatic or manual code signing? Are the provisioning profile and signing certificates correct? Xcode also has code signing build settings. Click the Build Settings button at the top of the project editor to access the build settings. The code signing build settings are in the Signing section. Are the values for those build settings what you expect them to be?
Replies
Boosts
Views
Activity
Jul ’23
Reply to Permission to read a local file
Are you making an app for yourself or for other people to use? If you are making an app for other people and want to play an audio file, you should bundle the file with the app and load and play the file from the app bundle. Using the app bundle is better than relying on a file being in the Downloads folder. macOS has privacy preferences in the Security & Privacy section of its Settings/System Preferences app. You can give an app full disk access or give an app access to specific folders. If you are making an app for yourself, use these settings to give your app permission to access what you need on the file system. You can give a sandboxed app access to the Downloads folder from the File Access section of the App Sandbox settings in Xcode.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Swift Playground Questions
Reddit has a Swift Playgrounds group that you could ask questions about the app. https://www.reddit.com/r/SwiftPlaygroundsApps/ Hacking with Swift has a forum where beginners can ask questions on Swift. https://www.hackingwithswift.com/forums
Replies
Boosts
Views
Activity
Jul ’23
Reply to error: Failed with exit code exited with status 1 error in Xcode14.3.1
I tried solution mentioned in support page. But it is not working out. What specifically is the solution you tried that did not work? Xcode's issue navigator will show the build errors in your project. Press Cmd-4 in Xcode to open the issue navigator. What are the build errors the issue navigator shows? If the only build error the issue navigator shows is Error: Failed with exit code exited with status 1, clean the build folder by choosing Product > Clean Build Folder in Xcode. After cleaning the build folder, build the project again. Are you using CocoaPods in your project? Using them can cause build errors where you would need to update the pods.
Replies
Boosts
Views
Activity
Jul ’23
Reply to FirstTimeDebugging - compile warning
Removing the if block will remove the warning. But I do not know if that is what the book wants you to do. I am not sure what the code is supposed to do because I have not read the book.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Why must I wrap a call to call to an async/await method in a Task?
You have to wrap calls to async functions in a Task block if the function or closure where you make the call does not support Swift's async await syntax. If you are getting build errors if you remove the Task block, it's a sign the function or closure does not support the async await syntax. See the following article for additional explanation: https://www.swiftdevjournal.com/fixing-the-async-call-in-a-function-that-doesnt-support-concurrency-error-in-swift/ SwiftUI has a .task modifier you can use to make an async call from a SwiftUI view. You may be able to use it to avoid having to wrap your button code in a Task block. See the following article for an introduction to the .task modifier: https://www.hackingwithswift.com/quick-start/concurrency/how-to-run-tasks-using-swiftuis-task-modifier
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Xcode 15 no storyboard
What type of project did you create? The multi-platform app projects use SwiftUI so there's no option to choose a storyboard for the user interface. If you create an iOS or Mac app project, there should be an Interface menu where you can choose to use a storyboard for the app's user interface.
Replies
Boosts
Views
Activity
Jul ’23
Reply to Xcode debugging breakpoints only show stack trace without corresponding line.
What appears in Xcode's editor instead of your source code? If you see a bunch of assembly language code in Xcode's editor, look for a function you wrote in the stack trace and click that function. Xcode should take you to that function in your code. If that does not help, you have to provide more details on what you are doing, such as the following: The version of Xcode you are using The type of Xcode project you created What kind of breakpoints you set: line, symbolic, or exception.
Replies
Boosts
Views
Activity
Jul ’23
Reply to FirstTimeDebugging - compile warning
The following condition: if false Will never be true so the code inside the if block print("Will this line of code ever be reached") someMethod() Will never execute. I have not read the book you are following. But it looks like the point of that code is to quiz you on whether the code in the if block will ever be reached, and not to build without any warnings. If you want to remove the warning, provide a condition that could be true or false or remove the if statement and the braces. But I think removing the warning defeats the point of the exercise.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to App Development For Newbie
Are you asking if an app you created with Xcode 13 and the iOS 15 SDK will run on iOS 16? If so, the answer is Yes, the app will run on iOS 16. You can make apps that support iOS 15 with Xcode 14. Set the deployment target, the minimum OS the app will run on, to iOS 15, and the app will run on iOS 15+ as long as you don't use anything Apple added in iOS 16. The following article provides screenshots and other details on supporting older versions of iOS: https://www.swiftdevjournal.com/supporting-older-versions-of-ios-and-macos/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23