Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

WatchKit support #2837

Merged
merged 3 commits into from
Aug 18, 2015
Merged

WatchKit support #2837

merged 3 commits into from
Aug 18, 2015

Conversation

kcharwood
Copy link
Contributor

Including AFNetworking in a WatchKit 2 project results in a SystemConfiguration.h file not found error.

I am seeing this in Xcode 7 / WatchOS 2 (beta 3)

@mobileoverlord
Copy link

I've been trying to get this running in a 2.0 extension. I guess WatchOS 2 doesn't have SystemConfiguration

@jervine10
Copy link

I'd love to hear someone has a pull request for this issue. We're looking to update our app to watchOS 2.

@ArEnSc
Copy link

ArEnSc commented Jul 21, 2015

Is there a work around for this guys? , other than of course not using AFNetworking lol

@kcharwood kcharwood added this to the 2.6.0 milestone Jul 24, 2015
@mRs-
Copy link

mRs- commented Jul 28, 2015

+1

2 similar comments
@walteryaron
Copy link

+1

@guylivneh
Copy link

+1

@kcharwood
Copy link
Contributor

Anyone spotted any good examples in other libraries that have a solution for this? Still thinking about how to tackle this.

@kcharwood
Copy link
Contributor

I put together a branch here with my first stab at it. Would love to hear if it working well for everyone here. Please test it and let me know.

@kcharwood
Copy link
Contributor

Btw this requires TARGET_OS_IOS and TARGET_OS_WATCH which are only available in Xcode 7/iOS 9/WatchOS 2. Not sure I could merge this into master until those GM.

@kcharwood kcharwood modified the milestones: 3.0.0, 2.6.0 Aug 3, 2015
@kcharwood
Copy link
Contributor

I guess I could add a pch line to the pod to define TARGET_OS_IOS if it isnt defined

@kcharwood kcharwood modified the milestones: 2.6.0, 3.0.0 Aug 3, 2015
@JARinteractive
Copy link
Author

[WKInterfaceDevice currentDevice] doesn't have model or systemVersion properties.

the umbrella header generated by cocoapods included the following files that are not part of the watch target:
#import "AFHTTPRequestOperation.h"
#import "AFHTTPRequestOperationManager.h"
#import "AFURLConnectionOperation.h"

Thanks for working on watch support!

@kcharwood
Copy link
Contributor

@JARinteractive

Those methods are on WKInterfaceDevice.

//
//  WKInterfaceDevice.h
//  WatchKit
//
//  Copyright (c) 2014-2015 Apple Inc. All rights reserved.
//

#import <CoreGraphics/CoreGraphics.h>
#import <WatchKit/WatchKit.h>

NS_ASSUME_NONNULL_BEGIN

@class UIImage;

typedef NS_ENUM(NSInteger, WKHapticType) {
    WKHapticTypeNotification,
    WKHapticTypeDirectionUp,
    WKHapticTypeDirectionDown,
    WKHapticTypeSuccess,
    WKHapticTypeFailure,
    WKHapticTypeRetry,
    WKHapticTypeStart,
    WKHapticTypeStop,
    WKHapticTypeClick
} WK_AVAILABLE_WATCHOS_ONLY(2.0);

@interface WKInterfaceDevice : NSObject

+ (WKInterfaceDevice *)currentDevice;

- (BOOL)addCachedImage:(UIImage *)image name:(NSString *)name WK_AVAILABLE_IOS_ONLY(8.2);
- (BOOL)addCachedImageWithData:(NSData *)imageData name:(NSString *)name WK_AVAILABLE_IOS_ONLY(8.2);
- (void)removeCachedImageWithName:(NSString *)name WK_AVAILABLE_IOS_ONLY(8.2);
- (void)removeAllCachedImages WK_AVAILABLE_IOS_ONLY(8.2);

@property (nonatomic, readonly) CGRect screenBounds;
@property (nonatomic, readonly) CGFloat screenScale;
@property (nonatomic, readonly, copy)  NSString *preferredContentSizeCategory;
@property (nonatomic, readonly, strong) NSDictionary<NSString*, NSNumber*> *cachedImages; // name and size of cached images

@property(nonatomic, readonly, copy) NSString *systemVersion  WK_AVAILABLE_WATCHOS_IOS(2.0,9.0); // e.g. @"2.0"
@property(nonatomic, readonly, copy) NSString *name           WK_AVAILABLE_WATCHOS_IOS(2.0,9.0); // e.g. "My Watch"
@property(nonatomic, readonly, copy) NSString *model          WK_AVAILABLE_WATCHOS_IOS(2.0,9.0); // e.g. @"Apple Watch"
@property(nonatomic, readonly, copy) NSString *localizedModel WK_AVAILABLE_WATCHOS_IOS(2.0,9.0); // localized version of model
@property(nonatomic, readonly, copy) NSString *systemName     WK_AVAILABLE_WATCHOS_IOS(2.0,9.0); // e.g. @"watchOS"

- (void)playHaptic:(WKHapticType)type WK_AVAILABLE_WATCHOS_ONLY(2.0);

@end

NS_ASSUME_NONNULL_END

@kcharwood
Copy link
Contributor

Also @JARinteractive, if you bring in just the NSURLSession subspec vs the entire library through cocoapods, do things look good to you?

@JARinteractive
Copy link
Author

@kcharwood oh, It looks like those were added in Beta 4. The NSURLSession subspec builds fine. Looks good.

@kcharwood
Copy link
Contributor

@kylef any suggestions on how to best structure the podspec for watchOS support?

@jervine10
Copy link

CocoaPods version 0.38 is out with watchOS 2 support:
http://blog.cocoapods.org/CocoaPods-0.38/

The update allows you to use Pods with watchOS. As a Pod Author, you have to specify the deployment target for watchOS in the Podspec, as seen below:

Pod::Spec.new do |s|
  # …
  s.watchos.deployment_target = '2.0'
end

@mRs-
Copy link

mRs- commented Aug 13, 2015

that's good news!

@Naethyn
Copy link

Naethyn commented Aug 15, 2015

+1

@kcharwood
Copy link
Contributor

After a day of battling, I have something up and working in the watchOS_support branch. Hopefully we can get this shipped soon...

cc @cnoon @kylef

@kcharwood
Copy link
Contributor

Note that iOS 6 support is removed from this podspec. Support has not yet been explicitly removed from the source itself, but that will be removed in a future update.

@@ -0,0 +1 @@
Did you know that git does not support storing empty directories?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be committed? Where did this file even come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing xcode generated it when I added a watch target.


@end


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline cleanup at the top and bottom.

@cnoon
Copy link
Member

cnoon commented Aug 18, 2015

My only other thing @kcharwood would be whether the project has actually been updated with the new deployment targets in the podspec. It would be a bummer to throw a bunch of compiler warnings for everyone that picks up the new release if there are any new deprecation warnings. Have you had a chance to see if that causes any problems?

kcharwood added a commit that referenced this pull request Aug 18, 2015
@kcharwood kcharwood merged commit d3391e6 into master Aug 18, 2015
@kcharwood kcharwood deleted the watchOS_support branch October 2, 2015 18:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants