Xcode not finishing archiving on "validate *.app" step - objective-c

So I am running xcode 4.6 trying and trying to make a release archive for an iPad app. Unfortunately, when I hit Product>Archive, XCode will not finish the archive. When i go into the logs, it gets all the way through the code sign step and just hangs on "validate Finger-Spelling.app" (It is an ASL app)
It had the same issue earlier, but it fixed it when I updated to xcode 4.6. Honestly, I probably have just forgotten something simple, so I here are is the build log for the step it is stuck on.
The build log step that it is stuck on:
Validate /Users/Michael/Library/Developer/Xcode/DerivedData/Finger-Spelling-dfbrlachhucwlcamnxjofkjuekbi/Build/Intermediates/ArchiveIntermediates/Finger-Spelling/InstallationBuildProductsLocation/Applications/Finger-Spelling.app
cd "/Users/Michael/Documents/Xcode Projects/Finger-Spelling"
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv PRODUCT_TYPE com.apple.product-type.application
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Users/Michael/Library/Developer/Xcode/DerivedData/Finger-Spelling-dfbrlachhucwlcamnxjofkjuekbi/Build/Intermediates/ArchiveIntermediates/Finger-Spelling/InstallationBuildProductsLocation/Applications/Finger-Spelling.app
It also may be my Bundle ID, which is "com.MichaelB.Finger-Spelling", but that matches up with everything in my info.plists.

really a stab in the dark but when I had a problem here it was that the version number I had entered was incorrect.

Related

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 /

Error when enabling auto login of macOS app using a helper

