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

Xcconfig file handling fix #49

Merged
merged 3 commits into from
Jul 24, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions step/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/bitrise-io/go-utils/v2/env"
"github.com/bitrise-io/go-utils/v2/log"
"github.com/bitrise-io/go-xcode/v2/autocodesign/projectmanager"
"github.com/bitrise-io/go-xcode/xcodeproject/serialized"
"github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj"
)

Expand Down Expand Up @@ -158,8 +159,20 @@ func (u Updater) updateVersionNumbersInInfoPlist(helper *projectmanager.ProjectH
}

infoPlistPath, err := buildConfig.BuildSettings.String(infoPlistFileKey)
// If the path is extracted into a xcconfig file, then it will not appear here in the build settings.
// We need to use xcodebuild to resolve the path.
if err != nil {
return err
if !serialized.IsKeyNotFoundError(err) {
return err
}

u.logger.Printf("Info.plist path was not found in the project\n")
u.logger.Printf("Using xcodebuild to resolve it\n")

infoPlistPath, err = extractInfoPlistPathWithXcodebuild(helper.XcProj.Path, schemeName, targetName, configuration)
if err != nil {
return err
}
}

// By default, the setting for the Info.plist file path is a relative path from the project file. Of course,
Expand Down Expand Up @@ -221,10 +234,12 @@ func hasEnvVars(path string) bool {
}

func extractInfoPlistPathWithXcodebuild(projectPath, scheme, target, configuration string) (string, error) {
args := []string{"-project", projectPath, "-scheme", scheme}
args := []string{"-project", projectPath}

if target != "" {
args = append(args, "-target", target)
} else if scheme != "" {
args = append(args, "-scheme", scheme)
}

if configuration != "" {
Expand Down
114 changes: 58 additions & 56 deletions testdata/project/Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
316869AC2C369E4E00D9196F /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
31FFC9182B6D38DC00B356FD /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
31FFC91B2B6D38DC00B356FD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
31FFC91D2B6D38DC00B356FD /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -115,6 +116,7 @@
31FFC91A2B6D38DC00B356FD /* Example */ = {
isa = PBXGroup;
children = (
316869AC2C369E4E00D9196F /* Config.xcconfig */,
31FFC91B2B6D38DC00B356FD /* AppDelegate.swift */,
31FFC91D2B6D38DC00B356FD /* SceneDelegate.swift */,
31FFC91F2B6D38DC00B356FD /* ViewController.swift */,
Expand Down Expand Up @@ -491,61 +493,61 @@
name = Release;
};
31FFC9432B6D38E000B356FD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = KUN9FDAF5L;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.iszabi.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
buildSettings = {
"ASSETCATALOG_COMPILER_APPICON_NAME" = AppIcon;
"ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME" = AccentColor;
"CODE_SIGN_STYLE" = Automatic;
"CURRENT_PROJECT_VERSION" = 9999;
"DEVELOPMENT_TEAM" = KUN9FDAF5L;
"GENERATE_INFOPLIST_FILE" = YES;
"INFOPLIST_FILE" = "$(SRCROOT)/Example/Info.plist";
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents" = YES;
"INFOPLIST_KEY_UILaunchStoryboardName" = LaunchScreen;
"INFOPLIST_KEY_UIMainStoryboardFile" = Main;
"INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad" = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
"INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone" = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
"LD_RUNPATH_SEARCH_PATHS" = (
"$(inherited)",
"@executable_path/Frameworks",
);
"MARKETING_VERSION" = "9.99.9";
"PRODUCT_BUNDLE_IDENTIFIER" = "com.iszabi.Example";
"PRODUCT_NAME" = "$(TARGET_NAME)";
"SWIFT_EMIT_LOC_STRINGS" = YES;
"SWIFT_VERSION" = "5.0";
"TARGETED_DEVICE_FAMILY" = "1,2";
};
isa = XCBuildConfiguration;
name = Debug;
};
31FFC9442B6D38E000B356FD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = KUN9FDAF5L;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "$(SRCROOT)/Example/Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.iszabi.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
buildSettings = {
"ASSETCATALOG_COMPILER_APPICON_NAME" = AppIcon;
"ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME" = AccentColor;
"CODE_SIGN_STYLE" = Automatic;
"CURRENT_PROJECT_VERSION" = 9999;
"DEVELOPMENT_TEAM" = KUN9FDAF5L;
"GENERATE_INFOPLIST_FILE" = YES;
"INFOPLIST_FILE" = "$(SRCROOT)/Example/Info.plist";
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents" = YES;
"INFOPLIST_KEY_UILaunchStoryboardName" = LaunchScreen;
"INFOPLIST_KEY_UIMainStoryboardFile" = Main;
"INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad" = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
"INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone" = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
"LD_RUNPATH_SEARCH_PATHS" = (
"$(inherited)",
"@executable_path/Frameworks",
);
"MARKETING_VERSION" = "9.99.9";
"PRODUCT_BUNDLE_IDENTIFIER" = "com.iszabi.Example";
"PRODUCT_NAME" = "$(TARGET_NAME)";
"SWIFT_EMIT_LOC_STRINGS" = YES;
"SWIFT_VERSION" = "5.0";
"TARGETED_DEVICE_FAMILY" = "1,2";
};
isa = XCBuildConfiguration;
name = Release;
};
31FFC9462B6D38E000B356FD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
Expand Down Expand Up @@ -624,14 +626,14 @@
};
31FFC9562B6D396C00B356FD /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 316869AC2C369E4E00D9196F /* Config.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = KUN9FDAF5L;
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = "Example/Example-Static-Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand All @@ -652,14 +654,14 @@
};
31FFC9572B6D396C00B356FD /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 316869AC2C369E4E00D9196F /* Config.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = KUN9FDAF5L;
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = "Example/Example-Static-Info.plist";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand Down
11 changes: 11 additions & 0 deletions testdata/project/Example/Example/Config.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Config.xcconfig
// Example
//
// Created by Szabolcs Toth on 04/07/2024.
//

// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974

INFOPLIST_FILE = Example/Example-Static-Info.plist