Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 11 archive gives PhaseScriptExecution failed

After I migrate my project from swift 3.2 to swift 4 in Xcode 10 I try to archive in Xcode 11 and give me this error:

PhaseScriptExecution Run\ Script /Users/desarrollo/Library/Developer/Xcode/DerivedData/MyApp-iOS-ewcyzseaubkujucenluznpmduhoo/Build/Intermediates.noindex/ArchiveIntermediates/MyApp-iOS-DEV/IntermediateBuildFilesPath/MyApp-iOS.build/Release-iphoneos/MyApp-iOS-DEV.build/Script-E95AEDE51E54767F00B60429.sh (in target 'MyApp-iOS-DEV' from project 'MyApp-iOS')

. . .

/Users/desarrollo/Library/Developer/Xcode/DerivedData/MyApp-iOS-ewcyzseaubkujucenluznpmduhoo/Build/Intermediates.noindex/ArchiveIntermediates/MyApp-iOS-DEV/IntermediateBuildFilesPath/MyApp-iOS.build/Release-iphoneos/MyApp-iOS-DEV.build/Script-E95AEDE51E54767F00B60429.sh: line 5: $(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1")

In the error stack I find export CURRENT_PROJECT_VERSION=114

I don't have any script with "$(CURRENT_PROJECT_VERSION) + 1" so I don't know what to do

like image 821
Navtti Avatar asked Sep 30 '19 14:09

Navtti


People also ask

How do I archive an Xcode project?

The Step archives your Xcode project by running the xcodebuild archive command and then exports the archive into an . ipa file with the xcodebuild -exportArchive command. This . ipa file can be shared, installed on test devices, or uploaded to the App Store Connect.

What is archiving in Xcode?

Archive: As its name says, it is the overall package (that contains . app and other related files). From archive you can create . IPA file similar to . apk file (android) with that you can distribute your application.

How do I archive apps in Xcode 13?

Archive your App In Xcode with your project open, select the simulator (button near the top of the window next to your project name, typically named as a specific type of iPhone) – change it to Generic iOS Device. Open the Product menu and choose Archive. You will see the archive information. Click Validate App.


2 Answers

UPDATE 2:

This causes builds to be canceled! Have a look at S1LENT WARRIOR's answer below, it seems to be working better.

UPDATE 1:

In the latest version of Xcode (Version 11.1) you can do the build number auto increment fairly easily.

Here are the steps:

  1. Go to your target's Build Settings
  2. Search for Versioning System
  3. Set it's value to Apple Generic
  4. Go to your target's Build Phases
  5. Add a new Run Script
  6. Add the following line agvtool next-version -all

Do this for all your targets and their build numbers will all be synced and updated every time you run any of the targets.

Got this answer from here: https://stackoverflow.com/a/58237340/1432355

P.S.: As said in a comment below

Using avgtool in a Run Script Phase causes the build to get cancelled

ORIGINAL:

You didn't do anything wrong I think.

If you go to your info.plist you will see that the build number has been replaced by $(CURRENT_PROJECT_VERSION) (you can find the variable in the Build Settings tab).

I am guessing you are using a script that increments build number automatically and that is causing the issue (I have the same thing on my project right now).

If you remove that script your app should build without this error.

I haven't found a solution yet on how to make the script work with this new $(CURRENT_PROJECT_VERSION) variable. (I will update this answer when I have found the solution)

like image 83
Moumou Avatar answered Sep 20 '22 19:09

Moumou


All the above answers weren't doing the trick by themselves, I had to compute a bunch of them, including the Apple documentation (see references below). So here are the steps I did if it helps someone to have all the steps.

In Info.plist, set:

  • CFBundleShortVersionString to $(MARKETING_VERSION)
  • CFBundleVersion to $(CURRENT_PROJECT_VERSION)

In target build settings:

  • set Versioning System to "Apple Generic"
  • set Current Project Version to 1 (or whatever version you want)
  • set Marketing Version to 1.0.0 (or whatever version you want)

In the scheme > Archive:

  • add a post-action "Run Script Action":
    • Provide build settings from: your app
    • in the script: cd ${PROJECT_DIR} ; xcrun agvtool next-version -all ;

  1. Apple doc mentioned by cuimingda : https://developer.apple.com/library/archive/qa/qa1827/_index.html
  2. Some of the steps mentioned by moucheg
like image 32
Toka Avatar answered Sep 22 '22 19:09

Toka