Jenkins succeeds without producing IPA file - ios

I have setup an mac mini slave on jenkins. The build process succeeds and my .app file and .dysm files etc are all created successfully.
I have Pack application and build .ipa? checked and defined a ipa filename pattern and an output directory.
When I run the build process, it actually creates the full path of my output directory, but at the end of the path, there is nothing in the final folder. No IPA. Again, the .app and other files are created successfully in the workspace build folder.
Also doesn't work if I leave the output directory blank or change it to other locations.
Jenkins succeeds with this message:
** BUILD SUCCEEDED **
Cleaning up previously generated .ipa files
Cleaning up previously generated .dSYM.zip files
Packaging IPA
Finished: SUCCESS
But alas, no IPA. Any ideas?

I was not able to solve the issue directly, so I am still interested in answers from someone who might have a more direct solution using the Xcode plug in with the pack and build ipa option.
Instead, I removed this option (unchecked it) and added another build phase for execute shell script.
I then added the script from this SO answer (modified for my use) and was able to export the ipa successfully.
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${RELEASE_BUILDDIR}/${APPLICATION_NAME}.app" -o "${BUILD_HISTORY_DIR}/${APPLICATION_NAME}.ipa" --sign "${DEVELOPER_NAME}" --embed "${PROVISONING_PROFILE}"
RELEASE_BUILDDIR and BUILD_HISTORY_DIR were changed to my own paths, and -sign and -embed were not needed because i'm using the same profile as the one that created the original .app file
I did have to use mkdir -p to make the path or it wouldn't succeed for me

So I was having the same problem and this is how I solved it:
In the Jenkins job, in the configure interface, under Advanced Xcode build options, I specified a Build output directory: ${WORKSPACE}/builds.
I also added a shell script to execute prior to the Xcode build phase:
mkdir -p "${WORKSPACE}/builds"
Now when I click the check box for "Pack application and build .ipa?", specify a .ipa filename pattern and use the output directory: ipa , the job runs, succeeds, and gives me a .ipa I can see in the Workspace at /builds/ipa/{name}.ipa
I hope this helps.

Had exactly the same problem as you.
Besides "Pack application and build .ipa", you also have to check "Unlock Keychain?" which can be found at "Code signing & OS X keychain options".
Furthermore, set the keychain path to:
${HOME}/Library/Keychains/login.keychain
The keychain password for me was the same as my user password. If you leave that field empty, you will see that your build freezes at a certain point. Inside the terminal where you started jenkins, you will see that it waits for you to type the password.
Hope it helped.

Related

Could not complete submission of dSYM, File no longer exists at (null)