I'm trying to have my app auto launch on login following Tim's tutorial: http://blog.timschroeder.net/2012/07/03/the-launch-at-login-sandbox-project/
I followed the instructions to the letter but I'm getting an error when I re-login to my computer as follows:
Jan 10 12:55:01 pc61 com.apple.xpc.launchd[1] (com.myApp.macgap.helper[25725]): Could not resolve CFBundleIdentifier specified by service: -10814: com.myApp.macgap.helper
Jan 10 12:55:01 pc61 com.apple.xpc.launchd[1] (com.myApp.macgap.helper): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
To outline:
I have my main app called "myApp" (ID: com.myApp.macgap )
In that app I have a helper app with ID: com.myApp.macgap.helper
When you launch the main app and go to preferences, you have an option to enable auto login (to fit to the Apple compliance rules)
I log out of my computer, log back in and look at the console to see what's going on (that's how I get the code above)
Another point worth mentioning, is when I do "Show package content" on the app and double click the helper app, it does launch the main app...
It all comes down to how launchd and launchctl work, as already answered, the regular use case often can be solved by reinstalling the app and ensuring the app is inside the applications folder. But there's another case that #byb is talking about, when this happens on your development machine – this can be caused by invalid launchd configuration.
When you run SMLoginItemSetEnabled it registers your bundle identifier along with other information in launchd service. At some point later, when your app changes, gets cleaned, or something else happens to it, which gets picked up by launchd, launchd may disable that particular login item. Apparently, sometimes this doesn't go smoothly, and consecutive calls with SMLoginItemSetEnabled will not work as expected or the agent / helper app simply won't launch.
The first thing to try is simply changing the bundle identifier for your launcher. If this solves the issue, try figuring out what's wrong with the original. Run launchctl print-disabled "user/$(id -u)" to display disabled services and login item associations. If the output contains your troubling bundle identifier – you are in luck.
I didn't find a way of removing disabled services by name using launchctl and had to do it by manually editing configuration files. Because they system-owned, you won't be able to simply click and edit, instead launch Xcode as root and remove the necessary references.
sudo /Applications/Xcode.app/Contents/MacOS/Xcode "/private/var/db/com.apple.xpc.launchd/loginitems.$(id -u).plist"
sudo /Applications/Xcode.app/Contents/MacOS/Xcode "/private/var/db/com.apple.xpc.launchd/disabled.$(id -u).plist"
Restart, run launchctl print-disabled "user/$(id -u)" to confirm removed items are no longer in the list. Try SMLoginItemSetEnabled again, hopefully now it will work as expected.
I had the exact same problem just now, and while looking for a solution found this (unanswered) question.
At least in my case, this desired functionality of the worked fine when I copied the app (exported from Xcode as a dev-id signed .app) to a fresh OS X install/account without all my development stuff on it. Of course it must also be in /Applications, as stated in the tutorial referred to in the question.
I am not sure why this feature of the app did not work on my development machine. Perhaps the problem could be due to some form of conflict with all the other near-identical copies of my app I have on disk (I have an archive of different versions of the app, plus the copies Xcode stores itself), all with the same bundle id of course.
Hope this helps in one way or another!
I had the same problem, removing other copies of app except one in /Applications solved the problem for me. To remove .app files generated by Xcode you can run Product->Clean.
I was struggling with this for hours. I had many apps with auto login but a new one just did not want to work.
Strangely this worked on the development machine:
Build App as normal
Move it to Application directory
Clean Xcode (CMD+k)!!
Enable auto login in the app.
Logout Login
I accidentally noticed that the system started the app (it tries in every 10 sec) when I clean Xcode :)
I can't find the duplicate copy but did find you can remove the service:
In a terminal window:
launchctl remove com.annoying.service
As it was already stated if there are more then one copies of service bundle on the machine launchd cannot resolve which one must be started by bundle identifier.
What I would recommend to you is find all copies of your service and then remove not desired ones.
For this you need to run following Swift code (It works even in Swift Playground):
import Cocoa
let bundleId = "com.your.bundleId"
let paths = LSCopyApplicationURLsForBundleIdentifier(bundleId as CFString, nil)
print("Available service instances by bundle id: \(paths)")
In my case it produces:
Available service instances by bundle id:
Optional(Swift.Unmanaged<__ObjC.CFArray>(_value: <__NSArrayI 0x6000002234a0>(
file:///Applications/MyApp.app/Contents/Library/LoginItems/MyService.app/,
file:///Users/igor/Library/Developer/Xcode/Archives/2017-12-27/MyApp%2027-12-2017,%2016.06.xcarchive/Products/Applications/MyService.app/
)
))
So I easely identified copy to be removed:
file:///Users/igor/Library/Developer/Xcode/Archives/2017-12-27/MyApp%2027-12-2017,%2016.06.xcarchive/Products/Applications/MyService.app/
Hope it help.
Assuming that you followed Tim Schroeder's recipe at: http://blog.timschroeder.net/2012/07/03/the-launch-at-login-sandbox-project/ :
What actually ended up working for me, was, in Xcode, to change my main project's build number from 1 to 2. I also tried a build number of 1000 and that worked fine as well.
In Xcode, select your main project target. Then, select the 'General' tab. If you see your Build is set to 1, change it to 2 and then rebuild, redeploy and see if that resolves the issue for you.
This was probably one of the screwiest bugs I have run into, in a while.

ObjC ARC contraction (clang crash)

