Skip to content

Commit

Permalink
SwiftPM support. Dropped carthage to simplify conversion. (#2)
Browse files Browse the repository at this point in the history
* SwiftPM support. Dropped carthage to simplify conversion.

* Make the error public

* Code review feedbak
  • Loading branch information
melle authored Jun 2, 2020
1 parent dbe224f commit 16d222a
Show file tree
Hide file tree
Showing 47 changed files with 1,396 additions and 1,590 deletions.
80 changes: 80 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
Packages/
Package.pins
Package.resolved
*.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
.swiftpm

.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

13 changes: 13 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// swift-tools-version:5.2
import PackageDescription

let package = Package(
name: "UDPBroadcastConnection",
products: [
.library(name: "UDPBroadcastConnection", targets: ["UDPBroadcast"]),
.library(name: "UDPBroadcastConnectionDynamic", type: .dynamic, targets: ["UDPBroadcast"])
],
targets: [
.target(name: "UDPBroadcast")
]
)
58 changes: 53 additions & 5 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<a href="https://developer.apple.com/swift"><img src="https://img.shields.io/badge/Language-Swift 5-orange.svg" alt="Language: Swift 5.0" /></a>
<a href="https://github.com/Carthage/Carthage"><img src="https://img.shields.io/badge/Carthage-compatible-brightgreen.svg" alt="Carthage compatible" /></a>

Framework to send UDP broadcast messages and listen to responses using a [Dispatch](https://developer.apple.com/reference/dispatch) dispatch source.
Framework to send IPv4/IPv6 UDP broadcast messages and listen to responses using a [Dispatch](https://developer.apple.com/reference/dispatch) dispatch source.

Note: this is a fork of [gunterhager/UDPBroadcastConnection](https://github.com/gunterhager/UDPBroadcastConnection) with breaking changes:
* Immediate binding is not supported
* carthage support was removed

## Requirements

Expand Down Expand Up @@ -81,15 +85,59 @@ You can test the broadcast and the handler for receiving messages by running the

## Installation

### Carthage

Add the following line to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile).
### Swift Package Manager

Create or modify the Package.swift at the root folder of your project. You can use the automatic linking mode (static/dynamic), or use the project `UDPBroadcastConnectionDynamic` to force dynamic linking and overcome current Xcode limitations to resolve diamond dependency issues.

If you use it from only one target, automatic mode should be fine.

Automatic linking mode:
```swift
// swift-tools-version:5.2

import PackageDescription

let package = Package(
name: "MyApp",
products: [
.executable(name: "MyApp", targets: ["MyApp"])
],
dependencies: [
.package(url: "https://github.com/teufelaudio/UDPBroadcastConnection.git", .branch("master"))
],
targets: [
.target(name: "MyApp", dependencies: ["UDPBroadcastConnection"])
]
)
```
github "gunterhager/UDPBroadcastConnection"

Dynamic linking mode:
```swift
// swift-tools-version:5.2

import PackageDescription

let package = Package(
name: "MyApp",
products: [
.executable(name: "MyApp", targets: ["MyApp"])
],
dependencies: [
.package(url: "https://github.com/teufelaudio/UDPBroadcastConnection.git", .branch("master"))
],
targets: [
.target(name: "MyApp", dependencies: ["UDPBroadcastConnectionDynamic"])
]
)
```

Then run `carthage update`.
Then you can either build on the terminal or use Xcode 11 or higher that now supports SPM natively.

```shell
$ swift build
$ xed .
```

### Manually

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@ open class UDPBroadcastConnection {
switch addressFamily {
case .ipv4:
try sendBroadcastv4(data: data)
break
case .ipv6:
try sendBroadcastv6(data: data)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation

public extension UDPBroadcastConnection {

enum ConnectionError: Error {
public enum ConnectionError: Error {
// IPv6 Address creation
case createv6AddressFailed(message: String)

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 16d222a

Please sign in to comment.