Swift for Xojo Developers for 2026

Back in 2020 I wrote a 14 part !NN tutorial on normalizing the syntax of many Xojo functions into a Swift syntax that would be easy to use, and include error handling and other items without having to write the sometimes more complex Swift versions in your projects

At that time it was a collection of various Swift modules that had to be included in each of your projects as needed. Since then for my own use I created a precompile framework that I use for all my macOS projects.

Now with that advent of SDK26 and the changes that have come along in the past 5 years, I have decided to revisit that framework code, update where necessary, as well as attempt to create TWO frameworks this time…. one for macOS, the other for iPhone, iPad and AppleTV (ie iOS)

As I re-engineer each module I will post a link to my website where it will be stored. When the whole framework has been completed, I will post an Xcode project that will compile into the framework format. (This framework should be sharable across projects). But for now it is NOT an β€œIMPORT” (I haven’t figured that out yet)

I will be starting with the STRINGS code first as it adds the most functions and is used in most of the rest of the modules as well

This is the ORIGINAL tutorial from 2020

Note : I will NOT be using GIT or any other versioning software… So please don’t post about that… it is MY decision to go this way

If you have any OTHER suggestions , please let me know :slight_smile:

NOTE: this is not JUST for Xojo developers, I find it makes my SWIFT development easier as I can use syntax from β€œback in the day”, but still get the benefits of the Swift compiler

10 Likes

Seriously cool. This might finally get me to try Swift/Xcode. LOL

The String Library has been updated and will be avaiilabe stand-alone shortly

These should match all of the current Xojo String Functions with a few new ones. The signature format is similar to API1. If you have any functions that I may have missed, let me know

//┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
//┃               BASIC Syntax for Swiftβ„’               ┃
//┣━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
//┃   Module ┃  String Library                          ┃
//┃   Author ┃  R.David Sisemore                        ┃
//┃  Written ┃  04-Aug-2016                             ┃
//┃  Updated ┃  17-Dec-2026                             ┃
//┃ Language ┃  Swift 6.2  ☐                            ┃
//┃ Platform ┃  macOS β˜‘  iPhone β˜‘  iPad β˜‘  tvOS β˜‘       ┃
//┣━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
//┃      Copyright Β© 2018 to 2026 : Dave Sisemore       ┃
//┃                All rights reserved.                 ┃
//┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

extension String { // signatures only are shown here
    public func onlyDigits() -> String {
    public func Asc() -> Int {
    public func Len() -> Int {
    public func Mid( _ start: Int,_ length: Int? = nil) -> String {
    public func Left(_ count:Int)  -> String { 
    public func Right(_ count:Int) -> String {
    public func InStr(_ lookfor:String,_ checkcase:Bool=false) -> Int {
    public func InStr(start:Int,_ lookfor:String,_ checkcase:Bool=false) -> Int {
    public func ReplaceAll(_ oldStr:String,_ newStr:String,_ checkcase:Bool=false) -> String {
    public func ReplaceLineEndings(_ newEOL : String) -> String {
    public func Compare(_ other:String,_ checkcase:Bool=false) -> Int  {
    public func BeginsWith(_ other:String,_ checkcase:Bool=false) -> Bool {
    public func EndsWith(_ other:String,_ checkcase:Bool=false) -> Bool {
    public func Trim() -> String {
    public func LTrim() -> String {
    public func RTrim() -> String {
    public func NthField(_ fieldNumber:Int,_ sep_by:String=",") -> String {
    public func CountFields(_ sep_by:String=",") -> Int {
    public func Split(_ sep_by:String=",") -> [String] {
    public func Lowercase() -> String { 
    public func Uppercase() -> String { 
    public func Titlecase() -> String {
    public func CDbl() -> Double {
    public func Val() -> Double {
    public func CLong() -> Int64 {
    public func intVal() -> Int { 
    public func Empty() -> Bool { 
    public func Replace(_ oldStr:String,_ newStr:String,_ checkcase:Bool=false) -> String {
    public func isNumeric() -> Bool {
} // end of String Extension

* Note all the above are also define as FUNCTIONS
* String.Uppercased() can also be called as Uppercased(string)

* These two are string functions, but not part of the extension

public func Str(_ x:Any,_ format:String="") -> String {
public func printusing<T>(_ value:T,_ _pattern:String="") -> String {