55[ ![ Build Status] ( https://travis-ci.com/tsolomko/BitByteData.svg?branch=develop )] ( https://travis-ci.com/tsolomko/BitByteData )
66[ ![ Build Status] ( https://dev.azure.com/tsolomko/BitByteData/_apis/build/status/tsolomko.BitByteData?branchName=develop )] ( https://dev.azure.com/tsolomko/BitByteData/_build/latest?definitionId=2&branchName=develop )
77
8- A Swift framework with classes for reading and writing bits and bytes.
8+ A Swift framework with classes for reading and writing bits and bytes. Supported platforms include Apple platforms,
9+ Linux, __ and Windows__ .
910
1011## Installation
1112
12- BitByteData can be integrated into your project using Swift Package Manager, CocoaPods or Carthage.
13+ BitByteData can be integrated into your project using either Swift Package Manager, CocoaPods, or Carthage.
1314
1415### Swift Package Manager
1516
@@ -22,7 +23,7 @@ let package = Package(
2223 name : " PackageName" ,
2324 dependencies : [
2425 .package (url : " https://github.com/tsolomko/BitByteData.git" ,
25- from : " 1.4 .0" )
26+ from : " 2.0 .0" )
2627 ],
2728 targets : [
2829 .target (
@@ -37,49 +38,96 @@ More details you can find in [Swift Package Manager's Documentation](https://git
3738
3839### CocoaPods
3940
40- Add ` pod 'BitByteData', '~> 1.4 ' ` and ` use_frameworks! ` lines to your Podfile.
41+ Add ` pod 'BitByteData', '~> 2.0 ' ` and ` use_frameworks! ` lines to your Podfile.
4142
4243To complete installation, run ` pod install ` .
4344
4445### Carthage
4546
46- __ Important: __ Only Swift 5.x is supported when installing BitByteData via Carthage .
47+ Add to your Cartfile ` github "tsolomko/ BitByteData" ~> 2.0 ` .
4748
48- Add to your Cartfile ` github "tsolomko/BitByteData" ~> 1.4 ` .
49+ Then:
4950
50- Then run ` carthage update ` .
51+ 1 . If you use Xcode 12 or later you should run ` carthage update --use-xcframeworks ` . After that drag
52+ and drop the ` BitByteData.xcframework ` file from the ` Carthage/Build/ ` directory into the "Frameworks, Libraries, and
53+ Embedded Content" section of your target's "General" tab in Xcode.
5154
52- Finally, drag and drop ` BitByteData.framework ` from ` Carthage/Build ` folder into the "Embedded Binaries" section on your
53- targets' "General" tab in Xcode.
55+ 2 . If you use Xcode 11 or earlier you should run ` carthage update ` . After that drag and drop the
56+ ` BitByteData.framework ` file from from the ` Carthage/Build/<platform>/ ` directory into the "Embedded Binaries" section
57+ of your target's "General" tab in Xcode.
58+
59+ ## Migration to 2.0
60+
61+ There is a number of breaking changes in the 2.0 update. In this section you can find a list of modifications you need
62+ to perform to your code to make it compile with BitByteData 2.0. For more information, please refer to either
63+ [ 2.0 Release Notes] ( https://github.com/tsolomko/BitByteData/releases/tag/2.0.0 ) or
64+ [ API Reference Documentation] ( http://tsolomko.github.io/BitByteData ) .
65+
66+ 1 . ` ByteReader ` class has been renamed to ` LittleEndianByteReader ` .
67+
68+ __ Solution:__ Change all occurrences in your code of ` ByteReader ` to ` LittleEndianByteReader ` .
69+
70+ 2 . ` BitReader ` protocol has two new method requirements: ` signedInt(fromBits:representation:) ` and ` advance(by:) ` .
71+
72+ __ Solution:__ If you have your own type that conforms to the ` BitReader ` protocol you need to implement these two
73+ methods.
74+
75+ 3 . ` BitWriter ` protocol has two new method requirements: ` write(unsignedNumber:bitsCount:) ` and
76+ ` write(signedNumber:bitsCount:representation:) ` .
77+
78+ __Solution:__ If you have your own type that conforms to the `BitWriter` protocol you need to implement the
79+ ` write(unsignedNumber:bitsCount:) ` function (the second function has a default implementation).
80+
81+ 4 . The setter of the ` offset ` property of the ` LsbBitReader ` and ` MsbBitReader ` classes will now crash if the reader
82+ is not aligned.
83+
84+ __Solution:__ If you set this property directly, make sure that the reader is aligned, for example, by checking the
85+ ` isAligned ` property.
86+
87+ 5 . The default implementation of the ` BitWriter.write(number:bitsCount:) ` function and the
88+ ` write(unsignedNumber:bitsCount:) ` function of the ` LsbBitWriter ` and ` MsbBitWriter ` classes now crash if the
89+ ` bitsCount ` argument exceeds the bit width of the integer type on the current platform.
90+
91+ __Solution:__ If you use these functions directly, make sure that the `bitsCount` argument has a valid value.
92+
93+ In addition, BitByteData 2.0 provides new functionality for working with signed integers more correctly. If you were
94+ working with signed integers before, consider using the new ` BitReader.signedInt(fromBits:representation:) ` and
95+ ` BitWriter.write(signedNumber:bitsCount:representation:) ` functions instead of ` int(fromBits:) ` and
96+ ` write(number:bitsCount:) ` , respectively.
5497
5598## Usage
5699
57- Use ` ByteReader ` class to read bytes.
58- For reading bits there are two classes: ` LsbBitReader ` and ` MsbBitReader ` , which implement ` BitReader ` protocol
59- for two bit-numbering schemes ("LSB 0" and "MSB 0" correspondingly).
60- Both ` LsbBitReader ` and ` MsbBitReader ` classes inherit from ` ByteReader ` so you can also use them to read bytes
61- (but they must be aligned, see documentation for more details).
100+ To read bytes use either ` LittleEndianByteReader ` or ` BigEndianByteReader ` class, which implement the ` ByteReader `
101+ protocol.
102+
103+ For reading bits there are also two classes: ` LsbBitReader ` and ` MsbBitReader ` , which implement the ` BitReader ` protocol
104+ for two bit-numbering schemes ("LSB 0" and "MSB 0" correspondingly), though they only support Little Endian byte order.
105+ Since the ` BitReader ` protocol inherits from ` ByteReader ` , you can also use the ` LsbBitReader ` and ` MsbBitReader `
106+ classes to read bytes (but they must be aligned when doing so, see documentation for more details).
62107
63- Writing bits is implemented in two classes ` LsbBitWriter ` and ` MsbBitWriter ` (again, for two bit-numbering schemes).
64- They both conform to ` BitWriter ` protocol.
108+ Writing bits is implemented for two bit-numbering schemes as well: the ` LsbBitWriter ` and ` MsbBitWriter ` classes. Both
109+ of them conform to the ` BitWriter ` protocol.
65110
66- __ Note:__ All readers and writers aren't structs, but classes intentionally to make it easier to pass them as arguments
67- to functions and to eliminate unnecessary copying and ` inout ` s.
111+ __ Note:__ All readers and writers aren't structs, but classes intentionally to make it easier to pass them as references
112+ to functions. This allows to eliminate potential copying and avoid writing extra ` inout ` s and ampersands all over the
113+ code.
68114
69- ## Documentation
115+ ### Documentation
70116
71- Every function or type of BitByteData's public API is documented.
72- This documentation can be found at its own [ website] ( http://tsolomko.github.io/BitByteData ) .
117+ Every function or type of BitByteData's public API is documented. This documentation can be found at its own
118+ [ website] ( http://tsolomko.github.io/BitByteData ) or via a slightly shorter link:
119+ [ bitbytedata.tsolomko.me] ( http://bitbytedata.tsolomko.me )
73120
74121## Contributing
75122
76123Whether you find a bug, have a suggestion, idea, feedback or something else, please
77- [ create an issue] ( https://github.com/tsolomko/BitByteData/issues ) on GitHub.
124+ [ create an issue] ( https://github.com/tsolomko/BitByteData/issues ) on GitHub. If you have any questions, you can ask
125+ them on the [ Discussions] ( https://github.com/tsolomko/BitByteData/discussions ) page.
78126
79127If you'd like to contribute, please [ create a pull request] ( https://github.com/tsolomko/BitByteData/pulls ) on GitHub.
80128
81- __ Note:__ If you are considering working on BitByteData, please note that Xcode project (BitByteData.xcodeproj)
82- was created manually and you shouldn't use ` swift package generate-xcodeproj ` command.
129+ __ Note:__ If you are considering working on BitByteData, please note that the Xcode project (BitByteData.xcodeproj)
130+ was created manually and you shouldn't use the ` swift package generate-xcodeproj ` command.
83131
84132### Performance and benchmarks
85133
@@ -90,7 +138,7 @@ run, show, and compare benchmarks and their results.
90138If you are considering contributing to the project please make sure that:
91139
921401 . Every new function has also a new benchmark added.
93- 2 . Every other change to any existing function doesn't introduce performance regressions, or, at the very least, these
141+ 2 . Other changes to existing functionality do not introduce performance regressions, or, at the very least, these
94142 regressions are small and such performance tradeoff is necessary and justifiable.
95143
96144Finally, please note that any meaningful comparison can be made only between benchmarks run on the same hardware and
0 commit comments