Skip to content

Commit

Permalink
Merge pull request #382 from benasher44/basher_embedded_targets
Browse files Browse the repository at this point in the history
Add capabilities for detecting app extensions and host targets
  • Loading branch information
segiddins committed Jun 7, 2016
2 parents d574c99 + 7164aa0 commit 9188279
Show file tree
Hide file tree
Showing 34 changed files with 2,420 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Did you know that git does not support storing empty directories?
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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()
}

}
Loading

0 comments on commit 9188279

Please sign in to comment.