Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capabilities for detecting app extensions and host targets #382

Merged
merged 13 commits into from Jun 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,11 @@

##### Enhancements

* Add helpers to `Project` for finding an extension target's host targets
and a host target's extension targets.
[Ben Asher](https://github.com/benasher44)
[#382](https://github.com/CocoaPods/Xcodeproj/pull/382)

* Add accessors for working with skipped tests inside TestAction in `.xcscheme` files.
[Eduard Panasiuk](https://github.com/somedev)
[#380](https://github.com/CocoaPods/Xcodeproj/pull/380)
Expand Down
34 changes: 34 additions & 0 deletions lib/xcodeproj/project.rb
Expand Up @@ -526,6 +526,40 @@ def native_targets
root_object.targets.grep(PBXNativeTarget)
end

# Checks the native target for any targets in the project that are
# extensions of that target
#
# @param [PBXNativeTarget] native target to check for extensions
#
#
# @return [Array<PBXNativeTarget>] A list of all targets that are
# extensions of the passed in target.
#
def extensions_for_native_target(native_target)
return [] if native_target.extension_target_type?
native_targets.select do |target|
next unless target.extension_target_type?
host_targets_for_extension_target(target).map(&:uuid).include? native_target.uuid
end
end

# Returns the native targets, in which the extension target are embedded.
# This works by traversing the targets to find those where the extension
# target is a dependency.
#
# @param [PBXNativeTarget] native target where target.extension_target_type?
# is true
#
# @return [Array<PBXNativeTarget>] the native targets that host the extension
#
def host_targets_for_extension_target(extension_target)
raise ArgumentError, "#{extension_target} is not an extension" unless extension_target.extension_target_type?
native_targets.select do |native_target|
((extension_target.uuid != native_target.uuid) &&
(native_target.dependencies.map(&:target).map(&:uuid).include? extension_target.uuid))
end
end

# @return [PBXGroup] The group which holds the product file references.
#
def products_group
Expand Down
@@ -0,0 +1,62 @@
{
"images" : [
{
"size" : "24x24",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "38mm"
},
{
"size" : "27.5x27.5",
"idiom" : "watch",
"scale" : "2x",
"role" : "notificationCenter",
"subtype" : "42mm"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "watch",
"role" : "companionSettings",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "watch",
"scale" : "2x",
"role" : "appLauncher",
"subtype" : "38mm"
},
{
"size" : "44x44",
"idiom" : "watch",
"scale" : "2x",
"role" : "longLook",
"subtype" : "42mm"
},
{
"size" : "86x86",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "38mm"
},
{
"size" : "98x98",
"idiom" : "watch",
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="6221" systemVersion="13E28" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="AgC-eL-Hgc">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6213"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Interface Controller-->
<scene sceneID="aou-V4-d1y">
<objects>
<controller id="AgC-eL-Hgc" customClass="InterfaceController" customModuleProvider="target"/>
</objects>
</scene>
</scenes>
</document>
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Extensions</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>WKCompanionAppBundleIdentifier</key>
<string>cocoapods.Extensions</string>
<key>WKWatchKitApp</key>
<true/>
</dict>
</plist>
@@ -0,0 +1 @@
Did you know that git does not support storing empty directories?
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>Extensions WatchKit 1 Extension</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>WKAppBundleIdentifier</key>
<string>cocoapods.Extensions.watchkitapp</string>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.watchkit</string>
</dict>
</dict>
</plist>
@@ -0,0 +1,31 @@
//
// InterfaceController.swift
// Extensions WatchKit 1 Extension
//
// Created by Benjamin Asher on 4/9/16.
// Copyright © 2016 CocoaPods. All rights reserved.
//

import WatchKit
import Foundation


class InterfaceController: WKInterfaceController {

override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)

// Configure interface objects here.
}

override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}

}