Renamed project failing - objective-c

I have taken a copy of an existing project (Door), with the expectation of using some of the core features for a supervisor application (Mgmt).
I have renamed the project from Door to Mgmt.
I have visited every visible file and changed references to the old application name.
I have done a global search and replace for the old app name.
I have also opened project.pbxproj and found over 10 references to the old project name and changed them. I have also edited xcschemes .xcscheme file name and the cxschememanagement.plist file. As I wish to use push, I have a new certificate for the new app
Everything appears fine, however.......
When I run the application it fails because it cannot find the view controller under the old applications name. (DoorViewController). For the life of me, I cannot see where this is referenced from. the error message is shown below....
[Switching to process 7171 thread 0x1c03]
Re-enabling shared library breakpoint 1
2011-11-30 12:18:17.128 mgmt[9706:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </var/mobile/Applications/EE73FFD1-5392-41F6-A8CB-706D042EF134/mgmt.app> (loaded)' with name 'DoorViewController''
Obviously there is one more thing missing, however it is not something I can see. Any suggestions?

I wonder if you tried this:
Open MainWindow.xib
On left column, under objects:
Do you see "Door View Controller"?
What is its class as per the identity inspector? (alt command 3)
If it's still DoorViewController, change it to the new one.
If this doesn't work, delete "Door View Controller", drag & drop a new one from the library and then change its identity.

./mgmt.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate and buried in the mainwindow.xib
<object class="IBUIViewController" id="578626022">
<string key="IBUINibName">DoorViewController</string>
Manually edited the xib file using a text editor and deleted the xcuserstate file got the app started. I am surprised that the IBUIViewController setting was not visible with a global search, nor within IB, however.......
Thanks sanjay.

Related

How a macOS document-based app start itself?

I am learning the document-based app architecture of macOS app development, but am confused about it.
I created a document-based app in Xcode. The app template created a simple document-based app. It can run, and will create a new document automatically when it is run.
My question is: How does this app start the document architecture? I suppose that there should be some code like the following:
NSDocumentController *docController;
docController = [NSDocumentController sharedDocumentController];
[docController newDocument:self];
But I can't find any such code in the created app. The - (void)applicationDidFinishLaunching: method in the app delegate is empty. Also, there is not any NSDocumentController object in the main nib file.
So, how does this app know that it should use the document architecture, initialize a NSDocumentController, and then create a new document?
how does this app know that it should use the document architecture, initialize a NSDocumentController, and then create a new document?
I’m unclear about the inner workings of Xcode, but it appears that in the app’s info.plist CocoaNSDocumentClass has to be set to Document and Role has to be set to Editor (or Viewer, None, or Shell) in order for the document to be created. In your demo try deleting either one or both of these lines in the plist and see if the app still works. Both settings are located on the second level of Document types. In my experience, deleting either of these lines breaks the app and restoring the correct setting fixes it. In a programmatically created document-based app (no nib) and compiling with Terminal the following errors are generated when I go inside the bundle and run the executable after deleting one or the other info.plist settings mentioned above.
2020-02-11 19:31:48.294 nsdoc_demo[1606:658926] NSDocumentController Info.plist warning: The values of CFBundleTypeRole entries must be 'Editor', 'Viewer', 'None', or 'Shell'.
2020-02-11 19:38:46.355 nsdoc_demo[1748:680819] -[NSWindowController loadWindow]: failed to load window nib file 'Document'.
Xcode (with Document.xib) generates the following error when CocoaNSDocumentClass is not set:
2020-02-11 16:22:03.022602-0600 docExpt[1166:428702] The DocumentType type doesn't map to any NSDocumentClass.
In my experience the source code can be ok, but if the info.plist is not set correctly a document-based app won’t work as expected.

Xcode 8 Beta #import unexpected behavior

So I'm just coming back to programming for macOS after a few years hiatus, and have discovered the #import syntax. I created a sample program to test it out, but it's not working as my googling seems to suggest that it should.
Test project setup:
Open Xcode
File>New>Project...
Select the Cocoa Application template for macOS. Click Next
Name the project "ModuleTest", add organization name and organization Identifier. Select Objective-C as the language, check Use Storyboards, make sure "Create Document-Based Application", "Use Core Data", "Include Unit Tests" and "Include UI Tests" are all unchecked. Click Next and choose a save location. Don't create Git repository, and don't add to any project or workspace. Click Create.
In the Navigator, click on Main.storyboard.
From the Object Library, drag an AVKit Player View object onto the View of the View Controller Scene in the Storyboard.
Now at this point, we can see the symptom, which is that if you build the project, a window will pop open, but the player is missing from it, and the xcode output window shows a message such as
2016-08-16 09:07:46.465 ModuleTest[19778:4097187] Failed to set
(contentViewController) user defined inspected property on (NSWindow):
*** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (AVPlayerView) for key (NSDestination); the class may be defined
in source code or a library that is not linked
This error occurs regardless of whether I put an #import AVKit; statement into AppDelegate.h, AppDelegate.m, ViewController.h, ViewController.m, or main.m. However, simply linking the AVKit.framework in the "Link Binary With Libraries" section of the project's Build Phases, solves the issue, no #import needed anywhere.
So what's going on? I thought #import was supposed to eliminate the need to manually link frameworks? Am I going through the process incorrectly? Is this happening because I'm using storyboards? Any ideas?
The problem is that there is no actual code that references the AVPlayerView. Try adding a single line of code that uses AVPlayerView and you'll notice that the error is gone.

Icons, Asset Catalog and Info.plist confusion

I have an app that started life for iOS 5 and has been updated ever since. For iOS 7 I have switched over to using an Asset Catalog for all the resources, which is nice and appears to work well. However, when I try to submit to Apple I get validation errors:
Invalid Image Path - No image found at the path referenced under key 'CFBundleIconFiles': 'Icon#2x.png'
I get the same error for the other icons, too. These icons do appear in the Asset Catalog and the names -- right down to the case -- match exactly as far as I can tell. The Asset Catalog is in the "Copy Bundle Resources" and all the resources appear in the right place when I run the app on both my iPhone and iPad (in iOS 7) and in the Simulator for iOS 6.
I have updated the app to use the minimum deployment target of iOS 6.
So, how do I successfully submit my update to Apple? Do I need the references in the Info.plist? Are there any other settings that I should check? Is the warning spurious and something that I should ignore (after raising a Radar)?
When an asset catalog is compiled for iOS 6 and lower, the images are put in the root of the app bundle, as if you were just copying them the old way. When this happens, Apple names the images according to the asset name, rather than the filename, which means we can still use +[UIImage imageNamed:] to get the assets on iOS 6 and lower.
This is true for the App Icon asset, when we have the following icons set in our asset catalog:
They become compiled like so:
As iOS 6 is still iOS 6, these files must be referenced in the Info.plist, otherwise the existing system wouldn't work. Looking in the compiled Info.plist for this test app, you see that Xcode has added CFBundleIconFiles for us and so we don't need to.
I have uploaded the test project I used to github.com/danielctull-tests/AssetTest.
Okay, so here is what I ended up doing. I'm not 100% sure it's correct but I thought that it was worth sharing.
I removed CFBundleIconFile, which I don't think is used in iOS 6 and above
I used the asset name rather than the icon filename in CFBundleIconFiles
I'm not clear what the proper names are so, for the sake of clarity: by icon filename I mean the name visible in the Attribute Inspector of the Asset Catalog when the icon is selected; and by asset name I mean AppIcon, which refers to seven actual icons in my case.
This both passes Apple's validation step and appears to look okay. I don't currently have an iOS 6 device but it displays correctly in the Simulator.
I had also a lot of Problems on this matter - I was constantly getting the error with the missing CFBundleIconName and that my Icons where not found. So here is my story, maybe it will be of help for somebody. By the way, I am using Visual Studio with Xamarin.
Add an Asset Catalogue to your Project with AppIcons (the actual name of the asset is not important but just that it is for the application icons). Add all of the necessary icon sizes. For the 'App Store' icon I have added an icon without a # in the name as someone in the forums suggested, but I am not sure, if it is 100% necessary. For generating the different icon sizes there are a lot of Websites and tools that can do that for you and you just need to provide the 1024x1024 one. They will generate the rest.
In the Info.plist under 'Visual Assets' and then 'App Icons' set the source to the asset that you have just created.
Now check your Info.plist. Do not open it with an external Editor, because all of your changes will be overwritten once you build your project. Do the following - right mouse click on the Info.plist in the Solution Explorer then select Open With -> Generic PList Editor.
Check that you have the following entries:
-Property = CFBundleIconName, Type = String. Value = Assets.xcassets/AppIcons.appiconset
-Property = XSAppIconAssets, Type = String. Value = Assets.xcassets/AppIcons.appiconset
Note that Visual Studio automatically adds, when it adds something altogether, 'Resources/Assets.xcassets/AppIcons.appiconset' as the Value. But in my case the Asset Catalog was created outside of the Resources folder and therefore, my icons where not found. So, check where your assets folder was created.
CFBundleIconFiles was not needed, because Apple uses the Asset Catalog instead now.
I hope that I was of some help :)

