Xcode 9 not finding assets after using xcode 10 - ios

I downloaded Xcode 10 to test some new features on a project, Now when I reopen the same project on Xcode 9. It seems that Xcode can't find any assets ( images)
This would work fine on Xcode 10 :
let image = UIImage(named: "AsunnyDay")
// this would find the correct image
However, on Xcode 9
let image = UIImage(named: "AsunnyDay")
//image would be nil
I guess it's something related to XCode 10 categorizing the assets as either for dark appearance or light. but I don't understand why would Xcode 9 not find them.

Guys this is how I fixed it.
Open project in Xcode 10 beta
Go to the assets
Select all the images you have
In the inspector, you will have an option to choose the appearance type. Choose Any, Light,Dark
This will create extra placeholders for other images:
Open Project in Xcode 9. the assets will look something like this
Reorder the 1x , 2x , 3x into place.
Delete the extra unassigned placeholders
Done

For me i just reran the project using Xcode 10 and then reverted back to Xcode 9 and it worked for me.

Change your command line tool and clear your derived data first.
Clear your project.
After that force quit Xcode and reopen it.
It solved my assets warning problem.
Hope it will help you.

Related

Xcode 8 storyboard error

Anyone can help me something goes wrong with me, I cant see my storyboard View, subview, imageview. All became white and its show error like on storyboard file
"An internal error occurred. Editing functionality may be limited."
I have open my project in xcode 8 and 8.1 beta latest xcode but both have same issue.
Main thing is that this is happening with all project not just one.
For example i am opening new project that is open in xcode 8 and i cant see that storeyboad file. Old project is working fine which are not open in xocde 8 i can see that project and open in xcode 7.3.1. but if i open that in xcode 8 and convert to xcode 8 compatible and this issue happen.
I have the same problem with Xcode.
I resolved it by disabling SIP (System Integrity Protection):
Press Command-R when start hold til logo and loading status appear
Open terminal
In terminal print: csrutil disable
Restart system
I have also faced this issue and resolve it by only follow these steps:-
Go to Xcode -> Preferences
Select Locations Tab
Click on Derived Data arrow.
Trash Derived Data Folder.
Restart System
Automatic Fixed this issue.
May this help you.
They inserted autolayout a few versions ago, exactly for this foreseeable reason. It's highly discouraged to use storyboards without autolayout, if you want to work with size classes, different devices with different screen resolutions, orientations, ecc.
My suggestion is revert the project to previous commit, reopen it with xcode7, add the needed constraint and reopen with xcode8 (you will still have problems, because of the many bugs of the new storyboard but they are mostly fixable).
Another option to keep working with in xcode8 it is to use a "freeform" simulated size from the Size inspector of the view controller and adapt the sizes to the old viewcontroller dimensions, but you will have to manage compatibility with all devices sizes programmatically, as i hope it is already being done. It doesn't anyway guarantee that everything works
There are some bugs in storyboard of xcode 8 so if you are not using autolayout then you should use xcode 7. now as you said in question that you are getting problem to open storyboard in older xcode (i.e. 7.x) that because once you open project in xcode 8 then it's change some configuration of storyboard which are not compatible with older xcodes.
So now for solution Open your project in xcode 8 -> open storyboard -> File inspector -> Under Interface builder document -> select xcode 7.x instead of latest xcode 8 from Open in
It will show popup something like Saving for Xcode 7.x will close your document and data for Xcode 8.0 features will be removed. Click Save and close the xcode 8 and open project in your older xcode (7.x) and you will able to open storyboard as it was before!!!
You can refer below screenshot,
Hopefully Apple will fix issue related storyboard and in newer version of xcode 8 you will able to switch project without messing up your UI! But right now there should be a workaround as i mentioned above! Try it!!
for me I just make all the views in storyboard size to inferred
^^"

Xcode6 image view + Asset Catalog. Image not showing

