This is an iOS library that you can use in your projects to discover physical web objects around you.
Currently discovers urls based on the following protocols:
- Bluetooth Low Energy: Discovering both Eddystone and UriBeacon beacons.
- mDNS: urls advertised via this protocol.
import Foundation
import MagnetScannerIOS
@objc(MagnetScannerClient)
class MagnetScannerClient: NSObject {
var scanner: MagnetScanner!;
override init() {
super.init();
scanner = MagnetScanner(callback: onItemFound);
}
@objc func start() -> Void {
scanner.start();
}
func onItemFound(item: Dictionary<String, AnyObject>) {
debugPrint("Item found!");
scanner.stop();
}
}
Carthage is a simple, decentralized dependency manager for Cocoa. To
install magnet-scanner-ios
with Carthage:
-
Make sure Carthage is installed.
-
Update your Cartfile to include the following:
github "mozilla-magnet/magnet-scanner-ios" ~> 0.1.0
-
Run
carthage update --platform iOS
-
This is where things start to really differ from CocoaPods. With Carthage, you need to manually drag the frameworks over to Xcode. Open your project in Xcode and go to
Linked Frameworks and Libraries
subsection in theGeneral
section of your projects settings. Now open theCarthage
folder in Finder and drag the framework in theBuild/iOS
folder over to Xcode as seen in this GIF:
-
Now your Swift code can see these frameworks, but we need to make sure the device that the app is running on has them as well.
-
In your project settings, navigate to the
Build Phases
. -
Add a
New Copy Files Phase
. -
Go down to the
Copy Files
section. -
Under
Destination
selectFrameworks
. -
Add the
MagnetScannerIOS
framework as seen in this GIF:
-
CocoaPods is a dependency manager for Cocoa projects. To install MagnetScannerIOS with CocoaPods:
-
Make sure the latest CocoaPods is installed.
# Using the default Ruby install will require you to use sudo when # installing and updating gems. sudo gem install --pre cocoapods
-
Create a Podfile by running
pod init
into your project directory: -
Open your Podfile and add MagnetScannerIOS by specifying
pod MagnetScannerIOS
on a single line inside your target block.
target 'YourApp' do
pod 'MagnetScannerIOS'
end
-
Run
pod install
. -
Close any current Xcode sessions and use
YourApp.xcworkspace
for your project from that point on.