I always hesitate to add a brand new question to the killer forums here, but I haven't seen anything close to this bug.
Seems clang has crashed on my while compiling one of my .m files. If anyone has seen or knows of any solution for the below I'd be immensely obliged.
This error occurs when I build for armv6 in a release configuration using XCode 4.4.1
But does not occur when I build for armv6 in a debug configuration, or release for armv7, armv7s or i386.
The specific error is "ObjC ARC contraction":
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '/Users/Me/Documents/ThisProject/iOS/..../ClassFoo.m'.
4. Running pass 'ObjC ARC contraction' on function '#"\01-[ClassFoo evalJS:]"'
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
In the ../Intermediaries/Project.build/armv6/ folder I see:
ClassFoo.dia
and I should see (like all of its surrounding files)
ClassFoo.d
ClassFoo.dia
ClassFoo.o
Here are the top 4 of the clang stack, in case someone recognizes something in it:
0 clang 0x00000001010536f2 main + 17107682
1 clang 0x0000000101053b79 main + 17108841
2 libsystem_c.dylib 0x00007fff93c428ea _sigtramp + 26
3 libsystem_c.dylib 0x00007fff93c7a54e tiny_malloc_from_free_list + 1078
edit: I also noticed when trying again recently that I'm getting complaints about the -fno-objc-arc flag -- perhaps the compiler sym-links are pointing at the wrong binaries?
Thanks in advance,
Miles
Thanks for all your interest, and I'm sorry to have to answer this question myself but no other solution I've tried has resulted in anything successful. I've done my best to document my adventure here as a how-to-guide to hopefully help a few others.
The short version:
Xcode 4.5+ does not support building to armv6 (iphone 3g).
With fresh installs of 4.5 & 4.4.1 I experienced various versions
of the original error.
The reason is two-fold:
xcspec files Xcode uses do not include entries for this architecture.
4 needed libclang_rt*.a files have had their armv6 slices stripped.
There is a solution! (see long version below)
The long version:
Amongst the many many frustrating attempts I made to sort this issue out, such as searching SO forums, searching apple dev forums, googling, endlessly fiddling with project settings, copying earlier SDKs into the Xcode.app packages, posting this question, filing a bug report with Apple, etc. ad infinitum <-- means, "and so in into infinity" each seemed to have either nothing pertinent to reveal or only a tiny tidbit of information.
The recipe for this solution finally took one frustrated and determined developer and the culmination of everything in one very long night.
So where's the how-to?
( Right here, bro )
There are about 12 steps, so don't forget the final ones below the images!
Disclaimer: This is my own solution and it works great for me, but if you're not sure about what's going on or what you're doing please be very careful and realize that I will assume no responsibility for any damages you may incurr by trying to follow these steps. That said, here you go!
If you don't already have a copy, download Xcode 4.4.1 from http://connect.apple.com
Extract /PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
Copy it to /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
Now you'll edit 4 Xcode .xcspec files in your Xcode 4.5:
Navigate here: /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications
Select these files:
iPhoneXcode4Options.xcspec
iPhoneOSArchitectures.xcspec
iPhoneCompilerOptions.xcspec
iPhoneClangOptions.xcspec
Right-click and select "Open with Xcode"
Repeat for Xcode 4.4.1, and stick the two windows side-by-side (just makes this easier).
You're going to add armv6 to several entries as below:
Here again:
And here:
Here you cut & paste an entry from Xcode 4.4.1 to Xcode 4.5:
Alright you completed that tediousness, yay! Save the edited files and close them all. Next you have to create new libclang_rt*.a files to handle compiling these arches. This step is more easily done in Terminal. Enter these commands:
Make sure the backups copy and there isn't some error in paths or typing!
cd /PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir armv6_extractions
lipo -extract armv6 -output armv6_extractions/libclang_rt.ios.armv6.a libclang_rt.ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.profile_ios.armv6.a libclang_rt.profile_ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.cc_kext.armv6.a libclang_rt.cc_kext.a
sudo cp -R armv6_extractions /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
cd /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir originals
sudo cp libclang_rt.ios.a originals/
sudo cp libclang_rt.cc_kext_ios5.a originals/
sudo cp libclang_rt.profile_ios.a originals/
lipo -create -output libclang_rt.ios.a armv6_extractions/libclang_rt.ios.armv6.a originals/libclang_rt.ios.a
lipo -create -output libclang_rt.cc_kext_ios5.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.cc_kext_ios5.a
lipo -create -output libclang_rt.profile_ios.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.profile_ios.a
Restart Xcode 4.5
^...I wrote "11" here...why's it showing as "1"?
Open your project and edit your settings accordingly. I recommend that you create a separate configuration just for building to armv6, and lipo everything together when you're done.
Add armv6 to Valid Architectures
Add armv6 to Architectures
For your specific armv6 configuration, set Base SDK to iOS 5.x (whatever is now listed in the drop-down menu)
Set your deployment target as needed ( I have built as low as iOS4.1 so far, and I believe the iOS5.x sdk you installed in the beginning can deploy as low as 4.x )
Okay, I think that's all.
If anyone sees any edits that need to be made PLEASE do so, and I welcome any feedback that anyone has to give here.
If something goes wrong, fingers crossed you can always reinstall your Xcode and try again (or not).
Best of luck.
I have had this problem before.... did you initialize your .m more than once? or import it? the only time this issue has occurred for me is when I tried to initialize or import a .m file somewhere other than where its native environment was.
A compiler should not crash. If it does then the vendor needs to fix it. Unfortunately I don't think you will be able to get any useful response via a Radar from Apple because they have moved on: there is a newer version of Clang in Xcode 4.5 and they don't support armv6 any more.
Having said that you should open a Technical Support Incident, because likely they can provide you with a workaround.
The error message indicates an internal error in the compiler while processing the function #"\01-[ClassFoo evalJS:]". You might be able to get around the error by rearranging the code in that function and/or adding volatile to local variables in that function.

