Xcode 14.0 command PhaseScriptExecution failed with a nonzero exit code - flutter

After updating my Xcode to the latest version 14.0. I am facing this issue if anyone know how to resolve it please let me know

Click properties on the project, go to build phases and check the option "For install builds only"

Maybe the problem is with "Run script"
Ex: I did change firebase crashlytics from "pod" to "Packeges".
But I not change script.
I have tried all the solutions in
"https://stackoverflow.com/questions/53289524/xcode-10-2-1-command-phasescriptexecution-failed-with-a-nonzero-exit-code"
My solutions is change TARGETS -> Build Phases. In the script field
form
"${PODS_ROOT}/FirebaseCrashlytics/run"
to
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
In short the problem is your script, do it right
If Scrip is install builds only. U need
Targets -> Build Phases -> Run Scrip -> check "For install builds only"
Ex:
APP_PATH=“${TARGET_BUILD_DIR}/${WRAPPER_NAME}”
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find “$APP_PATH” -name ‘*.framework’ -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read “$FRAMEWORK/Info.plist” CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH=“$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME”
echo “Executable is $FRAMEWORK_EXECUTABLE_PATH”
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo “Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME”
lipo -extract “$ARCH” “$FRAMEWORK_EXECUTABLE_PATH” -o “$FRAMEWORK_EXECUTABLE_PATH-$ARCH”
EXTRACTED_ARCHS+=(“$FRAMEWORK_EXECUTABLE_PATH-$ARCH”)
done
echo “Merging extracted architectures: ${ARCHS}”
lipo -o “$FRAMEWORK_EXECUTABLE_PATH-merged” -create “${EXTRACTED_ARCHS[#]}”
rm “${EXTRACTED_ARCHS[#]}”
echo “Replacing original executable with thinned version”
rm “$FRAMEWORK_EXECUTABLE_PATH”
mv “$FRAMEWORK_EXECUTABLE_PATH-merged” “$FRAMEWORK_EXECUTABLE_PATH”
done

On my side this issue appeared when i change my computer and issue was caused by Apple Silicon processor. When i start to use m1 pro, i did not check the installation page i directly intalled flutter via Fvm. When i check the installation page i saw there are a few steps to install flutter on Apple Slicon. And these steps fixed the issue;
sudo softwareupdate --install-rosetta --agree-to-license
ref: https://docs.flutter.dev/get-started/install/macos

Related

List packages which will be included in host Yocto SDK

I'm currently encountering an issue whereby the version of OpenCV being included in the target image is different to that which is being included in the host SDK (3.4.x as opposed to 3.3.x).
In order to better debug this, I want to list the packages (and their versions) which will be included in the host SDK produced by bitbake core-image-weston -c populate_sdk.
How can I do this? Note: I'm using the command line and am not using Toaster.
Thanks in advance.
One good way to debug such package or sdk issues is yocto buildhistory
Add the content below to your local.conf
INHERIT += "buildhistory"
BUILDHISTORY_COMMIT = "1"
BUILDHISTORY_FEATURES = "image package sdk" # maybe already default value
A new folder will be created under build/buildhistory/ , which allows you to verify packages, sdk and the image in a easy manner.
Edit:
Since you want it before compiling everything:
bitbake -g core-image-weston -c populate_sdk && cat pn-buildlist | sort | uniq | bitbake -s > dependencies

Xcode 10: Code Signing my App+Framework fails, because of failure signing 3rd party dependency framework (PromiseKit). Works in Xcode 9

I have an Xcode 10 - iOS12 swift project that links against My own framework (also Xcode 10 + iOS12).
The app project is referencing my framework project as a sub-project reference.
My Framework project references PromiseKit.framework (a universal framework - fat library), made using the following build script:
# Merge Script
# 1
# Set bash script to exit immediately if any commands fail.
set -e
# 2
# Setup some constants for use later on.
FRAMEWORK_NAME="PromiseKit"
# 3
# If remnants from a previous build exist, delete them.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
# 4
# Build the framework for device and for simulator (using
# all needed architectures).
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch arm64 only_active_arch=no defines_module=yes -sdk "iphoneos"
xcodebuild -target "${FRAMEWORK_NAME}" -configuration Release -arch x86_64 only_active_arch=no defines_module=yes -sdk "iphonesimulator"
# 5
# Remove .framework file if exists on Desktop from previous run.
if [ -d "${SRCROOT}/${FRAMEWORK_NAME}.framework" ]; then
rm -rf "${SRCROOT}/${FRAMEWORK_NAME}.framework"
fi
# 6
# Copy the device version of framework to Desktop.
cp -r "${SRCROOT}/build/Release-iphoneos/${FRAMEWORK_NAME}.framework" "${SRCROOT}/${FRAMEWORK_NAME}.framework"
# 7
# Replace the framework executable within the framework with
# a new version created by merging the device and simulator
# frameworks' executables with lipo.
lipo -create -output "${SRCROOT}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SRCROOT}/build/Release-iphoneos/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}" "${SRCROOT}/build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}"
# 8
# Copy the Swift module mappings for the simulator into the
# framework. The device mappings already exist from step 6.
cp -r "${SRCROOT}/build/Release-iphonesimulator/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule/" "${SRCROOT}/${FRAMEWORK_NAME}.framework/Modules/${FRAMEWORK_NAME}.swiftmodule"
# 9
# Delete the most recent build.
if [ -d "${SRCROOT}/build" ]; then
rm -rf "${SRCROOT}/build"
fi
When I go to archive my Parent App Project using Xcode 10 (And also 9.4.1) with Bitcode ON (that contains My Framework reference, and PromiseKit Fat library), I get the following error on the Signing stage: (Failed to verify bitcode in PromiseKit.framework/PromiseKit: error Cannot extract bundle from /var/folders..../(x86_64) - which suggests that it's simulator slice related)
If I turn the "Rebuild from Bitcode" option in the Organizer to OFF, then I get a different error: (Code signing "PromiseKit.framework" failed)
However, if I use Xcode 9.4.1 With Bitcode OFF, then it exports and signs fine.
Why is it trying to individually re-sign sub frameworks, and what can I do to alleviate the issues? I need the archiving to work normally with Xcode 10, along with any future third party dependencies being added to my framework target. (This is the first dynamic framework dependency added to my Framework target. Before I was "baking in" - in-boarding all 3rd parties for ease of development purposes, but PromiseKit is difficult to inboard due to extensive dependencies on Objective-c).
The Xcode Archive log is:
{
code = 330;
description = "Failed to resolve linkage dependency PromiseKit x86_64 -> #rpath/libswiftFoundation.dylib: Unknown arch x86_64";
info = {
};
level = WARN;
},
{
code = 330;
description = "Failed to resolve linkage dependency PromiseKit x86_64 -> #rpath/libswiftObjectiveC.dylib: Unknown arch x86_64";
info = {
};
level = WARN;
},
{
code = 0;
description = "Failed to verify bitcode in PromiseKit.framework/PromiseKit:\nerror: Cannot extract bundle from /var/folders/q5/hm9v_6x53lj0gj02yxqtkmd40000gn/T/IDEDistributionOptionThinning.RJD/Payload/MyAppName.app/Frameworks/PromiseKit.framework/PromiseKit (x86_64)\n\n";
info = {
};
level = ERROR;
type = "malformed-payload";
}
);
Some other solutions I tried was using a Project Reference to PromiseKit, instead of a Framework reference, however this doesn't work - in that I still need a framework reference from my main project, because I will get "library not loaded" error at runtime, if running without a FW reference. Same issue occurs when archiving while using a project reference.
Try this! It worked for me and many other people:
Goto
Build phases > Add > New Run Script Phase
The code should work for any default shell, but I recommend just using /bin/sh
and include the following code:
# Type a script or drag a script file from your workspace to insert its path.
# skip if we run in debug
if [ "$CONFIGURATION" == "Debug" ]; then
echo "Skip frameworks cleaning in debug version"
exit 0
fi
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[#]}"
rm "${EXTRACTED_ARCHS[#]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
It seems hat some frameworks ship architectures, that will not be used in the application.
Xcode will refuse to sign them. The above script removes unused architectures.
Credits: Some guy at GitHub, I can't find the exact source anymore.
Same issue here. The only workaround I've found is to use static library instead of framework.
In case you are not able to use static library, you'd better file a bug report to Apple.
This is what worked for me,
I have application and 2 in-house built frameworks, say A $ B.
Application needs A, but A needs B and since Apple doesn't recommend nesting frameworks, so both A and B had to be included in the app.
This is what my Xcode project looks like.
SOLUTION
In the application, under Frameworks, Libraries and Embedded Content, select Embed & Sign for all necessary frameworks. (as shown below)
But for all the custom framework projects, under Frameworks and Libraries section, select Do Not Embed. (as shown below)
This fixed the issue for me

"${PODS_ROOT}/SwiftLint/swiftlint" causes "Command PhaseScriptExecution failed with a nonzero exit code" with Xcode 10

Updating from Xcode 10.0 beta 2 to Xcode 10.0 beta 3 I now get this error at build time for an iOS project:
sourcekit: [1:connection-event-handler:10499: 0.0000] Connection interruptsourcekit: [1:updateSemanticEditorDelay:10499: 0.0007] disabling semantic editor for 10 secondssourcekit: [1:pingService:10499: 0.0007] pinging servicesourcekitten: connection to SourceKitService restored!
Connection interrupted
Never call this for file that sourcekitd fails.: file File+Cache.swift, line 127
/Users/Coeur/Library/Developer/Xcode/DerivedData/My-App-eloayqptodupvfhbyegtkncnhcpu/Build/Intermediates.noindex/My-App.build/UAT-iphonesimulator/My-App-Debug.build/Script-379156A71D62F5C100574D04.sh: line 2: 34382 Abort trap: 6 "${PODS_ROOT}/SwiftLint/swiftlint"
Command PhaseScriptExecution failed with a nonzero exit code
Swift 4.1
CocoaPods 1.5.3
SwiftLint 0.26.0
Its because of Keychain Access.
Open Keychain Access
Right Click Login Tab
Lock Keychain Login
Right Click Login Tab again
Unlock Keychain Login
and problem solved :)
It seems to be an issue with the SwiftLint 0.26.0 script when using Xcode 10.0 beta 3 or newer.
Cause
It seems related to SwiftLint #2276, itself related to SourceKitten 0.21.0, fixed in SourceKitten 0.21.1 and SwiftLint Master.
Solution
Update to SwiftLint 0.27.0 or newer:
pod 'SwiftLint', '~> 0.27'
(and run pod update SwiftLint)
Some Framework or SDK require Code Signing.
I done code signing and resolved the problem for me.
The pod that I was using was not updated for Xcode 10, so the solution that worked for me was to remove Cocoapods from my project and then installed again (the project was created on Xcode 9).
To remove it, the easiest way is:
$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean
After that, install the pods again.
I just restarted my Macbook and it worked.
For me adding arm64 architecture in "Build Setting -> valid architectures" resolved the issue.
I had an authentication process (outside of Xcode) running in the background which seemed to be causing this issue for me. I had the keychain dialog up asking for my password. Solution was to restart the machine.
Solution worked for me
I deleted all pod generated files and folders as listed below
Podfile.lock
Pods folder
ProjectName.xcworkspace
Again install pod for this project.
Now open .xcworkspace. Build and run...
It may cause the iOS 13 version. My error is to look at below
Assignment/Pods-Assignment-frameworks.sh: eval: line 131: unexpected EOF while looking for matching `''
Command PhaseScriptExecution failed with a nonzero exit code
Pods -> Targets Support Files -> Pods-AppName -> Pods-AppName-frameworks.sh.
Just commented particular line 131
# eval "$code_sign_cmd"
then clean and run
For me it was an issue with swiftlint. This happens when ever there are serious errors, for example forced unwrapping that swift lint validates.
The actual SwiftLint errors are not shown. Instead this “Command PhaseScriptExecution failed with a nonzero exit code” error is shown. After a bit struggle, I figured out that if your project's directory name or any its hierarchy folders have an apostrophe 's , then actual swiftlint errors or warnings are not shown even after including the runscript for it.
So I just had to rename my folders.
For example:
User -> Dave's Projects -> Git -> ProjectName
should be changed to
User -> Daves Projects -> Git -> ProjectName
This will show you errors or warnings. You can then fix the errors and hopefully the concerned error will also be fixed.
This issue resolves for me when I wait and let the project complete indexing before I do anything!
Restarting Xcode 10.1 fixed it for me; arose while updating Cocoapods ('RxSwift').
If the directory where your project is has blank spaces that problem occurs
To solve that problem add double quotes(""). For example:
"$(SRCROOT)/my framework/path"
In my case, Apple development certificate got expires.
To verify open Keychain -> My certificates -> check developer certificate is valid or not, If certificate is not valid then follow the below steps.
Open your apple developer account and create a new development certificate
Download and add it in your keychain.
Go to profiles and open your existing development profile and add the newly created certificate.
Download the fresh profile and install it.
Hope this helps you too.
I had this issue on my ionic4 app after I have used cocoapods. My issue was that in Targets->Build Phases->Embed Pods Frameworks, I had a wrong path to Pods-MyApp-frameworks.sh script correcting that path solved the issue for me.
Its because most of the time $PODS_ROOT variable doesn't set after installing pods
For me, there seems to be an issue with the swiftlint script. It was initially this, Which was what was in the doc as of the time of installation
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
I resolve the issue by modifying it to
if swiftlint
then
echo "swiftlint installed"
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
Not sure, this may be due to my XCode version(10.3)
I resolve the issue by rewrite the .sh file.
Xcode 10 with Swift 3.
1.rename problem.sh file and command+A then command+C.
2.vi *problem*.sh and command+V.
3.:wq! to save the new file.
Then everything will be ok.
If not ok, chmod a+x *problem*.sh and try again.
Only the following helped me.
Delete Podfile.lock
run pod install
Optional - update SwiftLint version
I had a new Macbook and got this error when trying to archive. I forgot to install cocopods in the new machine, so I did, then restarted the computer and restarted Xcode and it worked.
If you're getting
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
and a red
Command PhaseScriptExecution failed with a nonzero exit code
You should install the specific version of libreadline that you need
brew install readline
brew list --versions readline
brew switch readline 0.0.0

How to run an Xcode built app from the command line (bash)

Following on from my question How to run an xcode project from bash?
I've found the built *.app in the build directory, but I'm trying to figure out how to get xcode to open it as it can't just be run as a Mac OS X program.
Any ideas?
thanks to chuan at this post: XCode Test Automation For IPhone
I'm stuck with the same problem trying to launch my debug output from building my xcode project. I just experimented with the following
open ./prog.app&
seems to do the trick.
I've solved my problem using a bash file that uses rsync to sync working directories and then AppleScript which builds and runs the project.
sync.sh:
#!/bin/bash
# script for moving development files into xcode for building
developmentDirectory="/"
xcodeDirectory="/"
echo 'Synchronising...'
rsync -r $developmentDirectory $xcodeDirectory \
--exclude='.DS_Store' --exclude='.*' --exclude='utils/' --exclude='photos'
echo 'Synchronising Done at:'
echo $(date)
buildandrun:
set projectName to "projectName"
# AppleScript uses : for / in directory paths
set projectDir to "Users:username:Documents:" & projectName & ":" & projectName & ".xcodeproj"
tell application "Xcode"
open projectDir
tell project projectName
clean
build
(* for some reasons, debug will hang even the debug process has completed.
The try block is created to suppress the AppleEvent timeout error
*)
try
debug
end try
end tell
quit
end tell
Then, finally, I'm using a shell script called run.sh aliased in my .bash_profile:
run.sh:
#!/bin/bash
bash utils/sync.sh
osascript utils/buildandrun

Automating Xcode development

Can everything which is done through Xcode GUI be done through command line, like changing app name, changing provisional profile, distribution profile? If yes then how. May be it can be done through xcodebuild , but till now i am only able to compile through xcodebuild.
Yes. Building can be done through xcodebuild:
$ xcodebuild -help
Usage: xcodebuild [-project <projectname>] [-activetarget] [-alltargets] [-target <targetname>]... [-parallelizeTargets] [-activeconfiguration] [-configuration <configurationname>] [-sdk <sdkfullpath>|<sdkname>] [-xcconfig <filepath>] [<buildsetting>=<value>]... [<buildaction>]...
xcodebuild [-version [-sdk [<sdkfullpath>|<sdkname>] [<item>] ]
xcodebuild [-showsdks]
xcodebuild [-find <binary> -sdk <sdkfullpath>|<sdkname>]
xcodebuild [-list]
…but I see you already know that. The application name can be changed by simply editing the Info.plist file. And I think you can change the profiles by hacking the *.pbxproj file (it’s a regular text file). You can save a copy of the project file, change a profile through the IDE and then diff the new version and the saved copy to see the changes:
$ find . -name '*.pbxproj'
./Source/Foo.xcodeproj/project.pbxproj
$ cp Source/Foo.xcodeproj/project.pbxproj ~/Desktop
# …now changing the profile through IDE…
$ diff Source/Foo.xcodeproj/project.pbxproj ~/Desktop/project.pbxproj
517d516
< "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "…";
534d532
< "PROVISIONING_PROFILE[sdk=iphoneos*]" = "…";
But it depends on what you are trying to do. You could switch the profiles much easier by setting different profiles for different build modes (Debug/Distribution/Whatever).