Exclude App Extension (WatchKit) from Xcode build script / xcodebuild
Asked Answered
S

3

8

The CI service we are using at the moment works from iOS 8.1 which (correct me if I'm wrong) does not support the Apple Watch / WatchKit. I've done some searching and poking around Xcode, but to no avail.

I'm looking for a way to exclude my Apple Watch extension from the build - either through Run Build Script in Xcode, or what would be even better is a way to do it directly through the xcodebuild command.

Anyone have any tips?

Sycamore answered 15/4, 2015 at 18:37 Comment(0)
R
12

Look into your [Main Target] > Build Phases > Target Dependencies and [Main Target] > Build Phases > Embed App Extensions and remove the WatchKit information from both.

Risa answered 15/4, 2015 at 19:18 Comment(2)
Thanks for the reply - This works for sure, but I'm hoping I could use some sort of script, that I can then trigger with a flag for testing - so we can keep the app extension in the target for Dev / Beta / etc, but not have it there for testingSycamore
@Sycamore I am trying to do something similar did you find the answer?Canoewood
T
0

I am using a PHP script to remove the extension's appex file from the project runtime.

<?php
$file = file_get_contents("./PROJECT_Name.xcodeproj/project.pbxproj");
$emKeyPosition = strpos($file, "/* EXTENSION NAME */ = {
			isa = PBXNativeTarget;");
$bPhPosition = strpos($file, "buildPhases = (", $emKeyPosition);
$endPosition = strpos($file, ");", $emKeyPosition);
$emString = "Embed Pods Frameworks */,";
$emFramePosition = strpos($file, $emString, $bPhPosition);
$filelen = strlen($file);
$previousComma = strrpos($file, ",", -($filelen-$emFramePosition));
$finalFmString = substr($file, $previousComma+1, $emFramePosition+strlen($emString)-$previousComma);
$file = str_replace($finalFmString, "", $file);
file_put_contents("./PROJECT_Name.xcodeproj/project.pbxproj", $file);
?>

Let me know in case of issues for further discussion .

Teetotum answered 16/9, 2016 at 6:49 Comment(0)
B
-1

If you are looking for a script, You can use configure_extensions gem.

Syntax: configure_extensions <mode> <project> <app_target> <extensions...>

Example: configure_extensions add MyApp.xcodeproj MyApp NotificationsUI

Bakelite answered 6/6, 2021 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.