I have migrated Fabric to Firebase/Crashlytics and I am getting this below build error for my run script in an iOS project,
Build Phase - Run Script
# Name of the resource we're selectively copying
GOOGLESERVICE_INFO_LOCATION=${PROJECT_DIR}/${TARGET_NAME}/App/Scripts/GoogleService-Info.plist
# Upload sysmbol
echo "Uploading dsym file"
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp ${GOOGLESERVICE_INFO_LOCATION} -p ios ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
Build Error
[31merror: Could not complete submission of dSYM at /Users/me/Library/Developer/Xcode/DerivedData/Project-cmkidnrcwbunsqezgsrutqkmnivn/Build/Intermediates.noindex/ArchiveIntermediates/Project/BuildProductsPath/ReleaseOfficial-iphoneos/Project.app.dSYM: Error Domain=com.crashlytics.mac.error-domain.process-dsym Code=2 "File no longer exists at (null)" UserInfo={NSLocalizedFailureReason=File no longer exists at (null)}
Suggested in solution didn't work for me.
How to resolve it?
I recently got a new Mac and faced the same issue.
After trying lot of different things with no success, I found what was wrong. All I had to do, is to move my upload DSYM script at the bottom of the build phases script list.
We talk about this script:
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/YourPathToYourGoogleServiceFile/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
It has to be the last one executed
If this does not work, try this :
Comment your DSYM script, then archive your app.
Your archive should complete with success
Uncomment your DSYM script, and place it to the bottom list. (see correct order below)
Build a new archive.
Correct order :
run firebaseCrashlytics script.
run [CP] Embed pods frameworks
run DSYM Script
NB: In some cases, having a path containing some white spaces such as 'Supporting files' may lead to unexpected behaviour.

Xcode not generating all required dSYMs even though Build Settings have Debug Information Format = Dwarf with dSYM

Xcode is generating one dsym, which has the name of my app as the filename (e.g. MyApp.app.dSYM), but it's not generating the other dsyms with the UUIDs that Firebase is constantly telling me that I'm missing. (e.g. 92248A4B-6CA2-3B54-9787-C007E25C018F.dSYM)
I've followed the instructions, but something is still wrong. This was working when we were using Fabric, but since we updated to use Firebase directly, nothing is really working properly anymore.
I've followed the instructions on how to change the Build Settings to make sure the dSYMs get generated, but my Build Settings were already updated like that when I following the migration instructions from Fabric to Firebase. Here is a screenshot of my Build Settings:
Here is a screenshot of my Run Script Build Phase:
In the Archive Build Log, the only reference to generating dSYMs is for the one MyApp.app.dSYM that I get, but I need the others generated too.
GenerateDSYMFile
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
(in target 'MyApp' from project 'MyApp')
cd /Users/kenny/inaday2/svn-MyApp/trunk/apps/iOS/MyApp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dsymutil
/Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app/MyApp
-o /Users/kenny/Library/Developer/Xcode/DerivedData/MyApp-dttbmiamkojuotbcyjgzerxhcqun/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath/Release-iphoneos/MyApp.app.dSYM
Settings look okay, attaching the script I am using and process. Hope these info helps.
To have all the dsyms you need to first upload the build to Testflight and then from Tesflight, you need to download the final processed dSYM.zip.
A folder appDsyms.zip will be downloaded, once this is decompressed, you will see list of dSYM's
Post that use below script to upload the same to crashlytics.
So there are few changes done in Firebase Crashyltics the way dSYM mapped to the build we upload.
Initially, there was a manual option as well to upload but now that's abandoned and the only way by running the script from your terminal.
Pods/FirebaseCrashlytics/upload-symbols -gsp YOUR_PLIST_FULL_PATH -p ios ~/PATH_TO_DSYM_ZIP_OR_FOLDER
**Example[Below is my working script to upload dSYM to crashlytics]:**
Pods/FirebaseCrashlytics/upload-symbols -gsp MY_PRROJECT_NAME/Support/Firebase/Prod/GoogleService-Info.plist -p ios ~/Downloads/appDsyms

iOS and FirebaseCrashlytics

I am trying to follow the instructions on Firebase Docs to upload missing required dSYMs. However I am stuck on running the uploader script.
In my build phases I have
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols -gsp${SRCROOT}/GoogleService-Info.plist -p ios ${SRCROOT}/appDsyms"
When I try building the iOS app with this, I get the error:
line 4: /path/to/Pods/FirebaseCrashlytics/upload-symbols -gsp/path/to/GoogleService-Info.plist -p ios /path/to/appDsyms: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code
When I try running the script from the terminal I get the error:
No Google App ID or Google Services file provided
I have verified that I have a Google Services file and am able to run my project using other firebase services that rely on it. I used to be able to upload Dysm files directly into the Firebase Console, but that changes on March 1.
Should this command be run as an XCode script or a command from the terminal? And, more importantly, does anyone understand how to resolve this issue?
As of May 2020:
After Fabrics shut down, many developers faced such issues because Fabric was automatically creating the script to upload dSYM files from Xcode and we never pay attention to it.
Now as Fabric is replaced with FirebaseCrashlytics, in order to achieve this automatic mechanism, you can create a new run script and paste this script there:
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
This script will get the dSYM files and upload them to firebase servers so that you can see the crashes.
For multiple Schemes:
If your project has multiple schemes, you can simply create multiple such scripts by changing the path to the Google Plist file.
NOTE: You can also manually upload the dSYM files using upload-symbols tool [Check here], but it's always better to automate the process wherever we can.
EDIT: July 2020:
When you see missing dSYM files for the crash in the Crashlytics dashboard, instead of getting the email for it, you can upload the dSYM file for the build as soon as you submit it for Apple review or for testing via Test Flight.
Missing dSYM is shown because when bitCode is enabled, the App Store Connect process the binary post uploading it and generates a new dSYM file.
You can find the dSYM file from the Activity section in the App Store Connect.
2020 FirebaseCrashlytics solution
You have two solutions :
1) From the command line
Go to your project folder and run :
./Pods/FirebaseCrashlytics/upload-symbols -gsp GoogleService-Info.plist -p ios <path_to_your_dsyms_zip>
You can get your dsym in Xcode organizer > right click on the archive > show in Finder -> Show content -> go to dsymm folder and compress it
2) From Xcode Build Phases
As described here (Firebase doc), you can add a Run Script phase in Xcode with this content :
"${PODS_ROOT}/FirebaseCrashlytics/run"
You also have to add these two input files under the run script :
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
and
$(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)
After hours of struggling with this problem finally solved it using this approach:
use this command in Terminal: /path/to/pods/directory/FirebaseCrashlytics/upload-symbols -gsp /path/to/GoogleService-Info.plist -p ios /path/to/dSYMs
Important thing is instead of /path/to/pods/directory you should enter the path to your pods folder in your application folder, and instead of /path/to you should enter the path to the GoogleService-Info.plist which is in your project folder too. And the last one is, instead of /path/to/dSYMs you should enter the path to your archive which has the format of .xcarchive.
For finding the .xcarchive path, you should first archive your application, then go to XCode -> Organizer and select your build, then right click on it and select "Show in finder" and then right click on your .xcarchive file and select "Show package contents". This is it, you can copy this path and paste it instead of /path/to/dSYMs and then hit enter to start uploading to Firebase Crashlytics.
Check out this link for more information:
Firebase Docs
While implementing FirebaseCrashlytics(Currently is in beta) for Crashlytics
Add new run script from Build Phases and add the following :
"${PODS_ROOT}/FirebaseCrashlytics/run"
In Input Files sections add
${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
and
$(SRCROOT)/path to/GoogleService-Info.plist
If you still get dSYM missing error then try to run from terminal
/path/to/pods/FirebaseCrashlytics/upload-symbols -gsp /path/to/GoogleService-Info.plist -p ios /path/to/dSYMs
For path to FirebaseCrashlytics and GoogleService-Info.plist drag and drop from the actual location
For dSYMs path will be ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}
To get that hit the command with your project .xcodeproj and target xcodebuild -project YourProject.xcodeproj -target YourTarget -showBuildSettings
and replace your specific path
Please take note of the following while implementing Crashlytics
1. Run application in release mode
2. While testing disconnect device from mac
3. Set correct GoogleService-Info.plist
4. If you rename it, make sure you set the correct file name whenever required.
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp
"${PROJECT_DIR}/additional_folder/GoogleService-Info.plist" -p ios
"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
I replaced my GoogleService-Info.plist in additional folder and made directory changes in shell script. Probably you should do the same
For terminal command you better drag and drop necessary file in terminal then copy selected path
/path_to_pods/FirebaseCrashlytics/upload-symbols -gsp
/path_to_google_service/GoogleService-Info.plist -p iOS /path_to_dSYMs
Believe me, I spent one day but nothing worked,
Surprisingly few solutions are working for a few projects for my colleagues but I'm using Big Sur & Xcode 12.2 nothing worked for me.
Tried 1: Each step mentioned in firebase doc.
Tried 2: Tried to upload symbol from terminal by passing path_to_pod_firebasecrshlytics/uploadsybol -gsp path_to/GoogleService-Info.plist -p ios path_to/dSYMs
But, No luck,
Following trick works for me,
Step 1: make sure you are on the latest firebase crashlytics version for it, give a path to project & fire cmd pod update
I was using Firebase Crashlytics version 4.0.0-beta.1 but after pod update it is 8.2.0
Step 2: Go to build phase add a run script bellow compile bundle resources "${PODS_ROOT}/FirebaseCrashlytics/run"
Step 3: Add DYSM Script, "${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/your_path/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
Step 4: Build project;
Step 5: Run project & Stop or disconnect from storyboard
Step 6: Make crash 2-3 times & wait for 2-5 mins.
Cheers, All Set!
We can do:
PATH_TO_GOOGLE_PLISTS="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist"
To get a reference to the plist
Then use it:
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PATH_TO_GOOGLE_PLISTS}" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
Your Google Services path seems to be off. Here is an example of what my build phase looks like, which is able to successfully upload dSYM's. I suggest following these instructions one more time https://firebase.google.com/docs/crashlytics/get-deobfuscated-reports-new-sdk?platform=ios&authuser=0.
find /Users/okodysh/Library/Developer/Xcode/DerivedData/myApp-ftqksfkpdvisbtaozpqzzjiizpfk/Build/Products/Debug-iphonesimulator -name "myApp.app.dSYM" | xargs -I {} $PODS_ROOT/FirebaseCrashlytics/upload-symbols -gsp /Users/okodysh/Desktop/iOSApps/myApp/myApp/GoogleService-Info.plist -p ios {}
Finally, I've figured it out and wrote a shell script to handle all this for me
Feel free to to use it: https://github.com/cs4alhaider/firebase-upload-symbols
Hmm nothing worked for me but changing this:
"${PODS_ROOT}/FirebaseCrashlytics/run"
to this:
"${PODS_ROOT}/FirebaseCrashlytics/run" -gsp "${PROJECT_DIR}/project_main_dir/google-services-files/iOS-GoogleService-Info.plist"
EDIT:
for those of you trying to complie to iOS's Catalyst:
you don't have to download two different Google JSON files. You should use only one (cause you have only 1 target). IF you want to upload a mac version of your app, just go to App Store Connect and create a new release for OSX (in the same page of your app)
In my case none were working until I added this:
"${PODS_ROOT}/FirebaseCrashlytics/run" -gsp "${PROJECT_DIR}/intermediate_folders/GoogleService-Info.plist"
"${PODS_ROOT}/FirebaseCrashlytics/upload-symbols" -gsp "${PROJECT_DIR}/intermediate_folders/GoogleService-Info.plist" -p ios "${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}"
If I didn't add the path to the run command, the build phase would be running forever...
Check you FULL project folder path whether it contains space. I solve it by moving my project into another folder path that doesn't have space.