iOS: XCode 4.4.1: xcodebuild error - Unable to read diagnostics from file

So I would like to use xcodebuild in Terminal to create a build from a test application (called RunTeszt1). The app is an iOS single view application with nothing in it, just created and closed.
When I this from the Terminal, the build fails.
xcodebuild -target "RunTeszt1" -sdk "$iphoneos5" -configuration Debug
The error is:
Unable to read diagnostics from file "/var/folders/6s/cjw35hhs5lb6wpnx9m8lr2km0000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/RunTeszt1-Prefix-eqntxoxxhhlzvieuipqbxfumbpxb/RunTeszt1-Prefix.pch.dia" (Invalid File): Bad header in diagnostics file
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
When I run the app from XCode (4.4.1), the build completes and everything is ok. However, If I run the Console app and inspect the results after hitting build button in XCode, I see the same error message in the console. Nevertheless the build succeeds and opens the simulator.
Is this really a bug in xcodebuild which should be sent to apple? If it is I imagine a bunch of people already sent it.
How can I either make the error go away, or stop it from cancelling the building process, so circumvent it like XCode does?
Turns out the problem was code signing. Even though I put Don't code sign in the build settings, it still hanged up on it. Also it seems "-sdk xxx" was also at fault (no matter what sdk I specified).
Running this command resulted in a successful build:
xcodebuild clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -target RunTeszt2

Command /usr/bin/lipo failed with exit code 1 error

I have finally finished my app and I was getting ready to upload when this sudden error hit me and I have no idea what to do. I have checked other posts saying to change the code signing identity and I have done this but no luck. I tried every single option in the identity and no change. If anyone knows what is going on I would really appreciate it since I would simply just like to submit my app.
Here is what else it says in the erorr log:
/usr/bin/lipo: /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocerystores.build/Objects-normal/armv7/grocery stores and /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocery stores.build/Objects-normal/armv7/grocery stores have the same architectures (armv7) and can't be in the same fat output file
Command /usr/bin/lipo failed with exit code 1
I solved this issue by changing the value of the Valid Architecture found in Project > Build Settings > Architectures from the default "armv6 armv7" to "armv7". Hope this helps.
It's hard to see what exactly is happening without the command you are running. It looks to me like you are specifying the same input file twice, namely the arm7 version and lipo is telling you you can't add 2 arm7 versions of grocery stores to the universal file. Can you please enter the entire lipo command you are running? From the lipo man page:
-create
Take the input files (or file) and create one universal output file from them.
Do you possibly have the same file listed twice here?
Try changing your build target to a simulator build, clean and re-run.
In my case I used pods and oped projectFile instead of project workspace
In my case it was building a project on simulator in a release scheme, changed it to debug and it worked.