A simple library to make working with text in iOS easier. Currently, the library offers support for updating text in UITextView
or UITextField
without losing cursor position and text selection.
- iOS 9.0+
- Xcode 7
- Diff
Import the module into any file where you need to update text
import TextMagic
var textMagicService = TextMagicService()
If you need to update text in a UITextView
or UITextField
while preserving cursor position and text selection, use updateText(in:newString:)
. You provide the text input and changed text, and the rest happens magically for you.
- Adding tests for
UITextField
- Adding code coverage metrics
- Adding automated build
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate TextMagic into your Xcode project using Carthage, specify it in your Cartfile
:
github "benjaminsnorris/TextMagic" ~> 1.0
Run carthage update
to build the framework and drag the built TextMagic.framework
into your Xcode project.
You can use The Swift Package Manager to install TextMagic
by adding the proper description to your Package.swift
file:
import PackageDescription
let package = Package(
name: "YOUR_PACKAGE_NAME",
targets: [],
dependencies: [
.Package(url: "https://github.com/benjaminsnorris/TextMagic.git", majorVersion: 1)
]
)
Note that the Swift Package Manager is still in early design and development. For more information check out its GitHub Page
-
If you don't already have a
.xcworkspace
for your project, create one. (Here's how) -
Open up Terminal,
cd
into your top-level project directory, and run the following command "if" your project is not initialized as a git repository:
$ git init
- Add TextMagic as a git submodule by running the following command:
$ git submodule add https://github.com/benjaminsnorris/TextMagic.git Vendor/TextMagic
-
Open the new
TextMagic
folder, and drag theTextMagic.xcodeproj
into the Project Navigator of your application's Xcode workspace.It should not be nested underneath your application's blue project icon. Whether it is above or below your application's project does not matter.
-
Select
TextMagic.xcodeproj
in the Project Navigator and verify the deployment target matches that of your application target. -
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
-
In the tab bar at the top of that window, open the "General" panel.
-
Click on the
+
button under the "Linked Frameworks and Libraries" section. -
Select
TextMagic.framework
inside theWorkspace
folder. -
Click on the
+
button under the "Embedded Binaries" section. -
Select
TextMagic.framework
nested inside your project. -
An extra copy of
TextMagic.framework
will show up in "Linked Frameworks and Libraries". Delete one of them (it doesn't matter which one). -
And that's it!