What could cause code coverage enabled builds to fail?

Summary
I'm trying to get a code coverage report from my project. However when I try to build and run tests, there is no CodeCoverage folder created in the derived data folder.
How am I trying to do this?
I am running xcodebuild as follows:
xcodebuild \
-workspace <some_workspace> \
-scheme <some_scheme> \
-destination <some_destination> \
-derivedDataPath <some_path> \
-enableCodeCoverage YES \
build test
What is the problem?
For my workspace/project it fails at the very end with a line:
xcodebuild: error: Failed to build workspace <some_workspace> with scheme <some_scheme>.
Reason: Could not determine bundle identifier for <some_test_target>'s TEST_HOST: "<some_path>/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/<some_product>.app"
At first it seemed directly linked to the TEST_HOST issue, but that's not the case here.
There is simply no CodeCoverage folder:
<some_path>/Build/Intermediates/CodeCoverage
What have I tried?
I tried the same with a clean new project, same running the same xcodebuild command, which succeeds. Within the Build/Intermediates/ folder exists the CodeCoverage folder.
However, in my own project, which is more complex, the Build/Intermediates/ folder contains a bunch of *.build folders (related to the app and the various frameworks, HockeySDK.build for example) and PrecompiledHeaders but no CodeCoverage folder.
When looking through the output of xcodebuild I never see a reference to the CodeCoverage folder for my project. However, for the test project, the first mention is at:
Write auxiliary files
/bin/mkdir -p /<some_path>/Build/Intermediates/CodeCoverage/Intermediates/<some_project>.build/Debug-iphonesimulator/<some_project>.build/Objects-normal/x86_64
For my project I see:
Write auxiliary files
/bin/mkdir -p /<some_path>/Build/Intermediates/<some_project>.build/Debug-iphonesimulator/<some_project>.build/Objects-normal/x86_64
Workaround
Something else that seemed to 'trick' it into working is to set the Host Application to None. After doing this it builds and tests, but tests fail due to the lack of host. However, this causes the CodeCoverage folder to be created, and if the Host Application is correctly set again, running the build and tests works fine, with a code coverage report produced.
You have to assure the package name is equal in all configurations. Xcode modifies it in case you are using unsupported characters. For instance Xcode replaces "-" with "_".
In all configurations, go to:
Project -> Build Settings -> Product Module
and set the exact same name without spaces.

