Reinstall when building and running in xcode - ios

I am building an iOS app and running it on a connected device. During debugging, additional config files are present in the app. However, if I delete those config files from Xcode and then do a build and run, they are still present on the device (these are lua files that we write our game in). How can I force Xcode to uninstall the previous version of the app, i.e. do a complete clean build when installing? Cleaning the project and targets and deleting Derived Data seems to have no effect.

I strongly assume that you can't. Installing the app on the device copies files to the device, but does not delete files already present on the device.
(I had a similar problem when I converted a nib-based view controller to a programmatically created view controller. The nib file was still in the app bundle, leading to strange error messages.)
The only way to remove the entire bundle is to delete the app on the device.

Related

Xcode 13.3 Not Linking Storyboards

I have a project that builds and runs with no issues when using Xcode 13.0. However, if I close 13.0, and try to then build and run the project using Xcode 13.3, the app will build, but then crash immediately on launch with the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Main' in bundle NSBundle
I'm making no changes in the project at all - the only change being the version of Xcode used to build the app. When comparing the build output between the two versions of Xcode, I have noticed that 13.3 is skipping the "Link Storyboards" step.
A few things that I've tried include:
Removing the storyboard file from the .xcodeproj, and re-adding it.
Removing all localization from the project, thinking it may be related to that. I then tried re-enabling localization.
Creating a brand-new storyboard using the File > New> File… menu. Even the new .storyboard files are not linked or added to the project.
Removing and then re-adding the .storyboard files to the Copy Bundle Resources build phase.
Bumped the minimum deployment target from iOS 13.0 to 14.0
Cloned my source code from Git to a new location and built from there.
Product > Clean Build Folder and manually deleted the derived data folder locations more times than I can count. I'm using the default Derived Data location. (~/Library/Developer/Xcode/DerivedData)
I've been able to verify that the storyboard files are not being included in the finished app by inspecting the .app bundle after the build succeeds. All other resources I've been copying to the app are there, but the storyboards are not.
Has anyone else seen this issue, and if so, resolved it? I've been stumped for a few days now, and so far, the only thing that's worked has been rolling back to Xcode 13.0.
Fixed it. Turns out that a few years ago, a User-Defined build setting for CONFIGURATION_TEMP_DIR had been defined in our project. Removing this setting, and falling back to the default value got our project running again with no issues. I'm not sure why this setting had been defined originally, but apparently Xcode 13.3 just doesn't like it anymore.
This line also affected another project of ours, that doesn't use storyboards, but does have an Apple Watch app. In that case, the crash was similar, with the error stating that an Interface.plist file could not be found.
Apple's (archived) doc on the setting.

Why would a Unity3D app [exported to to an Xcode project] fail because ip_unity_plugin.bundle has "unsealed contents present in the bundle root"?

I am a Swift developer submitting an app made by a Unity3D developer colleague which is destined for the App Store. The Xcode project has this file in it:
Frameworks/Plugins/x86_64/ip_unity_plugin.bundle
...which I presume is required in order to run Unity within an iPhone app (yes, no?)
When validating the latest archive of the build I get this warning:
Code signing "ip_unity_plugin.bundle" failed.
View distribution logs for more information.
The logs state that:
.../myClients.app/ip_unity_plugin.bundle: unsealed contents present in the bundle root
Which has me like 🤷🏽‍♀️
Any ideas anyone?
Thank you for reading.
That bundle is actually the instant preview library for Google Daydream.
If you're building for release it's safe to delete it from the Assets/Plugins directory of Unity.
Alternatively you can mark the bundle to not be compiled by changing it's metadata in the inspector. You might also find that this problem goes away if you update to a newer version of instance preview.

Xcode 8 app runs on Simulator but doesn't display

I'm using the release version of xCode 8 and am trying to run my app on the simulators. They are all the iOS 10 simulators.
No matter which simulator I use, when I run the app the app icon shows up in the simulator but then that's it. The app never displays in the simulator. I only see the app icons of the iOS home screen.
I put some break points in my initial view controller at the viewDidLoad, viewWillAppear, and viewDidAppear methods. All of them triggered. So as far as my app is concerned, it is displaying on the device. I also get all the normal log output and networking calls happening just fine. It even shows the popups for permission to access the calendar and notifications. But my app is not brought to the foreground.
If I then click on the app icon in the simulator, my app runs normally. But it should be automatic when I hit run from xCode.
When I run my app on an iOS 10 device I get the same behaviour as all three of those view methods are called. However I don't get any of my normal log output. In fact I don't get any log output. However the app was already installed from when the device was on iOS 9.x. Not sure if that is a factor. But aside from the simulator issues, this is the bigger issue.
I've tried cleaning the build, deleting the app, I even tracked down the derived data folder and deleted that from the simulator. None worked. I also updated all my cocoa pods I have installed too.
Any one else experienced this?
That sounds weird but I read a lot of threads on the Apple Developer Forums on the same problem during the different Xcode 8 beta version, try these steps:
reset the simulator using the menu "iOS Simulator" -> "Reset Content and Settings..."
remove your 'xcuserdata' directory inside your .xcodeproj directory
do a clean build folder (hold down option key when selecting clean)
reboot your Mac
If these steps don't solve anything you can try this solution:
Copy-paste Xcode-beta.app from Applications folder to somewhere else, e.g. - Documents folder.
Delete Xcode-beta.app from Applications folder.
Move Xcode-beta.app from Documents to Applications folder again.
originally posted here, obviously using your Xcode.app instead of Xcode-beta.app.

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.

Xcode Build and Archive for Enterprise Distribution builds old archive

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.

Resources