2

I am facing a issue while generating build using command line script in Xcode 14, the same script is working with Xcode 13.

the function to archive is

function buildArchieve {
BUILD_FILES="$BUILD_DIR/${ASSET_BASENAME}"
mkdir -p "$BUILD_FILES"

# archieve the build
ARCHIEVE_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD/${PRODUCT_NAME}.xcarchive"
(xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive 1> /dev/null ||
xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive ||
failed "XCode failed to build app")

# export archieve
EXPORT_PATH="$BUILD_DIR/${ASSET_BASENAME}/$EXPORT_METHOD"
xcodebuild -exportArchive -archivePath "$ARCHIEVE_PATH" -exportPath "$EXPORT_PATH" -exportOptionsPlist "$EXPORT_PLIST_FILE" 1> /dev/null

# Extacting DSYM file
if [ "$METHOD" == "app-store" ]; then
    DYSM_FILE="${EXPORT_PATH}/${PRODUCT_NAME}.xcarchive/dSYMs/WhiteLabel.app.dSYM"
    ditto -c -k --norsrc "$DYSM_FILE" "${BUILD_FILES}/${PRODUCT_NAME}_${bvers}.dSYM.zip"
fi

# removing archieve file
rm -rf "$ARCHIEVE_PATH"

}

and I am getting following on the Jenkins console

/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath "administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive" clean archive User defaults from command line: IDEArchivePathOverride = /Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/BroughSuperior/administrator/testing-app5_ios_2023-05-05-10:10:33/enterprise/testing-app5.xcarchive IDEPackageSupportUseBuiltinSCM = YES`

I can not use Xcode 13 now, since apple has stopped taking builds from Xcode 13. And the same command works in Xcode 13.

Archive_output.txt file

Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace BroughSuperior.xcworkspace -scheme BroughSuperior -configuration Release -destination generic/platform=iOS -archivePath clean archive

User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES

Resolve Package Graph

Resolved source packages: Facebook: https://github.com/facebook/facebook-ios-sdk.git @ 13.0.0 Bugsnag: https://github.com/bugsnag/bugsnag-cocoa @ 6.2.0

** CLEAN SUCCEEDED **

Prepare packages

Computing target dependency graph and provisioning inputs

Create build description Build description signature: d6adcbd478de817a50f1882539a78d15 Build description path: /Users/administrator/Library/Developer/Xcode/DerivedData/BroughSuperior-gmieqdexltbrbsesvhrtzpgzfdig/Build/Intermediates.noindex/ArchiveIntermediates/BroughSuperior/IntermediateBuildFilesPath/XCBuildData/d6adcbd478de817a50f1882539a78d15-desc.xcbuild

note: Building targets in dependency order warning: Run script build phase 'Build Helper Script' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'WhiteLabel' from project 'BroughSuperior') note: Run script build phase 'Copy MIBKit Resource Bundle' will be run during every build because the option to run the script phase "Based on dependency analysis" is unchecked. (in target 'WhiteLabel' from project 'BroughSuperior') warning: Run script build phase 'Bugsnag' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'WhiteLabel' from project 'BroughSuperior') /Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/MIBKit/MIBKit.xcodeproj: error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "HHGY6CWBZB" with a private key was found. (in target 'MIBKitResources' from project 'MIBKit') ** ARCHIVE FAILED **

Surbhi Garg
  • 414
  • 5
  • 19
  • Do you have any other specific error message? Would |this help](https://stackoverflow.com/a/56289124/6309) – VonC May 14 '23 at 05:49
  • @VonC its a iOS native code not react native code. nothing else, its not giving as such error. the script after this line does not run. – Surbhi Garg May 15 '23 at 04:15
  • Can you add more logging information to your script to help diagnose where it's getting stuck? As in `xcodebuild -workspace "$WORKSPACE" -scheme "$SCHEME" -configuration "$CONFIGURATION" -destination 'generic/platform=iOS' -archivePath "$ARCHIEVE_PATH" clean archive > $BUILD_DIR/archive_output.txt 2>&1 || failed "XCode failed to build app with error: $(cat $BUILD_DIR/archive_output.txt)"` (no `(..)`): This script will capture the output from the `xcodebuild` command and store it in a file. Do replace `$BUILD_DIR` with your actual build directory path. – VonC May 15 '23 at 08:39
  • I have added function to archive let me know if anything else is required – Surbhi Garg May 16 '23 at 11:23
  • I do not see the `archive_output.txt` part, which would help since it would capture the error in a file. – VonC May 16 '23 at 11:26
  • I have added file output in the question, please check – Surbhi Garg May 17 '23 at 13:02

2 Answers2

2

The error message in your log indicates that it should be a signing issue:

/Users/administrator/.jenkins/jobs/iOS Bruff dev/workspace/MIBKit/MIBKit.xcodeproj: error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "HHGY6CWBZB" with a private key was found. (in target 'MIBKitResources' from project 'MIBKit') ** ARCHIVE FAILED **

This suggests that Xcode cannot find the appropriate iOS Development certificate that matches the specified team ID.

on the Jenkins console

Remember, if you're using Jenkins to build your project, you'll need to ensure that the correct certificates and provisioning profiles are installed on the Jenkins server, and not just your local machine.
Your Jenkins server could be your local machine: make sure it (Jenkins) is running with your account.

First, check your certificates: Open the Keychain Access app on the Mac used as Jenkins server (could be your own machine), and verify that the correct iOS Development certificate is present. If it's not, you might need to download it from the Apple Developer website and install it.

Then check your provisioning profiles (Open Xcode and go to Xcode > Preferences > Accounts, select your Apple ID, and click on "Manage Certificates.") See if the development certificate is present in the list of certificates. If not, you can add it by clicking the plus button.

Try and update your build settings, by opening your project in Xcode and check the build settings for your target. Make sure the "Code Signing Identity" is set to "iOS Developer" and the "Provisioning Profile" is set to "Automatic" or to the correct specific profile. Also, ensure that the correct team is selected in the "Signing & Capabilities" tab.

Note: Sometimes, issues can arise because the wrong version of Xcode is being used by command line tools. You can set the correct version by going to Xcode > Preferences > Locations > Command Line Tools and selecting the correct version of Xcode.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
-2

I had a similar problem and this helped me.

Changes in Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
    end
  end
end

Source: https://github.com/CocoaPods/CocoaPods/pull/11723/files#diff-48e896df652b2501f6273da535c8613c530227a16358271160cc2ec590c2cb11R603

Vasyl Nahuliak
  • 1,912
  • 2
  • 14
  • 32