Xcode Build and Archive for Enterprise Distribution builds old archive - ios

I'm working on creating an app for in house distribution enterprise level. I've created the app and tested hosting it on my own server and even getting the click to install working. Now though I have some updates to the app, I make the edits and I even see them in the simulator. When I build and archive the app things seem fine, then I go to the archived project in the organizer window, click the share button and distribute for enterprise, I enter details such as the ipa final url and the app title and then ok & save. Then I upload the app to my server and update any links to point to this new app. The click to install still works properly, but it installs the old version of the app. I've even tried this on a new device. Is there some step I'm mission that tells Xcode some version to build? If so, I don't get is how the simulator shows the update fine, but the archive that is built is not showing the latest code. The app I can find in the simulator dirs is 9.4MB in file size, but the one that is saved after build and archive is only 1.4MB (the update involves a lot of added images), so is the build for archive is not even getting the new files?

if a clean won't work, try completely removing the derived data folder.
the default location is in /Users/you/Library/Developer/Xcode/DerivedData . if you haven't played with the DerivedData location in preferences, this is likely where you'll find the sub-folder containing the cache.
when i encounter a situation similar to the original question (retaining items i've deleted, or similarly missing items i've added or holding onto project icons i've changed), i perform a clean on my project, close it, hit Delete… in the organizer, possibly even remove it from the organizer, possibly even remove from disk and then re-checkout from git if you have it under version control in this way, then re-open the project from scratch.

I figured it out and thought I should post it in case it helped someone else.
I cleaned the project.
Build > Clean - not 100% on what "Clean" is supposed to mean/do, but it allowed the project to build from the current files rather than the old files somehow.

Related

Xcode creates generic archive of iOS app because of malformed/incomplete Info.plist file inside the archive

I am trying to archive and distribute my ios app but out of nowhere it just stopped working. I have deployed my app many times and also had this problem before because xcode somehow creaded some bad xml lines in my project.pbxproj file, but eventually I edited the xml source code and it was ok (app archive and upload/distribution to AppStore). Now xcode is showing my new created archive in "Other items" sections and i cannot upload to AppStore. I opened the archive and I noticed that key elements are missing from the Info.plist file inside:
I looked into other archives (after upload/distribution) and it should look like this:
I tried about 10-11 links on google or stackoverflow, summerized very well here (see accepted answer): Xcode creating generic Xcode archive instead of iOS App Archive?
I tried everything and also cocoapods update to 1.10.0, cleanup cache, reinstall pods, no luck.
My app uses another framework project (developed also by me as described here: https://www.raywenderlich.com/5109-creating-a-framework-for-ios) but I haven't changed that one either. I set Skip install to YES to everything except my app's main TARGET and PROJECT Build settings and checked for private header files. I also distributed another app that uses that exact framework project and everything is ok there.
I checked the new changes compared to last commit and the only modifications (except the source code files) was the build and version number of my app.
In the end, I opened my archive and added the missing entries manually in with an xml editor inside the Info.plist, and restarted xcode (as described at the end of the accepted answer in the link above). After that I was able to distribute my app. The problem is that I do not want this approach because I do not know what is causing this and also what other problems it may cause. Does anyone have any other ideas? It seems a lot of people come across this issue, it has tens of possible causes and it makes me lose hours of work everytime it happends (about once every few months this issue just pops out of nowhere).

XCode won't run my application on a device/simulator anymore

I am kind of stuck with my XCode problem. First of all: I have a project that contains 5 different targets. Now something went wrong (I can't remember changing anything related to project settings).
If I want to run any target on device or simulator the build succeeds but then nothing happens. Neither the app is started in simulator nor on a device. So I checked the Scheme (-> "Edit scheme") and I could not select my app in the Executable menu. I think I can remember that the .app file was selected there before (as it is if i create any new project). Does anyone know why I can't select anything there?
What I am curious about, is the fact that choosing "Other" in the Executable menu brings me to my DerivedData directory that indeed contains the *.app file resulting from the build. That leads me to my next problem.
If I select this *.app file explicitly and try to run the app XCode gives me the error " does not have an architecture that can execute." But I checked my settings many times and I am definitly using $(ARCHS_STANDARD) in every target.
I am a little bit lost here ... does anyone has a hint, what could have messed up my project and how to fix it?
Might not work, but I've found a lot of bugs in xcode which simply require quitting it, and reopening.
You could also try clearing out the DerivedData directory. Do a full clean build (hold down option key when selecting clean build).
And lastly, reset the simulator via the menu iOS Simulator > Reset Content and Settings.
I got this when I changed the name of my App on one development machine and then tried to work on it a few months later on another machine. I fixed it by deleting the old scheme and Autocreating the new scheme. The settings are under Product - Scheme - Manage Schemes.
OK I solved the problem by myself. I was on the right track before. I did compare the project.pbxproj file again using FileMerge. I merged all lines related to an *.app file from the working version into my corrupt project file. After that my project was fixed. The *.app files showed up under the "Product" group in XCode and I could run the application on simulator/devices again. It seems that I forgot something while I was merging the files via copy & paste. ;)
Rather than cleaning out the DerivedData directory from Xcode, have you tried the "old fashioned" way from Finder? Try quitting Xcode, nuking ~/Library/Developer/Xcode/DerivedData/ModuleCache from Finder, and restarting Xcode.

Thoroughly Cleaning Out App Data for Clean Build?

I have never had a problem like this but its clear a thorough clean out of all app data related to my project needs to be done as I am getting a crash related to UICollectionView which I have no removed any reference to in its entirety. I have tested the build on the simulator after resting its contents and it runs without the crash.
For building to my iPhone, I have deleted the app, restarted my iPhone, cleaned the project in Xcode, quit Xcode, restarted my computer and re-built and run. However my iPhone seems to be remembering something from that old build, resulting in this error to still be prevelent.
So how can I truly once and for all (without restoring my bleeding iPhone) clean out any old data related to my Xcode build?
Thanks.
Deleting the app on your phone should be sufficient. Your phone will not "remember" the app, as you suggest it might be. The only thing an app can physically leave behind after being deleted is anything that it put into the Keychain, such as a username/password that was saved there. Other than that, nothing can be left behind after an app deletion (at least not for practical purposes, I'm not trying to claim that iOS zeroes out the bits).
That said, obviously do a clean in Xcode and then delete your derived data. For full instructions on doing a complete clean, see the answer to the following question: How to Empty Caches and Clean All Targets Xcode 4
Have you tried deleting the Derived Data in Organizer? Press Command-Shift-2 and go to the Projects tab. Under your projects you should see a long path to Derived Data. Delete that, restart your computer, and let Xcode reindex your project. Link to a screenshot

Storyboard won't update in simulator

I have a working app in Xcode, however when I try to build and run it the simulator displays an older version of the storyboard I was working on. I had changed some of the design on the storyboard but this does not reflect in the simulator, nothing is updated.
Does anyone have any ideas?
Delete the App on the simulator.
Clean
List item
Build & Run
Use NSLog(#"") in your controller to check code execution.
I just spent at least 6 hours on this. I have a solution, but I also submitted a technical support ticket to apple to try to get more info on the cause and proper solution.
Simply remove the references to your storyboard files and add them back in the same file group.
This seems to include the storyboard files back into the app bundle generated during build(which can be seen in the
DerivedData/APPNAME/Build/Products/Debug-iphonesimultator/APPNAME.app
From here I can see my changes reflected from the storyboards as expected.
PS - Are you using localization at all? I was.
I lost 2 hours to this.
Solution was braindead simple: delete app, turn OFF the iPhone 5S (iOS 7.1.1), and turn it bavk on.
When you turn on localization,
xcode moves storyboard file in localization folder (ex. Base.lproj/name.storyboard). When you build and run project on simulator, xcode copy name.storyboard into "derivedData"/Base.lproj/name.storyboard, but previous, created before localization "derivedData"/name.storyboard still exists. In this case simulator uses the file which can be found easier, i.e simulator uses old file "derivedData"/name.storyboard to operate.
Solution: Just rename the storyboard file, in navigator and in targets/general.
This error happened to me for the first time when I had multiple copies of a project on my computer. For whatever reason, the fact that there were multiple copies were making it look as if the storyboard had not been updated between copies and in some cases the code was not updated. I thought I had forgotten to throw the right copy on my flash drive before going home, but it turned out it's an XCode error.
Delete any multiple copies using the same name, restart XCode and open your most recent copy. Extremely bizarre, but I will probably use BitBucket or GitHub from now on instead of throwing it on a flash drive.
Deleting
~/Library/Developer/Xcode/derivedData/
worked for me!
I just have the same problem after localizationMy solution is clicking Product, Clean build folder. Then it will be fine
The storyboard on the simulator was what it should have been. The storyboard on the device would not update. I had to delete the application from the iPhone and then re-run it on the device in order to get the Storyboard to update on the device. Fortunately for me it was only test data, but I was using Auto-Layout on one view and went back to manual. I think that's what caused the issue for me.
I find that removing and adding storyboard file back doesn't work in my case, also it has side effects like it will automatically add a main nib entry into App's plist file (which subsequently makes the App fails to launch in iPhone simulator).
I don't want to try to delete the application from the simulator since I have many files under the Document directory of the App.
At last I find another way that works well: simply delete the "/Users/$username/Library/Application Support/iPhone Simulator/7.1/Applications/$app/$yourapp.app" file. The files under Documents directory are untouched.
(I have localized my storyboard as well.)
I found this same thing happened with Xcode 6.1.1 if I happened to have copied a project; the new project run in the simulator was actually still reflecting the old, original project.
In my case the problem was with how the default area was set up for derived data (essentially the location where the binary files go for a build). Mine was set to legacy and the simulator was using the wrong project, even after a clean. The solution was to go to Preferences->Locations, press Advanced, and change the location from Legacy to Unique.
I get this too when using localized storyboards - Run in Xcode just refuses to install the latest version of the compiled storyboard. I think it is something to do with the way Run copies changed resources across to the device - it does it differently than other forms of on device app installation.
The quickest way to get past this without deleting the app and losing any data is to:
Generate an Archive build in Xcode
Export this for Adhoc deployment
Double-click on the generated IPA to add it to iTunes
From the device page in iTunes force an update to that app
In order for iTunes to see that you have a new version your app build number will need to be incremented (if you don't do that already), before generating the archive.
I find this method means you don't have to delete an app off the device, you're just forcing it to install the entire install package rather than a diff which is what I think Run is doing.
I'm not sure what causes this, if it is a localized resources bug or what, but this is still a problem in Xcode 7 for me.

How to restore my project wisely

So, it started as a simple test, where I had to delete my app from my iPhone (iOS4.3) just to check how the app behaves on a first run. (I am developing to support down to iOS4.3).
After the deletion, I wasn't able to run the app on my iPhone for some reason. The "Active Scheme" would show iOS Device, although I could manually select my own device from the list, the project wouldn't set my device by default. XCode would drop a message from the top saying:
Could not launch “project1” No such file or directory
(/Users/portal/Library/Developer/Xcode/DerivedData/project1-
cfjhjgezzcapwoadaivpptyywptu/Build/Products/Debug-iphoneos/project1.app/project
I went through this SO post (EDIT: Therefore, restarting XCode, iPhone doing clean project, hard resetting my iPhone) but this didn't change anything, except I can now delete the Derived data in Organizer.
I have a working backup at hand though. Thing is it is a bit outdated as I made many changes to the project. I can run the backed up project, and it seems sane as good.
Now my question is how can I merge the files back into the sane project? The XCode project itself has changed a bit, frameworks were put in as well as some settings.
I tried to simply copy the changed files into the old project, but all I get is a SIGABRT upon the first run. I did a FileMerge look, and saw that for some reason my projectAppDelegate.m is non existant in the PBXBuild section of the .xcodeproj file. which I didn't touch. seems like a mess here.
How can I merge the new project to the old one correctly?

Resources