Is `XCBuildConfiguration#base_configuration_reference` supported in xcodeproj?

1k views Asked by At

When opening a project using Xcodeproj::Project.open (xcodeproj 1.5.1 gem), if the project has baseConfigurationReferences defined for build configurations, the XCBuildConfiguration#base_configuration_reference is nil. For example, when opening a CocoaPods project (CocoaPods adds an xcconfig for each build configuration):

2.4.1 :001 > require 'xcodeproj'
 => true 
2.4.1 :002 > p = Xcodeproj::Project.open "examples/ios/BranchPluginExample/BranchPluginExample.xcodeproj"
 => #<Xcodeproj::Project> path:`/Users/jdee/github/BranchMetrics/fastlane-plugin-branch/examples/ios/BranchPluginExample/BranchPluginExample.xcodeproj` UUID:`7B03D6141EA18B7F00AE01E7` 
2.4.1 :003 > p.build_configurations
 => [<XCBuildConfiguration name=`Debug` UUID=`7B03D62C1EA18B7F00AE01E7`>, <XCBuildConfiguration name=`Release` UUID=`7B03D62D1EA18B7F00AE01E7`>] 
2.4.1 :004 > p.build_configurations[0].base_configuration_reference
 => nil 
2.4.1 :005 > p.build_configurations[1].base_configuration_reference
 => nil 

But in the project.pbxproj:

[jdee@Jimmy-Dees-MacBookPro fastlane-plugin-branch (master)]$ grep baseConfigurationReference examples/ios/BranchPluginExample/BranchPluginExample.xcodeproj/project.pbxproj
            baseConfigurationReference = A78993DA75A56A8B38F927FF /* Pods-BranchPluginExample.debug.xcconfig */;
            baseConfigurationReference = D3CC0ABC7F7C89663342D316 /* Pods-BranchPluginExample.release.xcconfig */;

Is there another way to load the file so that this is populated? Or maybe the information is available somewhere else.

Updated 2017-11-18

The plot thickens. In a workspace with CocoaPods integration, if the Pods sandbox is missing, certain required xcconfigs will also be missing. In some cases, particularly when using PBXNativeTarget#resolved_build_setting with resolve_against_xcconfig (the second arg) true, an Errno::ENOENT will be raised showing the pathname under Pods, which should be the value of PBXBuildConfiguration#base_configuration_reference. The exception is raised here:

https://github.com/CocoaPods/Xcodeproj/blob/master/lib/xcodeproj/project/object/build_configuration.rb#L195

But if I rescue the exception and examine #base_configuration_reference, it's nil.

1

There are 1 answers

0
Jimmy Dee On BEST ANSWER

Just after updating that above, the answer occurred to me, and I've confirmed it. The #base_configuration_reference may be populated on a target but not on the project.