Storyboard project all programmatically
- New Project Storyboard
- TabBar07> Info > DELETE Main storyboard file base name row
- TabBar07> Info > Application Scene Manifest > Scene Configuration > Application Session Role > ... > DELETE Storyboard Name
- Delete the Main.storyboard file > “Move to Trash” (gray)
- Clean build folder
- Source: Heavily leveraging the TabBar-Tutorial (https://www.youtube.com/watch?v=AoQb6Dy6l04)
Get Object Type
- type(of: [what_ever_object_you_want_to_determine_type])
print("Selected viewController: \(type(of: viewController))") // Print the class type which will be UIViewController
Add operations to main thread
Most commone an concise way:
DispatchQueue.main.async {
// UI updates go here
}
- This method is used for other
OperationQueue.main.addOperation {}- In complex scenarios where you’re using multiple background operation queues, and you need to execute something on the main thread after the background tasks are done.
- When managing dependencies between tasks or providing cancellation logic with Operation.
Push notifications
reference 1: https://docs.leanplum.com/reference/ios-push-notifications
reference 2: ChatGPT conversation Async API iOS Setup
Simulators
Simulators are mounted on my computer here:
/Library/Developer/CoreSimulator/Images/
LocationManger
- see LocationFetcher07 app and GitHub repo
Method: startUpdatingLocation()
- Provides continuous location updates.
- Stops when the app is terminated.
- can work in background
- High battery consumption.
- Continuous: Starts updating location and continuously sends updates via the delegate.
- Synchronous in the sense it continuously runs until stopped.
Method: startMonitoringSignificantLocationChanges()
- Tracks significant location changes.
- Works even when the app is terminated.
- Moderate battery usage.
- Continuous: Monitors significant location changes and sends updates via the delegate.
- Acts like an asynchronous event trigger when a significant change occurs.
Method: requestLocation()
- Fetches the location once and then stops.
- Does not work when the app is terminated.
- Minimal battery usage.
- Asynchronous: It requests the location once and calls the delegate method upon completion.
- Suitable for one-time location requests.
CocoaPods and Sentry
These notes may be missing some earlier steps because I already had CocoaPods and Sentry in another project. But this is what I am doing 2024-08-22.
Install Sentry via brew
- make sure yopu havea arch -arm64. I check this by just typing
archin the terminal and response was "arm64". - install command:
-
install getsentry/tools/sentry-wizard && sentry-wizard -i ios
navigate to Project folder
In this case I was in the root of WhatSticks13iOS
- terminal command:
pod init - this creates the Podfile that looks like this:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'WhatSticks13iOS' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for WhatSticks13iOS
end
Modify Podfile
This is what I will try now to match with the minimum deployment and the project name for WhatSticks13iOS
platform :ios, '17.0'
use_frameworks!
target 'WhatSticks13iOS' do
pod 'Sentry'
end
Install CocoaPods
From the terminal in the project root do: pod install
- After running pod install, Xcode creates a .xcworkspace file. Always open this file (instead of the .xcodeproj file) when working on your project from now on
Get DSN from Client Keys and place in Project
Settings > Team > Project > Client Keys
- Team in this new case is: "nick-rodriguez-911def83e"
- Project: "what-sticks13"
- Then I placed it in the Config.Swift file replacing the value for sentryDSN property.
implementation
- Inside AppDelegate
import UIKit
import Sentry
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
print("- in AppDelegate -")
SentrySDK.start { options in
options.dsn = Config.sentryDSN
options.debug = false // Enabled debug when first installing is always helpful
}
return true
}
// more code/methods
}
Try a crash out:
SentrySDK.crash()For more information see the /Learning/zNotesDocs/Sentry20230913.docx file
adding Error Symbols
Sentry.io website logged in as you.
Left panel under your name “Settings” > "Team" >
Click on “Custom Integrations” link next panel just inside form Settings
Click “Create New Integration”
Choose Type: “Internal Integration”
Settings:
- webhooks: I left empty
- Permissions Project: Read & Write
- Permissions Issue & Event: Read & Write
- Add "New Token" for use in step #7
Download Sentry CLI terminal command:
curl -sL https://sentry.io/get-cli/ | SENTRY_CLI_VERSION="2.20.5" shLocate the .xacheive files
- You will need the path. Mine was: "/Users/nick/Library/Developer/Xcode/Archives/2023-09-02/TuRincon 02-09-2023 09.11.xcarchive"
- To find it go to your Xcode project > Window > Organizer > Select and Archives > then right click to “Show in Finder”
Link in terminal:
sentry-cli debug-files upload --auth-token [insert_token_from_custom_integrations_here] \
--include-sources \
--org nick-rodriguez-911def83e \
--project apple-ios \
"[enter_path_and_file_name_of_.xcarchive_file]"
- example of a file path: /Users/nick/Library/Developer/Xcode/Archives/2024-08-19/WhatSticks13iOS 19-08-2024, 19.05.xcarchive
Delegate Method Pattern
Allow a child UIViewController to call a method of its parent UIViewController. Child UIViews can have have delegates to parent UIViewControllers. The general steps are:
- Define a protocol (the delegate) that declares the method(s) to be called.
- Have the parent view controller conform to this protocol.
- Assign the parent view controller as the delegate of the child view controller.
- Use the delegate in the child view controller to call the method in the parent.
ChildViewController.swift
import UIKit
class ChildViewController: UIViewController {
// Define the delegate property
weak var delegate: ChildViewControllerDelegate?
override func viewDidLoad() {}
}
protocol ChildViewControllerDelegate: AnyObject {
func didTapButtonInChildViewController()
}
ParentViewController.swift
import UIKit
class ParentViewController: UIViewController, ChildViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
}
Troubleshooting:
maybe something with cocoapods?
- Sandbox: rysnc.samba
- Solution: Targets > Build Settings > Build Options > User Script Sandboxing set to “No”.
simulator
This problem arised from react native expo app not finding the Xcode iOS simulator
- check
xcode-select -p- if the path is
/Library/Developer/CommandLineToolsprobably needs to be changed to recognize this as the path by: - change path
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
- if the path is