A collection of Swift, SwiftUI and iOS goodies.
Feel free to request features or suggestions for improvements.
Check for device is jail-broken status.
Example for showing local notifications.
Example of common accessibility modifiers.
A simple example to demonstrate separate views for iPhone and iPad. Users will see the bottom nav on iPhone and Sidebar on iPad.
A cool "Android Toast" like implementation for SwiftUI.
Example for capturing image, recording video and selecting media from library.
A custom Toggle like component with inside label support.
On going...
SwiftUI modifier for UIAlertController
. This is created to be able to change the Alert button colors.
Add fonts to the project, add the fonts name to the plist file. Finally, use fontStyle(size:weight:)
to set fonts.
Total 3 playground related to date formatting. Inspired by NSDateFormatter.com.
A ready to use wrapper for SwiftUI-Shimmer.
A collection of animation related SwiftUI features.
Checkout the "News" module to get an example for how to run an UI test using mock data.
Check Playgrounds
directory for the books.
GCD and Structured Concurrency Model: A quick guide about the GCD (DispatchQueue
etc.) and Structured Concurrency Model (Task
, actor
, Sendable
etc.)
- Example to create preview with mock Models and ViewModels (
ObservableObject
). (See Media Capture & Select Example) - Macro example (see
packages/URLMacro
directory) - This project is using Tuist. Current
Tuist
implementation has following examples:- Quick module add using
Module
model - Custom Schema
- Custom
xcconfig
- Custom Build Config
- Custom InfoPlist
- Quick module add using
NavController
: A ready to use navigation wrapper on top ofNavigationStack
.- Basic example for
URLSession
- Basic example for
Alamofire
- Basic example for
@AppStorage
- Basic example for
Realm
This project is using Tuist. To run the project we need some initial setup.
Step 1: Install mise
We need mise
to install Tuist
and for maintaining project based Tuist
versioning.
Install mise
CLI:
# Install CLI
$ curl https://mise.run | sh
# Check mise version
$ ~/.local/bin/mise --version
mise xxxx.x.x
# Add mise to Zsh configuration file (`.zshrc`) for auto activate mise
$ echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
Finally, restart your shell session to use mise
.
Install Tuist
using the following command:
mise install tuist
git clone git@github.com:ImaginativeShohag/Why-Not-SwiftUI.git
cd Why-Not-SwiftUI
We need to fetch the app dependencies. So use the following command to install the dependencies from Package.resolved
file using Tuist
.
tuist install
Finally, generate and open the project using the following command:
tuist generate
This will generate the project file and open the project in Xcode.
- As we are using
Tuist
to manage our Xcode project, use the following command to open the Tuist manifest files in Xcode for editing:
tuist edit
-
We have to run the
tuist install
every time we change any dependency of our project. -
To upgrade dependency versions, use
tuist install --update
command. -
Always use
tuist generate
to open the project. -
After changing branch we also need to run the
tuist generate
command to generate project files. -
Please don't use Xcode Source Control. (Issue)
Please see the Tuist documentation for details.
Root
: Root directoryConfigurationFiles
: Configuration filesCoreData
: Core Data modelsEntitlements
: EntitlementsTargets
: Targets/ModulesModuleX
: An example target/moduleResources
: Resource ofModuleX
Sources
: Source codes ofModuleX
Models
: All models forModuleX
- Note: Keep models screen/sheet name wise.
UI
: All the UI files forModuleX
. It also containsViewModel
s.Components
: Common UI components that are shared in multiple screensScreens
: All screens, sheets etc.XYZ
: UI files for screen/sheetXYZ
Components
: Common UI components for screen/sheetXYZ
ABCView.swift
: Example component file
XYZScreen.swift
: Example screen/sheet UI fileXYZViewModel.swift
: Example view model file
ViewModels
: CommonViewModel
s forModuleX
.
Tests
: Unit test targetResources
: Resource ofTests
XYZTests.swift
: Example unit test file
UITests
: UI test targetResources
: Resource ofUITests
XYZUITests.swift
: Example UI test file
ModuleY
ModuleZ
- ...
Tuist
: Tuist configuration files
Note: Let's assume our target name is Core
.
/// Get current targets `Bundle` instance.
let bundle = Bundle.module
/// Get a specific targets `Bundle` instance.
let bundle = CoreResources.bundle
// Equivalent old way:
let bundle = Bundle(identifier: "org.imaginativeworld.Why-Not-SwiftUI.Core")
Note: Let's assume our target name is Core
.
// Old way
let color: Color = Color("example-color")
// New way
let color: Color = CoreAsset.exampleColor.swiftUIColor
// Old way
let image: UIImage = UIImage("example-image")! // The asset must be in the current target :(
// New way
let image: UIImage = CoreAsset.exampleImage.image // Access from any target :)
- MetricKit crash report example (WIP)
- Full app custom font
- Custom Sidebar: Finalize it (WIP)
- Custom Build variant
- Add documentation to the extensions
- Home list multiple accent color
- Use system font styles
- CMS Module
- System UI Components Collection
- Navigation system update
- SF Symbol animation ((How to animate SF Symbols)[https://www.hackingwithswift.com/quick-start/swiftui/how-to-animate-sf-symbols])
- Migrate to Tuist
- Migrate to Tuist 4.0
- Fix a freeze issue in
NavigationView
insideNavigationStack
- Add
ShimmerUI
- Update
Backend
- Update
ShimmerUI
- Update
Tuist
docs ("Access Assets" section etc.)
md5()
fileName()
fileExtension()
isValidEmail()
isBlank()
commaSeparatedString(emptyValue:) -> String
: Combine string array separated by a comma.
fileSize() -> Int
: The file size in KB.
fileSize() -> Int
: The file size in KB.
#warning("message")
#line
#function
#file
#column
#id
...#endif
#filePath
#colorLiteral(red: 0.292, green: 0.081, blue: 0.6, alpha: 255)
Copyright 2021 Md. Mahmudul Hasan Shohag
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.