iOS Newbie here. After the announcement of Xcode 6 and SWIFT, I decided to give it a try.
Now I am three days into iOS development and found a very strange problem.
Problem: On a empty project with only 1 ImageView control, I can't figure out how to display a PNG image.
Here is what I did:
1) Create a single view project.
2) Create a Asset Catalog, add image set, add PNG image.
3) In storyboard, drag Image View Control into the board.
4) Assign image & background color to Image View
Now hit run and simulator shows only the image background but not the image.
Xcode 6, target iOS7.0, ipad 2 simulator(7.1).
Tested the same procedure in Xcode 5 and the image shows correctly. However, I wish to learn SWIFT + Xcode 6. Using Xcode 5 isn't really a solution.
Here is the project package if you care to test it.
I've had a similar problem, but for an Objective-C project. I found this "problem" listed in the release notes:
"Images from asset catalogs in projects with a minimum deployment target of iOS 7 or OS X 10.9 will be available when running on iOS 8 and OS X 10.10, but not iOS 7 and OS X 10.9."
Which I took to mean that you will not see the images if the target device/simulator is not running iOS 8. I've partially confirmed this by deleting the images from the Images.xcassets and copying them into the project as files, then they get loaded and displayed correctly.
So, I take this mean that I should avoid using the Images asset catalog for iOS 7 targets for this release and just copy the images in as files.

Cannot visualize images inside Xcode

I cannot visualize images in Xcode 5. When I select them on the left panel they don't show, this used to working.
Is it some configuration from coming from Xcode 4 that I am missing?
I tried restarting and creating other project and does not seem to work for me, only code is seen, no images, tried png jpeg etc no do
Check this question, are you perhaps running Xcode on full-screen?
There's a known bug about images missing on Xcode 5:
https://devforums.apple.com/thread/211772?tstart=0
I just tried a new sample project with Xcode 5.1 Developer Preview and it looks like it is not fixed yet.

App Icon not showing up, although I have added in Xcode 5

