Posts

Post not yet marked as solved
0 Replies
323 Views
I have a widget with a .intentdefinition file set up, and I can select from my enum when running my widget, but I'm not sure how to use this information in the code. What I want to be able to do is run different code in getTimeline based on what the user selects in the widget settings. If anyone could help, that'd be greatly appreciated. Thanks!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
7 Replies
2.1k Views
Hi everyone, I'm building a Swift app using Storyboards. I've been working fine for a few months now, but all of a sudden my app won't load properly. Whenever I open it on a Simulator or my physical iPhone, the launch screen is displayed before a black screen appears. My Mac is on macOS Big Sur Developer Beta 5 with Xcode 12 Beta 6, and my iPhone is on iOS 14 Developer Beta 5. This happened all of a sudden and I don't recall doing anything to cause it. Here's what I've tried so far... Renaming the storyboard and updating the target's General tab to the new name, as well as doing the same but manually editing Info.plist Moving the storyboard in and out of "Copy Bundle Resources" Updating to the latest Xcode 12 beta (I'm on macOS Big Sur) Clearing Derived Data with DevCleaner - https://itunes.apple.com/app/devcleaner/id1388020431 Starting a whole new project and moving all of my code and resources over via drag-and-drop (Interesting observation: when I started a new project, I added a simple label to the default Main.storyboard and ran it on my iPhone. The label wasn't displayed. Adding a function to my AppDelegate to load the storyboard manually on launch Adding various print statements in AppDelegate and my Home View Controller AppDelegate I've added let storyboard = UIStoryboard(name: "Main", bundle: nil) let initialViewController = storyboard.instantiateViewController(withIdentifier: "Home") self.window.rootViewController = initialViewController self.window.makeKeyAndVisible() print("App launched") to my AppDelegate. Now, when I run my app, I get printed. I also added override func viewDidLoad() { super.viewDidLoad() print("Home view loaded") to my Home View Controller. Now, when I run my app, I get this printed in Xcode: 2020-08-28 13:11:20.140963+0100 MY-APP[11077:1951343] libMobileGestalt MobileGestaltCache.c:166: Cache loaded with 4536 pre-cached in CacheData and 53 items in CacheExtra. 2020-08-28 13:11:20.759943+0100 MY-APP[11077:1951162] Metal API Validation Enabled Home view loaded App launched Still, nothing on my iPhone. The launch screen appears, fades to black, and that's it. I'm so confused. If anyone knows how to fix this, or something I can try, please let me know. Thank you in advance!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
1 Replies
647 Views
Hi all. I have a UserDefaults dictionary that contains a URL to an image (.png) saved on-device. let dict = defaults.object(forKey: myString) as? [String: String] ?? [String: String]() let imgStr = dict["Image"] This returns a string with the file path of the image on the device, as saved from another View Controller: file:///Users/noah/Library/Developer/CoreSimulator/Devices/60EB1F35-0B0A-4E65-B891-FE157B2D2AD7/data/Containers/Data/Application/60A8DC12-7636-4D47-BCC2-DA1BA55703CE/Documents/MyString.png I then need to display this image in an image view: this code is what I have: let imgToDisplay = UIImage(contentsOfFile: imgStr!) imageView.image = imgToDisplay This doesn't cause any errors, but the image view displays nothing — not even the placeholder image in my Storyboard. I do have override func viewDidLoad() { super.viewDidLoad() imageView.isHidden = false } earlier in the file and if imgStr == "NO_IMAGE_UPLOADED" { imageView.isHidden = true } The "NO_IMAGE_UPLOADED" string is what another View Controller saves in place of the image path when an image is being uploaded. Not the prettiest way, but it works for now. In short, the issue is that the image view displays nothing, even when my print statements through the program all get executed. Even my storyboard placeholder image doesn't display. Thanks in advance for any help you can give me and I hope you're all well.
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
1 Replies
2k Views
Hi all, I've been trying a lot of solutions online for quite some time, but I haven't had much luck at all. I have a button that presents an alert with two options: Photo Library or Camera. When Photo Library is pressed, I'd like a photo library picker to display so the user can pick a single image. When Camera is pressed, I'd like a camera view to appear so the user can take a single image. Then, I'd like that image to be saved to the device, and the function should return the location URL so I can integrate that into my dictionary (see my earlier post here). As I say, I've tried quite a lot and I haven't managed to get it working. If anyone could help, I'd be hugely grateful. Thank you all so much in advance, and I hope you're all doing well during this time!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
2 Replies
363 Views
Hi all, I need to share the data of a String variable between two view controllers. VC1 defines the variable, and then VC2 needs to have the variable to be able to work with it later. My current code is this: VC1: var myVariable: String = "" ... let myVariable = array.randomElement() VC2: let firstVC = FirstViewController() let myVariable = homeVC.myVariable print("Data is \(myVariable)") When called, VC2 prints: Data is  Is there anything I'm doing wrong? VC2 doesn't print the variable, even though VC1 is printing it before I tap the button to segue to VC2. Any help would be appreciated - thank you all so much in advance!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
0 Replies
701 Views
Has anyone else got this issue? I've submitted it to Apple under FB7820658. Whenever I open System Preferences and click any pane icon (Desktop & Screensaver, General, etc), the app hangs for a second and then presents me with a window titled “System Preferences Internal Error”. When macOS Big Sur was first released as a developer beta, I installed it to a separate APFS volume first. I could use System Preferences fine there. I then booted back into macOS Catalina, deleted the Big Sur volume, and installed Big Sur over Catalina, keeping all of my data. System Preferences worked fine in Catalina. The error describes “NSPrefPaneBundle supportedAppearance” - due to “Appearance” my first thought was to toggle Dark Mode from Control Centre, but that did not fix anything. I’ve restarted many times and continue to have this issue.
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
3 Replies
1.2k Views
Hi everyone! I'm making a food app where the user can save meals to categories, and add an image, ingredients, and the recipe. The meal name is saved to a UserDefaults array. Then, a dictionary is created with the meal name, ingredients, recipe, and the image location path on the device - and saved. For example: /*Save the new meal to the array*/ self.breakfasts.append(newMealName!) /*Update UserDefaults with the new array*/ self.defaults.set(self.breakfasts, forKey: "breakfasts") /*Define the dictionary*/ let dict = ["Name": newMealName, "Ingredients": newMealIngred, "Recipe": newMealRecipe, "Type": "breakfasts", "Image": imgPath] /*Save the dictionary to UserDefaults*/ self.defaults.set(dict, forKey: newMealName!) (I'm only using block comments for each comment here as the Developer Forums don't seem to support "//") I need a way to display all of this on my app's home screen. Ideally, I'd like a side-scrolling collection view with the images that users upload, and the meal title displayed on them. (The last bit is easy enough, just a blur effect and a label) If that's not possible, a TableView that shows all of the meals in a separate cell - and segues to a view with the meal name and associated info - would work for now. I'm relatively new to Swift so I apologise if I'm doing anything wrong here — thanks so much to everyone in advance. I look forward to your responses and I hope everyone is doing well during this time!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
3 Replies
3.1k Views
Hi, I'm creating a small app for a file download website that I run. I currently have a UI where the user can choose, from a dropdown, a file that we have hosted, and then a download button appears. When they click Download, I want them to be presented with an NSSavePanel to choose a directory for the file - before the file starts to download. I've tried: let url = URL(string: "https://www.apple.com")! let task = URLSession.shared.downloadTask(with: url) { localURL, urlResponse, error in 		if let localURL = localURL { 				if let string = try? String(contentsOf: localURL) { 						print(string) 				} 		} } task.resume() from a Hacking With Swift tutorial but I think that's more for iOS. When running that code, I can see the network usage of the app in Xcode go up - so it's working - but it starts straight away and there is no destination selection option. Basically, I need a way to add a save dialog box to that snippet above. If anyone can help I'd be hugely grateful. Thanks so much in advance!
Posted
by NoahEvans.
Last updated
.
Post marked as solved
4 Replies
676 Views
Hi all,I have a concept that my graphic designer made. I would like to use it for my app. How can I get it into storyboard in Xcode? The actual Swift code isn't an issue, but I'm a bit stuck on how to add this to my storyboard.I've exported assets such as the button as images, but that doesn't seem to scale well over devices. I'd be willing to do UI programmatically but I've never done this before, so it's not my first choice.If anyone has any ideas, I'd be really grateful. It's a great UI but I don't know how to make it a reality!Thank you so much!!
Posted
by NoahEvans.
Last updated
.
Post not yet marked as solved
1 Replies
605 Views
I am working on a food tracking app. The user will be able to enter the name of a meal, upload an image of the meal, add a rating, save ingredients, add a recipe, and add the calorie count.I have prototyped my app by saving the name of meals to UserDefaults as an array, but that won't work for this amount of data. How could I save all of this to the device, and be able to programmatically show it all (e.g. randomly pick a saved meal and show its corresponding info)?I'm quite new to Swift so I apologise if this is a bit vague, but I hope someone will be able to help me here.Thanks so much in advance and I hope you're all well!
Posted
by NoahEvans.
Last updated
.
Post marked as solved
3 Replies
6.6k Views
I need to round a filled in button in Swift. My button was added, and filled, in Storyboard.Here's some of the things I've tried, none of which work:button.layer.cornerCurve = .continuous button.layer.cornerCurve = .continuous button.clipsToBounds = trueThe first one works in another app of mine, but won't work here.I'm quite confused at the moment so any help would be hugely appreciated!Thank you all so much in advance, and I hope you're all well.
Posted
by NoahEvans.
Last updated
.
Post marked as solved
1 Replies
918 Views
Hi everyone,I hope you're all well. I have a .pkg with two .app files inside - my main app, which users will have in their Applications folder, and a helper tool that the pkg installs to /Library/Application Support/com.mycompany.myapp. Due to sandboxing issues, this is necessary. (Quick check - if my main app is sandboxed but my helper tool is not, will that be accepted by the Mac App Store?)I have created a bundle ID for both - com.mycompany.myapp and com.mycompany.myapp-helper. However, when uploading through Transporter, I get the error "No suitable application records were found. Verify your bundle identifier 'com.mycompany.myapp-helper' is correct."I'm thinking this is because my app in App Store Connect uses the ID com.mycompany.myapp, so Transporter doesn't know what to do with the helper tool.If anyone can assist me I'd be hugely grateful - I know it's possible because apps like Microsoft Office, which definitelyhave helper tools, are on the App Store. If it changes anything, my installer also adds a .plist into /Library/LaunchAgents so the app starts at login.I can distribute outside of the App Store, but I really don't want that as it limits the number of users I have access to.Thank you so much in advance, and I hope you're all staying safe and well during this time.
Posted
by NoahEvans.
Last updated
.