Issue with updating app and UITextView - ios

I have an app that has a UITextView in it. The user presses a button and the action changes the text on the UITextView. The app is functional and in the AppStore right now, it was built using iOS 4.2.
With out changing anything with the code. When testing a new version of the app building it for iOS 6. the app will not show any text in the UITextView when installed in the simulator or new device. The UITextView is blank...but when using an NSLog it writes to the log that there is text in the UITextView.
I have noticed that if the device had the previous version of the app, which is in the AppStore. And I compile the new version of the app onto that device, the app functions like it is suppose to and the UITextView is updated when the button is pressed.
in my .h file
#import <UIKit/UIKit.h>
#interface TimeSheetViewController : UIViewController <UITextViewDelegate>
{
}
#property(nonatomic, retain) IBOutlet UITextView *logTextView;
in my .m file
#synthesize logTextView;
-(IBAction)buttonAction
{
logTextView.text = [NSString stringWithFormat:#"%# \n New words go here...", logTextView.text];
NSLog(#"%#", logTextView.text);
}
Even trying to have text set from the UITextView from the Interface Builder fails to show up unless the app is pre-existing when the new version is compiled onto the device

Try using the setText method of the textview.
[logTextView setText:#" New words go here..."];
If it doesnt work, check if you have set the textView as not editable ie user interaction disabled or anything like that in xib file if you have one.

This is only a half answer or more precisely not a solution... according to
Technical Note TN2285: Testing iOS App Updates
Warning: Do not use Xcode to install or run updates to your app for quality assurance testing.
To make the development cycle faster, Xcode only pushes changed files
into the apps it runs, and does not delete files from existing
app-bundles. This makes builds significantly faster. But it means that
using Xcode to install an app over an older old build can make a
"frankenbuild" with legacy files it wouldn't otherwise have. This can
cause problems during testing and mask bugs.
Additionally, running with Xcode will mask "watchdog crashes" that can
happen if an upgrade takes too long to launch.
I believe what is going on is that, some file is being left behind from the AppStore version when I compile my new version from Xcode onto it....making it work like it is suppose to.
But since the file is missing in the new version compiled from Xcode, any new installs of the app from the unreleased future version of the app are missing that particular file and are not functioning correctly.
I'm not quite sure what the file is, but I intend to look into it more or build a new project and copy and paste the old code into it.
Testing Your App on Many Devices and iOS Versions

I was using the following code in the viewDidLoad method:
int fontSizeA = [(sizeLabel.text)intValue];
logTextView2.font=[UIFont fontWithName:#"Arial" size:fontSizeA];
The problem I ran into was that the sizeLabel become disconnected in the Interface Builder and the viewDidLoad method was really using this code...
int fontSizeA = [(#"sizeLabel")intValue];
logTextView2.font=[UIFont fontWithName:#"Arial" size:fontSizeA];
which gave the appearance that there was no text in the UITextView.

Related

iOS app exception on app start (doesn't crash the app) [duplicate]

I am using Xcode 6 (GM, I didn't download betas), and I am developing apps for iOS 7+. For all my projects, I just opened the same projects I used to work on in Xcode 5.
In the Breakpoint navigator, I have the All Exceptions breakpoint on. It is set to Break: On Throw. Now, each time I run my app (whether on a device or in simulator), it stops execution on the line return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); in the main() function.
If I press Play to continue program execution twice, the program runs fine. So this doesn't prevent me from working, but it is annoying to have to manually play the execution each time and reset my editors.
I like the behaviors I have set up in Xcode (taking the current editor to where the execution has paused), and having that All Exceptions breakpoint is important IMO. (So I don't want to change those)
By running the same code, with the same environnements, for an iOS 7 target (again, device or simulator), the exception is not thrown.
Any clue what could cause this strange behavior?
As stated in the comments, you should turn off catching the C++ exceptions by editing your All Exceptions breakpoint.
In order to do that, right click on your breakpoint and change Exception from All to Objective-C:
Exceptions in C++ code are part of normal app functionality. However, exception breakpoint is not catching unhandled but every raised exceptions, even when they're handled correctly later on, hence the stop in execution.
TLDR; In my case the cause of problem was missing fonts.
I also had this problem. While #Johnnywho is correct that leaving Exception Breakpoint for Objective-C only, stops the unwanted behaviour, it still does not explain what is the real cause, why does it run without exception on iOS7 and why does this happen only on some projects.
That's why I went on and dissected one of my projects in which I had this problem, until the point where I was able I found the cause. I suppose that there could be more than one cause for this behaviour, but in my case that was missing custom fonts.
Quick way to test it:
Start a new single view project
Enable breakpoint on all exceptions, including C++ (Breakpoints / + / Add Exception Breakpoint)
Drag into the project some custom font (allow copying and check the target to add it to)
Add a label to the view in the main view controller
Choose the custom font for your label (on Xcode 6+ it should show in the font picker as soon as you drag it into the project).
Run the app and confirm that you see the label in your custom font (it seems that we don't need to add the font file name in Info.plist for the key "Fonts provided by application" anymore, if the custom font has been used in a storyboard of xib of the app).
Now remove the custom font from your project (either by unticking target relationship or by removing it in target settings / Build Phases / Copy Bundle Resources)
Delete the app from your device or sim (to delete the font file from the app bundle)
Product / Clean
Run the app again (now the label still has the reference to the custom font but the app does not have the file for it). You should notice the mysterious exception if you run on iOS8.
Run the app on device with iOS7 or sim with iOS7 (you'll need to change the iOS Deployment Target to iOS7 for that). Although the label won't show the custom font, there won't be an exception.
Add the font file back to the target and the breakpoint does not stop on run anymore.
So my conclusion is that on iOS8 the missing fonts cause C++ exception while on iOS7 they don't, hence the breakpoint trigger.
Similar exception (and breakpoint trigger) can also be caused by incorrectly written font file name in Info.plist file under the key "Fonts provided by application".
Just summarized previous answers which helped me to fix it.
Problem: When you add custom font and then apparently delete (replace) it, somewhere in project is still his reference and the breakpoint stops several times at main C++ lib breakpoint stops in iOS 8.
Solutions
1) Find in project and delete (replace) all references to those fonts. Might in some nibs, submodules, etc…
2) If you can’t fix everywhere (e. x. read-only libs use them) or problem still exists after solution 1 , add those old fonts back to project
3) Ignore it - It is C++ lib so change breakpoint exception from “All" to "Objective-C" only
Xcode 9, sometimes there are exceptions that are thrown but iOS is catching it gracefully. This will help
source
for my case, it was a user-defined attribute in nib
I had a same issue, the issue was i have added some interface files from other project which has different font in it. Just find them and remove.

Xcode crash on opening storyboard

I am developing an app for iOS with Xamarin. Lately, I haven't been able to access my storyboard file in Xcode or compile my app anymore because Xcode crashes right away when opening the .storyboard file.
The error message is the following:
ASSERTION FAILURE <br>
Details: Creating an out of band arbitration unit with a view (<IBUITableViewCell: 0x7fa88d13a5d0>) as the root under another view (<IBUITableView: 0x7fa88cf000e0>) is not yet implemented.<br>The view would need to be in two arbitration units, the one above for positioning constraints, and the root of the one below for sizing constraints. <br>But then that means that subviews cannot have constraints that affect the size of the view, so the view must have ibExternalTranslatesAutoresizingMaskIntoConstraints set to YES.
<br>Object: <IBUITableViewCell: 0x7fa88d13a5d0>
<br>Method: -ibArbitrationUnitWasCreatedWithReceiverAsRootUnderParent:
I tried rebasing my storyboard to the last version that worked (the one the app was submitted to the app store) and weirdly, even that version didn't work.
My plan was to manually remove and every view controller and add them one by one to figure out where the error is.
However I don't understand why XCode crashes when opening the storyboard and not just shows me exactly where the error in my xml is.
So if anyone has encountered this problem before and has a better way to fix it than to manually do it, I would really appreciate any help.
ibExternalTranslatesAutoresizingMaskIntoConstraints needs to be YES
Sounds like the Storyboard was created with an older Xamarin.iOS that introduce this issue.
The fastest solution is to open the storyboard in vi (or Xcode / View As Source, or another text editor of your choice, and replace all translatesAutoresizingMaskIntoConstraints="NO" with "".
Save the file, re-open it in the Storyboard editor and fix your contraints.

UITextFields not responding in iOS 9.0 migrated project

I'm migrating a project from iOS 7.0/8.0 to 8.0/9.0 and I'm facing this problem :
Any UITextField I have on my UI freezes the app but doesn't trigger a crash.
I've tried to remove delegates, even IBOutlets. I've created a new empty controller, with just one UITextField, that my appDelegate shows instead of any other, but nothing works...
Is anyone facing the same issue ?
Damn it, it solved itself...
My only move before that was creating a Watch Extension, which I deleted by rebasing my project on a previous commit.
Anyway it was truly stranged, I also had a crash on UIAlertController that I used nowhere in my app...
Thanks anyway !

Storyboard crashes Xcode when opened

Whenever I attempt to open up my storyboard, Xcode crashes with the following error report
The funny thing is, the app works fine in the simulator and builds without errors. What is causing this crash? I see two possible crashes:
Exception reason: UITableView dataSource is not set
, but that shouldn't make the storyboard crash right?
Details: Failed to compute auto layout status IBLayoutConstraint, IBUIButton, IBUIDatePicker, IBUITextField, IBUIView, IBUIViewController, and IBUIViewControllerAutolayoutGuide.
Which doesn't give much information at all.
I have been using a storyboard with Xcode 5 for some time, so the question does not appear to be related to moving from Xcode 4 to 5. I can open the storyboard as XML and I can open my iPhone storyboard just fine.
If you are using git, I would recommend reverting to a time before this problem started.
If you are not using git, and you are absolutely sure you did not edit the xml for the storyboard then I would say:
1)find the storyboard file using the finder.
2)copy it to your desktop.
3)go back to Xcode and delete the storyboard from your project, select "move to trash". 4)re-import the storyboard file into your project.
Ive had similar problems with Xcode 5 and either reverting using git or the steps above usually get me back up and running.
Exception reason: UITableView dataSource is not set
Details: Failed to compute auto layout status IBLayoutConstraint, IBUIButton, IBUIDatePicker, IBUITextField, IBUIView, IBUIViewController, and IBUIViewControllerAutolayoutGuide.
The errors described above lead me to think that one if not all viewcontroller(s) for the items listed above lost their connectivity to viewcontroller.h / viewcontroller.m files. I would make sure you have everything wired up correctly, and you can check this by making sure the items in your viewcontroller have a circle in the gutter (next to the line numbers) that is filled in (solid) if the circle is not filled in then it means your items are not wired up to your viewcontroller. I would post a picture of your .h / .m file of your viewcontroller so we can further investigate.
I ended up copying each view controller scene (in XML) into a new storyboard. Some view controllers could not be copied without the storyboard crashing so I had to recreate about 4 of them, but by and large I got the majority of my work back.
What you need to do is reopen the project again in Xcode 5 and then go to the storyboard. Then at the right side choose for "Identity and type" and then set "opens in" to Xcode 4.6 to be able to open it in Xcode 4.6. And disable auto layout, somehow when you open it in xcode 5 it asks you to update it, I think you did that without a thought, happened to me as well :)

UIBarButtonItem appears in iPad simulator but not in actual app

I've got a puzzle. I'm a newbie and recently got my first app approved. However, I just noticed that a question mark icon that appears fine when I run the app in Xcode's iPad simulator is invisible for some reason in the actual app store app. The question mark is a UIBarButton item in the toolbar of the starting view controller in the app. The curious thing is the UIBarButton is obviously present in the actual app store app because when I click on that area of the screen, the information screen that it is supposed to show does indeed appear. But for some reason the button itself seems to be invisible in the app store app (but, again, the very same UIBarButton IS visible when I run my program on Xcode's iPad simulator).
One more piece of info: When I first start up the app downloaded from the app store on my iPad, the blue question mark actually does appear briefly in the toolbar of the app for about 1/4 second but then disappears.
Here below is the code segment which is in the viewDidLoad method of the starting view controller. The questionMarkBarButton property is a UIBarButtonItem which brings up an information screen when clicked.
[self.questionMarkBarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:#"Helvetica-Bold" size:26.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
Any ideas what could be causing this strange behavior? I'm at a loss how to proceed because apparently I can't debug this using Xcode's iPad simulators since they show that the question mark UIBarButtonItem is visible and behaves as expected.
Additonal Info:
Here's how the UIBarButtonItem is declared in the .h file of the view controller:
#property (weak, nonatomic) IBOutlet UIBarButtonItem *questionMarkBarButton;
It appears to be hooked up correctly, as evidenced by the fact that the button works (although it is invisible in the app downloaded from the App store).
Also, here is a picture of this part of the storyboard:
Finally here is what the starting screen looks like on the Xcode simulator. You can see the question mark button in the toolbar here, but for some reason it is invisible (although present) in the version of the app downloaded from the app store:
More info:
In examining my app again, I see that there later on in the app I again use a UIBarButtonItem to present an information screen, and it appears and works as it should. The most apparent difference between how I coded these UIBarButtonItems is that for this problematic "question mark" UIBarButtonItem I tried to make the question mark bolder and more prominent by putting the following line of code in the viewDidLoad method of the view controller, whereas I did not use the following line of code with the UIBarButtonItem that appears later in the app (i.e., I let the text in this other UIBarButtonItem just appear in its plain, default form).
[self.questionMarkBarButton setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont fontWithName:#"Helvetica-Bold" size:26.0], UITextAttributeFont,nil] forState:UIControlStateNormal];
So unless anyone has any better idea, I guess I'll just submit an update for my app in which I remove this line of code and let the question mark appear in its plain, default style rather then an enlarged, bold style.
Final edit (12/7/13)
I removed the code line above and resubmitted my app to the App Store. The app now works properly, with the "?" information button now showing. The bottom line appears to be that the setTitleTextAttributes method does not currently appear to be a good, reliable method to use with UIBarButtonItem objects. It will appear to work fine in the Xcode simulator, and even in testing with your own iPhone and iPods, but for some reason it will not work when people download the app from the Apple store.
Objective c is case sensitive, Make sure your bar button variable that you create and assign are same . hope this may help you. as this is one of the issue when things go right for simulator instead of device.

Resources