Objective C two errors pngcrush

I don't have any problems with my code, but I think there are some settings wrong.
On the simulator, my application works great, but when I want to put it on my device I get the following error:
**pngcrush caught libpng error**
Could not find file: /Users/USER/Library/Developer/Xcode/DerivedData/PROJ-afhreiqghfsdvwbrdbfrawtkuser/Build/Products/Debug-iphoneos/PROJ.app/Email.png
This is the first error I get, and it only happens with Mail.png and Emailp.png. All other pics are okay.
The second error I get is not really an error. But when I view the .app folder which is on my device, I have lots of files which shouldn't be in there:
AppDelegate.d
Appdelegate.dia
AppDelegate.h
AppDelegate.o
Proj-Prefix.pch
I have these for every header. How can I change it so it won't all land in my bundle?
I'm gessing that Email.png has not been linked to your target when you imported the image, thus it has not been moved to your device.
You can check if you select the blue area with the project's name in the navigator window and go to Build Phases -> Copy Boundle Resources and add it with the little plus sign at the bottom if it's not in the list.
My other guess is that the actual filename is email.png and while the simulator is case-insensitive, the device is not. That can be why it cannot find it.
EDIT:
2, I'm quite certain XCode generates those files at build time and somehow they got put in the .app package. Can you tell us what's inside those files?

iPhone HelpViewController undeclared (first use in this function)

I have a strange XCode project compilation issue. I have a subclass of UIViewController called HelpViewController that is created the same way as several other similar classes I have for adding to a UITabBarController.
When compiling I get the error; HelpViewController undeclared (first use in this function) when I try and create an instance to add to the tab bar.
If I rename the class to GuideViewController (*.h, *.m, *.xib filenames; all occurances in .h and .m; #import "*.h" and * alloc) the compilation succeeds but if I rename it back to HelpViewController it fails again with the same error.
I looked for HelpViewController in the dev docs but couldn't find anything to suggest it is a reserved name. Why might this particular class name be causing the error?
Sounds a lot like a #import is missing or incorrect. But it looks like you've covered that. Make sure you do a clean of the project (or delete the build directory), it could be old artifacts getting in the way.
Turns out I'd got my XCode project in a mess. When I deleted my *ViewController class at some point I had selected to only delete the references and not move the files to the trash as well. This removed the reference for the File Owner's outlet for view which could be seen as a warning in Interface Builder. The lack of a correct view reference prevented the ViewController being used (A View Controller is also a View). Since the files were still present in the file system (but not shown in the XCode project) they compiled badly. I deleted the files and selected to move them to the trash and then recreated them from scratch.