This repository has been archived by the owner on Jun 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Swift Live Reload #94
Comments
I've found it helpful to write the watcher initializer in Obj-C still in order to take advantage of the // CASStyle+Additions.h
#import <Classy/Classy.h>
@interface CASStyler(Additions)
+ (void)initWatcher;
@end // CASStyler+Additions.m
#import "CASStyler+Additions.h"
@implementation CASStyler (Additions)
+ (void)initWatcher {
#if TARGET_IPHONE_SIMULATOR
NSString *absoluteFilePath = CASAbsoluteFilePath(@"../Resources/stylesheets/stylesheet.cas");
[CASStyler defaultStyler].watchFilePath = absoluteFilePath;
#endif
}
@end // AppDelegate.swift
import Classy
public class AppDelegate: UIResponder, UIApplicationDelegate {
public func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
CASStyler.initWatcher()
}
} |
Another option besides using the bridging header and the macro directly is just to use Swift and the FILE macro: if UIDevice.currentDevice().systemName.compare("iPhone Simulator") == .OrderedSame {
let curFilePath = __FILE__
let curFileDir = curFilePath.stringByDeletingLastPathComponent;
let styleFilePath = curFileDir.stringByAppendingPathComponent("StyleSheets/stylesheet.cas")
CASStyler.defaultStyler().watchFilePath = styleFilePath
} |
Very nice, thanks! |
Added to wiki. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Would be great to see an example of how to get Live Reload working with Swift. I can't get
CASAbsoluteFilePath
to be available despite adding to the bridging header.The text was updated successfully, but these errors were encountered: