I have a project that uses cocoa pods.
I couldn't set the PRODUCT_NAME in xcodebuild it always leads to compile time error.
/usr/bin/xcodebuild -scheme $Scheme -workspace $WorkSpaceOfProject -configuration Debug clean build CONFIGURATION_BUILD_DIR=$PathToApp "CODE_SIGN_IDENTITY=$CodeSigningIdentity" "PRODUCT_BUNDLE_IDENTIFIER=$BundleIdentifier" "PROVISIONING_PROFILE=$ProvisioningProfileIdentity" "PRODUCT_NAME =$Appname"
unknown:0: error: underlying Objective-C module 'Appname' not found
If I remove the PRODUCT_NAME from the above script, then it compiles successfully but unfortunately I have to set the app name via script
I tried setting -xcconfig as somebody suggested , it also didn't work out.
How can I change the app name through script but at the same time compile the app with cocoa pods?
If I compile it using the project file instead of workspace it executes without any problem. Here is the script:
/usr/bin/xcodebuild -target $Target -project $ProjectFilePathAbsolute -configuration Debug clean build CONFIGURATION_BUILD_DIR=$PathToApp "CODE_SIGN_IDENTITY=$CodeSigningIdentity" "PRODUCT_NAME =$Appname" "PRODUCT_BUNDLE_IDENTIFIER=$BundleIdentifier" "PROVISIONING_PROFILE=$ProvisioningProfileIdentity"
But I have to compile with workspace because I am using cocoapods.
Any suggestions are highly welcome.
I solved the above issue by using PlistBuddy and in the xcodebuild command I didn't use PRODUCT_NAME
Here is the script that I used
/usr/libexec/PlistBuddy -c "Set :CFBundleName test" info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName test" info.plist
/usr/bin/xcodebuild -scheme $Scheme -workspace $WorkSpaceOfProject -configuration Debug clean build CONFIGURATION_BUILD_DIR=$PathToApp "CODE_SIGN_IDENTITY=$CodeSigningIdentity" "PRODUCT_BUNDLE_IDENTIFIER=$BundleIdentifier" "PROVISIONING_PROFILE=$ProvisioningProfileIdentity" "PRODUCT_NAME =$Appname"