Code Sign Error in macOS Monterey, Xcode - resource fork, Finder information, or similar detritus not allowed

Already tried : Code Sign Error on macOS Sierra, Xcode 8
Please see image showing error
CodeSign /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
cd "/Volumes/Development/Project/Top Best Games/19. Lets Flow/35/let's FLOW - source/proj.ios_mac"
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Signing Identity: "iPhone Distribution: New Free Games (2CHN583K4J)"
Provisioning Profile: "Super Flow Flipp AppStore"
(c6c30d2a-1025-4a23-8d12-1863ff684a05)
/usr/bin/codesign --force --sign E48B98966150110E55EAA9B149F731901A41B37F --entitlements /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Intermediates/Flow.build/Debug-iphoneos/Super\ Flow\ Flip.build/Super\ Flow\ Flip.app.xcent --timestamp=none /Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super\ Flow\ Flip.app
/Users/gururajtallur/Library/Developer/Xcode/DerivedData/Flow-bkqjkvtmvjovpyepfjeyqmjpintj/Build/Products/Debug-iphoneos/Super Flow Flip.app: resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
In Code Sign section its allowing me to select profile and certificate...but still giving error.
How to fix this problem ?
Solution 1:
Apple Developer Website Answers above problem Here.
Execute below command in terminal : First goto projects root folder
xattr -cr <path_to_project_dir>
Clean Xcode and Re-build.
Solution 2:
Just go to project root directory and run this command xattr -cr .
xattr -cr .
Clean Xcode and Re-build.
Solution 3:
You can fix this problem by finding files which holds finder information.
In terminal, goto project root directory and execute
ls -alR# . > kundapura.txt
This creates kundapura.txt in current directory. Now search for com.apple.FinderInfo and clear this attributes for all files. You can do it like this
xattr -c <filename>
Example: xattr -c guru.png
Once you clear all then code sign works. Clean Xcode and Re Build. Cheers
Solution 4: Inspired by Mark McCorkle's Answer
In terminal, goto project's root directory and execute one by one command
find . -type f -name '*.jpeg' -exec xattr -c {} \;
find . -type f -name '*.jpg' -exec xattr -c {} \;
find . -type f -name '*.png' -exec xattr -c {} \;
find . -type f -name '*.json' -exec xattr -c {} \;
Clean Xcode and Re-build.
The error is from attributes inside your image files. This happened from our graphics designer saving images from photoshop with attributes.
Here is a simple command to find all of your png files and remove their attributes. Run this in your projects root directory from terminal. Clean and rebuild; problem solved.
find . -type f -name '*.png' -exec xattr -c {} \;
If you have this error when codesigning an app:
resource fork, Finder information, or similar detritus not allowed
Command /usr/bin/codesign failed with exit code 1
Go to your project root folder and execute
find . | xargs -0 xattr -c
This will clear attributes for all files.
In Sierra, the rules on what can be in a signed bundle have been tightened, and resource forks are no longer allowed. AppleScript has been saving information in resource forks forever, although that information has been unused for a long time. With Sierra, when you save a script, this resource fork information will no longer be saved.
It means you cannot codesign a script that was last saved in a version before Sierra; you have to save in Sierra to be able to sign in Sierra.
The people likely to be affected by are who bundle other scripts within their scripts (cordova?). They will not be able to sign the container script until all the embedded scripts have been resaved under Sierra.
UPDATE:
Seems like this also works:
xattr -rc .
If you have any insufficient permissions error try to prepend sudo: sudo xattr -rc .
The easiest way to handle attributes on your source files is to have Xcode clear up the archive before it runs codesign. To do this:
Select your target in XCode
Select the Build Phases tab
Press the + symbol
Select New Run Script Phase
Enter the following for the script:
xattr -cr ~/Library/Developer/Xcode/DerivedData || echo Clear
Now when you build your target it will clear out any attributes that would have broken codesign. By clearing out at this stage you don't have to alter your source code / project directory.
The "|| echo Clear" part of the script ensures that the project build continues even if xattr errors.
This method is good if you use programs such as DropBox on your code repository that add the attributes, as it doesn't change your source project, only the built archive.
You may need to change the path to match your DerivedData directory - this path will be shown next to the codesign error.
I have used following command. Use terminal window. Navigate to your Project and execute following:
xattr -rc .
There is official Apple answer for this issue in Technical Q&A QA1940.
This is a security hardening change that was introduced with iOS 10,
macOS Sierra, watchOS 3, and tvOS 10.
Code signing no longer allows any file in an app bundle to have an
extended attribute containing a resource fork or Finder info.
To see which files are causing this error, run this command in
Terminal: xattr -lr <path_to_app_bundle>
You can also remove all extended attributes from your app bundle with
the xattr command: xattr -cr <path_to_app_bundle>
<path_to_app_bundle> can be replaced with directory of your Xcode project. For example ~/Development/MyProject
All about clearing files is fine, but tedious for multiple projects.
graphics apps, (like photoshop in old versions) write additional info (we now call it metadata..) in an old fashion in external files, or they came frm older OSX, files like:
"com.apple.ResourceFork" and "com.apple.FinderInfo", when unzipping folder, for example.
Xcode 8 refuses to add it to a build (as You added them to a project with a "git --add ." maybe..)
You can find in terminal recursively and delete them, but can be tedious.
I wrote a small free utility to delete it.. hope it can help..
https://itunes.apple.com/us/app/cleandetritus/id1161108431?ls=1&mt=12
For those (like me) who are just trying to develop an app without having to strip extended attributes on every new photoshop created PNG added to the macOS target, you can temporarily disable code signing by adding a user defined build setting:
CODE_SIGNING_ALLOWED = No
Obviously, one distributing an app needs to eventually deal with the issue but this enables development in cases like mine where it wasn't necessarily straightforward to omit code signing in Sierra (on past OS X / Xcode it was easier to do so).
Per RGriffith's comment, here are a few screenshots for those who aren't sure how the custom build setting is added.
Simple solution:-
How I did [Working for me]
Step 1:-
Go to this folder - from your finder press option Go - > Go to Folder
then type your project path like this
example:-
Library/Developer/Xcode/DerivedData/yourprojectname/Build/Products/Debug-iphoneos
Now you can see a window pop with list of available File, There you see yourApp.app file [ Don't do anything just wait for step 2].
Step 2:-
Open new Terminal and type just cd then just drag step 1 yourApp.app to terminal, now you will get the path for the app, now press enter button.
Step 3:-
Now type this command **
xattr -rc .
Don't miss "."(Dot) press enter button.
That's it, Go to your Xcode project and clean and run again.
-----In case you can't apply the solutions above, because of lack of bash knowledge or something else.
I had this problem as soon as I enabled iCloud Drive on my Sierra. And my project was in a folder which was synced with iCloud Drive. I suppose this is what adds those additional attributes.
Temporary solution:
Disable iCloud Drive for the folder where your project is.
You will need to delete the app bundle folder and rebuild the app as explained below.
My app is called: augment
In terminal window, goto your app folder
e.g.: cd /Users/username/Library/Developer/Xcode/DerivedData/
In terminal window run command for your app folder
e.g.: xattr -cr augment-flmbiciuyuwaomgdvhulunibwrms
Clean>Build>Run.
There is also a free app on Mac Appstore called "CleanDetritus" which will do removal of these.
This problem came to me yesterday.
(What's wrong) I updated image resources by manually replacing file in finder and I failed with this compilation error.
(What's right) Don't update image in this way. After that I dragged images to 'xcassets' in Xcode. No more error appear again.
My problem is every change I make in the code and execute again the error reappears. Then I find a solution to execute the command automatically every compilation/execution of code.
Thanks to #rich-able I discovered "Run Script". Then I put the command "xattr -cr ." in the field.
One of the best solution is
Go to terminal type this
xattr -cr "Full path of your project"
To find full path of your right click on Xcode project->get info -> copy path and replace with .
Then type below command
xattr -cr "Full path of your project"
Clean and build done.
The simplest fix may be if you are using git. Try:
$ git stash
$ git stash pop
Git does not store file metadata, the above will strip it all away.
Open terminal and just run this command.
xattr -cr "path to .app file"
I found that if I add color tag on the folder under DerivedData, it will give the above error when debug on device.
Remove the color Tag fix this error for me.
My problem was that I used cordova to build the app around 1 year ago, but it wasn't compatible with the new version of xcode, so I simply used cordova build ios and it worked again.
If the xattr commands doesn't the trick this may be due to an XCode 9 bug:
let's try to remove and re-add the resource folder (it was a .xcassets in my case) containing the affected files from Xcode. (you should understand which are the affected files previous through the xattr -lr command)
The problem is in the derived data, You should clean the derived data and then clean the project and build. Please check this link.
I'm also facing the same issue, got fixed by just restarting my Macbook.
You can remove the derived data
Xcode -> Preferences
And click on the arrow below Derived Data, and empty the folder Derived Data
I don't know what happened to me, but when I was running flutter app on simulator, I was encountered by the error. I used flutter clean command and removed the derived data and then everything goes fine.
My .app was on a network mounted drive.
codesign -f -vv --preserve-metadata=entitlements -s {*my Apple distribution cert SHA*} my.app
my.app: resource fork, Finder information, or similar detritus not allowed
I don't know if too long path or the fact it was on a NAS device was a problem. I copied the .app to my local Downloads directory, and then was able to codesign.
my.app: signed app bundle with Mach-O thin (arm64) [*com.something.my*]
This happened to me as well when I duplicated a .plist file and edited it, instead of creating a new one. the xattr -lr <path> command helped me identify the problematic file.
My issue was related to unintended changes on framework integrated using Carthage. I had modified one line in framework by mistake and it didn't show up in git because dependency build folder was ignored from git.
Solution : Deleted framework folder in Carthage and rebuilt it.

Resources