I have added the icon as shown in the pic below but I am still not seeing the icon in my device or simulator.
This might be an XCode 5 bug that the added icons are not actually included in the app bundle, but you can work around it by going to Build Phases, expand Copy Bundle Resources, then press the "+" sign in the bottom to manually add the icon files to this category.
In addition iOS 5/6 seems to have a bug that the screen doesn't update the app icon even if the icon files are included in the bundle. To work around it (as suggested by josema.vitaminew at App Icon not changing when app version is updated in iOS 5 simulator) you can drag the app icon into a folder, then iOS will update the appearance of it.
If using the Asset Catalog, it might be worth also checking whether Images.xcassets holds all your targets as shown in the below image.
Expanding on adp's answer, if anyone has switched to asset catalogs but they stopped working, and still can't find a solution for Asset Catalog, Images.xcassets, AppIcon or LaunchImage not working, here is a reproduction of the same problem I encountered, and the solution:
I had upgraded to Xcode 6 and opened a project created by an earlier version (4 or 5, not sure) and no matter what I did, AppIcons and LaunchImages absolutely would show up when I ran the app in either iOS Simulator or the device.
I tried Xcode->Product->Clean, Xcode->Window->Organizer->Projects->Derived Data->Delete..., relaunching Xcode and the iOS Simulator, then rebuilding and relaunching the app (failed).
I tried "Reset Contents and Settings..." in iOS Simulator and even deleting ~/Library/Developer/Xcode/DerivedData//Build/Products/Debug-iphoneos and relaunching the app (failed).
I tried archiving the project, hoping that it was just an issue with the iOS Simulator, but the icon in the Organizer-Archives window was still shown as the default white square with lines, confirming that the icon would also not show on a device (a helpful trick to have when no device is handy). (failed).
I tried choosing "Don't use asset catalogs" in Target Settings and creating a new AppIcon-2 and LaunchImage-2 (failed). -this is what cost me at least 2 more hours, because this should have worked and the fact that it didn't revealed the bug in Xcode but I just couldn't see it-
I tried creating a new project from the single view template and compared all of the Info.plist settings (failed).
I tried comparing the new project's Contents.json with mine in Images.xcassets (failed).
I tried dragging the images from the left sidebar Navigator into the AppIcon image wells, hoping that they were just not being copied in a build phase for some reason (failed).
Finally in exasperation at the thought of having to create a new project just to fix the icons, I tried deleting Images.xcassets in the left sidebar Navigator and choosing "Move to Trash", then quitting Xcode and relaunching in case it cached anything. Then when I went to click the App Icons Source popup menu, it only showed "Don't use asset catalogs". I had to select it in order to bring back the "Use Asset Catalog" button. Then I was able to create new AppIcons and LaunchImages, drag images to the wells, build and launch the app in iOS Simulator and finally see icons appear properly.
So the problem appears to be with how Xcode stores Images.xcassets inside the project, and not with target membership, derived data, or anything in Images.xcassets itself. You must remove your assets file and create a fresh one, then drag images to wells by hand again.
It took me 3 hours of research to solve something that should have "just worked" and the entire process of having to manually create individually sized art assets has been so tedious over the years that it has personally cost me countless hours of busywork.
Hopefully this bug workaround helps someone avoid the frustration I went through. I can't help with the friction of manually sizing art assets, but I highly recommend the Icon Slayer website to automate that (of which I have no affiliation).
I have encountered the same problem when the project is switching from xcode5 to xcode6 . The solution is just click on the icon in the image asset,open the right panel , just tick the iOS version option in the panel,add the icons that are blank run it again ... It worked for me
I want to add my solution, where the problem is only isolated to the iPad, my app icon will not show only for iPads. After trying all the solution above, and I looked in the info.plist and found this flag that was not there before the problem with iPads. A new key/value has been added called "CFBundleIcons~ipad" without my knowledge and had nothing as it's value. Removing the key helped resolve my issue.
According to Apple Docs, the icons must be placed on the root level of the app files.
IOS/Xcode will not go under directories to search your image.
Solution is to move the images onto the root of your application i.e. where your source files are, or you can create references in the same way.
Regards
Heider
In my case, I just needed to clean and rebuild my project.
I had the same problem and after a couple of hours finally I could resolved it, copying an old -info.plist from one of my backups project and replace it, this works fine for me.
Regards
My issue ended up being I had used jpg images, rather than pngs.
For me, it was a much simpler solution than the others listed here. I had simply got the assets the wrong size. I had not paid attention to the multipliers that are necessary (e.g. 2x or 3x) and therefore the build was generating a warning for the incorrect asset sizes (which I had ignored). In my case, I corrected the image sizes and voila they appeared in the simulator.
For a macOS/OSX application, you also need to always add a 128 pixel size (and 2x), you can not only use a 512 pixel size and expect it to size down.
If your app icon has any transparency then it won't work. Check it!
I had all the images in the relevant folders and when I right clicked on the empty icon image in Images.xcassets/AppIcon and chose show in finder it would find the image correctly and show it, but for whatever reason it wasn't adding correctly to the project.
After trying a lot of different things above I simply dragged the images from finder into the AppIcon area and it worked.
If you are using cocoapods be sure to check this answer from a related question. After many lost hours, this is what fixed it for me.
https://stackoverflow.com/a/46349476/1343140
Xcode 9.3:
Open your project and add AppIcon images.
Click on general, go to "App Icon and Launch Image"
Click "App Icon resource" and add AppIcon (In my case it added AppIcon-1, so you can use that on rename that and do above step again).
In my case, I updated Build Rules > Using > to "Asset Catalog Compiler"
instead of any custom script and it worked for me.
I had this issue. Following the steps everyone provided did not help. However, it was because of my own ignorance. I had an issue with duplicate resources being created and one of the suggestions was to remove items from copy bundle resources. Well, it never mentioned that the asset folder was required to be in there so I deleted it. After fighting with this issue for 5 hours and recalling that it use to be in copy bundle resources I added it back and the app Icons worked.
Xcode copy bundle with appropriate file included.
make sure you create your appicons with an image 1024x1024
make sure you set 'app icon source' (project > general > App Icons and launch images) to the appropriate icon folder.
make sure you have not deleted the copy bundle resource for said app icon folder like i did.
cocoapods has a forum for a specific issue if all else fails.
Hope this helps.

Not able to see localized images in iPhone simulator

I have an existing working iPhone project inside XCode 4.2. I localized an image (which is used on a button) and I always see the old version of it inside the iPhone simulator. Where does it find that old version?
What I've done:
Window -> Organizer -> Project -> Delete Derived Data
Product -> Clean
Inside the IPhone simulator, I tried resetting it.
I tried deleting the project and recreating it (from SVN)
I deleted everything in Library->Developer->Xcode, Library->Delveoper->Application Support->iPhone simulator, Library->Developer->Application->Interface Builder 3.0
And I still see the old version... Is it compiled somewhere inside the interface builder with the button or something like that? Weird... really weird.
Note: I'm able to localize an image button if I add a new image, but using old existing image is always showing me the old version.
Solution :
My project contained images like ImageName#2x.png (for IPad I guess).
By also localizing those + clean + build + reset IPhone Sim settings, it worked. Go figure.
Also, when I add another language for the #2x images, I have to manually add the image in the other xx.lproj (where XX is the language code) with the finder because somehow XCode doesn't it.
Delete the App in iPhone Simulator (same way you would delete it on real iPhone) and try it again.
I have encountered a similar problem to this where the XIB file would not accept modifications. I eventually fixed by renaming the XIB file and then changes were accepted. Worth a try in your case I think.

Resources