CocoaPods / CocoaPods/Xcodeproj

"stringRep should be a non-empty string, but it's an empty string" assertion failure when saving project

Open
#261 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
2.4k
Forks
488
PR merge metrics
No merged PRs in 30d

Description

I am trying to update my `PRODUCT_NAME` setting before my CI builds run. I've written the script below, which seems to do what I intended, but I get an assertion failure when saving the project. This is the script:

``` ruby
#!/usr/bin/env ruby

require "rubygems"

gem "xcodeproj"
require "xcodeproj"

def update_target_setting(setting, value)
main_project = Xcodeproj::Project.open("")
main_project.initialize_from_file
app_target = main_project.targets.find{|target| target.name == "MainTargetName"}

puts "Changing #{setting} from '#{app_target.send(setting)}' to '#{value}'"
app_target.send("#{setting}=", value)

main_project.save
end

if __FILE__ == $0
update_target_setting("product_name", "MainTargetName-Beta")
end
```

It runs fine if I comment out `main_project.save`, but on that call, I get the following output (even though it looks like it updated the project successfully):

> 2015-04-07 14:25:47.642 ruby[21513:553745] [MT] DVTAssertions: ASSERTION FAILURE in /SourceCache/DVTFrameworks/DVTFrameworks-6760/DVTFoundation/MacroExpansion/DVTMacroDefinitionConditionSet.mm:153
> Details: stringRep should be a non-empty string, but it's an empty string
> Object:
> Method: +conditionSetFromStringRepresentation:getBaseMacroName:error:
> Thread: {number = 1, name = main}
> Hints: None
> Backtrace:
> 0 0x000000010a4dc73a -[DVTAssertionHandler handleFailureInMethod:object:fileName:lineNumber:assertionSignature:messageFormat:arguments:](in DVTFoundation)
> 1 0x000000010a4dc18f _DVTAssertionHandler (in DVTFoundation)
> 2 0x000000010a4dc47e _DVTAssertionFailureHandler (in DVTFoundation)
> 3 0x000000010a470908 +[DVTMacroDefinitionConditionSet conditionSetFromStringRepresentation:getBaseMacroName:error:](in DVTFoundation)
> 4 0x000000010c06a43e -[DVTMacroDefinitionTable(XCMacroExpansionExtensions) _xc_setValue:forMacroName:errorHandler:](in DevToolsCore)
> 5 0x000000010c06aac1 __108-[DVTMacroDefinitionTable(XCMacroExpansionExtensions) xc_setMacroNamesAndValuesFromDictionary:errorHandler:]_block_invoke (in DevToolsCore)
> 6 0x00007fff8fc7ebd5 __65-[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke (in CoreFoundation)
> 7 0x00007fff8fc7eaf9 -[__NSDictionaryI enumerateKeysAndObjectsWithOptions:usingBlock:](in CoreFoundation)
> 8 0x000000010c06a997 -[DVTMacroDefinitionTable(XCMacroExpansionExtensions) xc_setMacroNamesAndValuesFromDictionary:errorHandler:](in DevToolsCore)
> 9 0x000000010c06d59d -[NSProcessInfo(XCMacroExpansionExtensions) xc_cachedEnvironmentAsMacroDefinitionTable](in DevToolsCore)
> 10 0x000000010be442f6 -[PBXTarget createMacroExpansionScopeWithBuildParameters:](in DevToolsCore)
> 11 0x000000010be46807 -[PBXTarget cachedMacroExpansionScopeForBuildParameters:](in DevToolsCore)
> 12 0x000000010be5b63f -[PBXTarget expandedValueForString:forBuildParameters:](in DevToolsCore)
> 13 0x000000010bed28ab -[PBXNativeTarget fullProductNameForConfigurationNamed:](in DevToolsCore)
> 14 0x000000010be54a59 -[PBXTarget fullProductName](in DevToolsCore)
> 15 0x000000010be14a96 -[PBXReference setProducingTarget:](in DevToolsCore)
> 16 0x000000010be59183 -[PBXTarget awakeFromPListUnarchiver:](in DevToolsCore)
> 17 0x000000010bed3658 -[PBXNativeTarget awakeFromPListUnarchiver:](in DevToolsCore)
> 18 0x00007fff8fc2cff6 -[NSArray makeObjectsPerformSelector:withObject:](in CoreFoundation)
> 19 0x000000010be2b5b5 -[PBXPListUnarchiver decodeRootObject](in DevToolsCore)
> 20 0x000000010bdf5fd9 +[PBXProject projectWithFile:errorHandler:readOnly:](in DevToolsCore)
> 21 0x000000010bdf6ecd +[PBXProject projectWithFile:errorHandler:](in DevToolsCore)
> 22 0x00007fff8d4a8f44 ffi_call_unix64 (in libffi.dylib)
> 23 0x00007fff55d0a9e0

I found mentions of this error [on Stack Overflow](http://stackoverflow.com/questions/6064476/xcode4-project-utility-to-clean-up-pbxproj-file) in relation to Xcode crashing with a similar error, but they all refer to malformed projects with null target names. I searched through my `pbxproj` file and found no sections like that. Am I doing something wrong, is there a bug in `Xcodeproj`, or some middle ground?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.