Xcode Deployment Info and icons using CMake - ios

I've tried looking for info on how to set these (in red) using CMake but have had no luck so far:
1st red box issue:
First of all, even though the device seems like it's been set to 'Universal' correctly, the value isn't being interpreted correctly by Xcode. When I set it to 'Universal' manually using the dropdown, it gives a tab each for iPhone and iPad. Furthermore, I know it's not being interpreted correctly as the app does not function correctly (in my case, neither the launch image nor the app itself run full screen).
I don't think setting orientation programmatically is an option for me since I need the launch image in the correct orientation as well.
So can't do something like this:
How do I programmatically set device orientation in iOS7?
2nd red box issue:
I use an asset file for all my icons, so at the moment I'm having to build using CMake and then press 'Use Asset Catalog' each time.
I found this but doesn't seem very useful:
http://cmake.3232098.n2.nabble.com/Icon-and-Launch-image-support-for-iOS-apps-td7590970.html

Regarding the "1st box issue", I've found that the approach taken by this demo project works really well.
https://github.com/forexample/testapp/blob/master/CMakeLists.txt
They use a templated Info.plist to inject the bundle identifier, etc, during configure. The nice part is then you can modify the orientations in the plist.in file, and then these get translated cleanly to the Info.plist once you open the project.

Regarding the 2nd red box issue, i found that the attribute I needed to set was XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME
For example:
set_target_properties(${TARGET} PROPERTIES
XCODE_ATTRIBUTE_ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
For Launch Images I got it to work by setting it in the plist.in file under UILaunchStoryboardName as described in yano's previous answer.

Related

Runtime warning: Could not load the image "imageName" referenced from a nib in the bundle with identifier "bundleId" [duplicate]

when I load my application it shows a warning message that
"Could not load the "" image referenced from a nib in the bundle with
identifier "
I searched and confirmed all my images. But it still shows that warning.
Select your image(s) in Project Navigator.
Open the File Inspector.
Make sure you have the target selected.
I had the same issue when I Refactor to Storyboard. Apparently the Asset catalog does not transfer the image reference. To fix, see below:
You would notice that your ImageViews is empty from reference.
1 - Click on the ImageView
2 Go to the Utilities bar where you would see you asset image is unknown
3 - Change it back to you image asset
This should fix your error. Hope this helps!
There might be many reasons of this error. To fix this issue you can just follow below given step:
Go to product menu of the Xcode, select clean.
If still you are getting the error, then remove the images from your project and again add the images to your project.
while adding image into the project, make sure that you have selected the Project name inside the "Add to targets". And also enable the "Copy items if needed".
Please Refer below image for better understanding:
Just select the image in Xcode and in right side, File inspector, under 'Target Membership' make sure your project is selected.
Another thing you can do is delete and re insert your image and make sure 'Copy items if needed' is selected and 'Add to targets' your project is selected.
Click on the image file in your Xcode navigator.
Once selected, go to the right side bar (of XCODE) which is
utilities and under file inspector, scroll to target membership and
select your project target file.
Then build and run the project again.
Xcode9 beta2 release note:
Jpeg assets in asset catalogs are not found on iOS 10 or earlier for apps built with Xcode 9. APIcalls for accessing the image such as UIImage.imageNamed: return nil. (32524123)
Workaround: Use png resources or limit app testing to devices running iOS 11 or later.
Xcode9 beta3 release note:
Jpeg assets in asset catalogs are found on iOS 10 or earlier for apps built with Xcode 9.(32524123)
For those that are getting this error while developing a cocoapod
I was trying to use an image from my pod's bundle, thats inside a .xcassets file, in the storyboard. It would show fine in the storyboard but when i ran the app it would crash saying it cant find the resource.
I changed my podspec to include s.resources as well as s.resource_bundles
s.resource_bundles = {
'SDKRes' => ['SDK/Assets/*']
}
s.resources = ['SDK/Assets/*.{xcassets}']
Then it was able to load the resource properly from the storyboard
You can try opening your storyboard or nib as Source Code and then "Find" the image name in it, see if it exists but already invalid in your project, probably you have deleted or changed its name, and now it doesn't seem valid.
I have just updated to XCode 9 and it started giving me this issue. I created a new Image Set in the Assets section and added the images I wanted to this, then re-added them to my tab bar images with custom names and it worked fine. Hope this helps!
PROBLEM
This happened to me seemingly out of the blue on a tab bar controller with icons for each tab. The storyboard was still showing my image icons and the assets existed with the expected names.
MY FIX
Select the tab bar icons in their respective view controller and reassign the image like you did the first time.
This happened to me as well. I was doing everything right when adding the image but for some reason it was not working. I had to click on the image again once added, and then on the right toolbar under "Target Membership" I noticed my project was not selected even though I was selecting it when adding the image. I selected it here and everything worked fine.
I got the same error message (in XCode 8), even though the app ran fine (in the simulator and on the device).
I found the problem: In my storyboard, using the document outline pane, I clicked through every single UIImage, and looking at the attributes inspector for each UIImage - in the Image View section - found that one UIImage had a blank file name (instead of the .png file name containing the image). Reselecting the .png file name from the dropdown box fixed the error message.
I have fetching same issue in xcode 9.
just tick on target membership
I pulled my hair out over this issue for hours and none of the solutions in this thread worked. The problem, in the end, was that the Xcode project files were stored on a Google Drive file stream. As soon as I moved it to the local drive or iCloud it worked fine.
My case was a bit different. I was using an old IBDesignable element which had some property of setting an image directly from the storyboard. Since that element was old, hidden and unused the images it had were not present in my assets folder.
Now Xcode won't be able to search this image since it is not in the project anymore. But if you search in the finder, inside your project, you'll find the XIB/Storyboard in which it is mentioned. From there you can find it manually by opening that XIB or Storyboard as source code and search. Once found either replace them with a new image or remove the unused element.
Look into storyboard file you'll see a question mark icon on any of the imageView (as shown in screenshot below) or UIButton image.
Just correct it and the warning will be gone.
Hope this helps
My guess is that you have an image in the Project Setting->Build Phases->Copy Bundle Resources which loses its reference and appears in Red text color. Remove this image from there and re-add.
This happens often due to relocate the image file after adding into project where image was added as a reference instead of a copy.
May be this can fix your issue.
Urughhh. I tried to fix this with all the above solutions, but nothing worked. What finally worked was:
Delete image from your project and select Move to Trash
Clean project
Close and restart XCode
Rename your image filename so something other than the previous name
Add new image to your project
I was facing the same problem, I solve it by deleting folder and create again and past all images then add reference again.
Based on what #hstdt posted above, it made me think I should check that my image is a filetype that doesn't have any bugs related to it. (https://stackoverflow.com/a/44558948/6804257)
I was using a .gif. I got rid of that image and instead used a .png. Now it works.
Had the same issue and none of these answers worked for me. Instead I restarted the mac and iPhone I was working with and then everything started to work fine again. 🤷‍♂️
My case is difference. I have more one assets folder. So I added to the wrong one.
Just remove and add to the right.
In my case,removing and adding the assets folder from the target fixed the issue.
Xib sets a wrong name for folder reference images. For example I have the folder like Menu->icon.png. Xib sets the "icon" name for the image. It should be "Menu/icon". So do no set images in xibs if you use a folder reference images.

In iOS, how to change launchscreen image according environment (dev, hom, prod)?

I have a launchscreen with a image, so far working well.
But now I have 3 schemas: dev, hom and prod.
I would to know how to change the launch screen image according the schema selected at the build time?
EDIT
I have in mind two options, but I do not know which one is best:
Option 1: Create two storyboards and create a variable to set the name of the correct storyboard in the app delegate. This variable I will use in the Info.plist key (Launch screen interface file base name).
Option 2: Create two scenes at the Launchscreen.storyboard and programatically set the correct scene according the enviroment.
Use targets, add a target for each environment, each target will have its own info.plist and you just set a different launch screen storyboards for each target , set it once in the relevant info.plist and you ready to select any target and run.
Your second option definitely won't work, since you cannot execute any code on a LaunchScreen and the LaunchScreen is displayed before any code could be executed (even in your AppDelegate), so you cannot change the LaunchScreen file in runtime.
Your first option is almost correct. Indeed a viable solution could be creating several Storyboards for the different launch screens, but you need to tweak the Info.plist file in a build script, you cannot do this in runtime either. Be aware that I haven' actually tested this method, but in theory it should work.

Why in iOS Framework, xctest is always red colour?

I'm trying to make a new framework to use in my other project. I know if it is red colour means can not find to the path of the file. But this not a file I created!
What I don't understand is why my new framework with pretty much nothing inside is always red colour. I even run test cases (default). I appreciate if anyone can help me to fix this:
No, Scheme(not schema) is different from Target. Check out this thread for better understanding Xcode: What is a target and scheme in plain language?
To solve your issue, click on the WSBandKit framework icon on top left section(adjacent to iPad2 simulator icon); and select editScheme option from drop down. You will be presented with a new screen with some option. Go to Build option and tick the option of Run for your test target. Close the screen and Build the framework for Device.
Check the image for reference. Initially the Run option will be unchecked for test target that you have to check.

iOS 8: Launch Screen StoryBoard appears black [single XIB file works fine]

So I tried creating a launch storyboard for my iOS 8 app using this tutorial
However, I only get a black screen when I launch my app. A single launch screen.xib file works perfectly, however, when I try to use a storyboard, it doesn't work.
I tried a storyboard with just a single view controller, but it still gives me a black screen, hence I believe the issue is with storyboard files in my setup. Any ideas?
[XCode version 6.4]
EDIT: So I just want to clarify that it is the launch screen that appears black. The main storyboard itself appears correctly when the app has finished loading
Read through the tutorial and tested it, and it doesn't say two things:
1: You'll need to add a UIViewController to your .storyboard file, and then select it as the Initial Controller.
2: If you wish to change more than just the launch screen, you'll have to go to the project settings and set the "Main Interface" to your corresponding .storyboard.
Once that is done, all you need to do is edit the UIButton/Label/etc connections to your ViewController classes.
EDIT:
For clarification, you can set a UIView as the initial controller by selecting it in it's respective storyboard file, then opening the Attributes Inspector. The option for 'Is Initial Controller" is towards the middle.
For people using UIImageView in the launch screen
Make sure that you are using the image name without the extension in the attributes inspector.
So for example, if your image file is named launcher.png, only use launcher as image name.
This will show the image as invalid (?) in the editor but will show correctly when run on device.
(Don't ask me why it works this way. Ask Apple.)
None of the answers have all the steps required, hence this exhaustive solution.
Storyboard
Start by creating the LaunchScreen.storyboard. Xcode > File > New > File... > Storyboard > LaunchScreen.storyboard and add it to all appropriate targets.
In this storyboard, create a single view controller of type UIViewController. Do all the magic your launch screen requires, then follow these steps:
LaunchScreen.storyboard > Show the File inspector > Use as Launch Screen
LaunchScreen.storyboard > View Controller > Show the Attributes inspector > Is Initial View Controller
Project > General > Deployment Info > Main Interface > LaunchScreen
Repeat for [iPhone] and [iPad]
Project > General > App Icons and Launch Images > Launch Screen File > LaunchScreen
If setup properly, your Info.plist should have LaunchScreen .storyboard, without the .storyboard under the UILaunchStoryboardName & UIMainStoryboardFile properties:
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>LaunchScreen</string>
Notes:
This is not incompatible with having legacy images for older devices using Launch Screen File > Assets.
Pay special attention to LaunchScreen.storyboard and Main.storyboard. One is used for launch, the other for your app entry point. They both need to have Is Initial View Controller set.
In the storyboard, which you are using for launching, please make sure that you had selected the option of Is initial view controller for the very single view controller present in it.
I Belive I may have had a similar issue that required something a littel different to the above answers.
I created a new launch screen in a .storyboard file, then after it not appearing I resulted to a new .xib file which still did not appear when the app was launched.
I figured out that some of the images I had on my launch screen had an Outlet Collection to an old .swift file. After removing this from the LaunchScree.xib's the launch screen worked fine.
Notice the litte warning sign in the outlet reference ->
Make sure that you set your entry point and in your general info tap make sure that you have the view set to resize from nib. Also make sure that in your general tab the start up point is set. In the deployment info.
Hope this helps
Spent way too long on this, thanks Apple! I finally discovered that I had to delete the actual UIImageView in my view controller - not just the image - in order to change to a different image. Tried renaming the images, replacing them in all different ways, deleting caches, deleting the app from the device, doing a Clean before building. The original image was gone from everywhere as far as I could see but it would still appear. Finally I added a new UIImageView on top in the view controller and this took a new image. Then I just deleted the old UIImageView and all was fine.
The solution is use the image name without the extension png.
For example, if your image file is named "img.png", only use "img".
This will show the image as invalid (?) in the editor but will show correctly on running.
This happen because the LaunchScreen.storyboard accept only images inside Assets.xcassets and the way to refer the images inside Assets.xcassets is the name of the resource without extension.
I think that use the name without extension is a workaround that work.
I had the black screen instead of my splash after localizing my app. In Localization section of the File inspector of LaunchScreen.storyboard I had only one tick for one localization. So, I added a tick for the second localization and this fixed the issue.
Answers by #SwiftArchitect and others are good, but I kept getting the black launch screen instead of my launch storyboard.
The problem ended up being that my storyboard was losing its connection to my target.
When I created it, I moved it into a different group/directory in the Project navigator, to keep things neat. BIG MISTAKE! That disconnected it from the target... it didn't matter that the group/directory it was now inside of was connected to the target!
You can tell the difference in the dropdown menu located at:
Project > General > App Icons and Launch Images > Launch Screen File
When you open that menu, you should see your storyboard as a choice to click on.
Do not type in your storyboard name manually -- that's a sign that the target membership isn't right.
I am also trying to add a launch screen, and this procedure got it to appear (thank you!), but now the app hangs there, not moving on to Main.storyboard and viewDidLoad. I have this:
Launch screen interface file base name LaunchScreen
Main storyboard file base name LaunchScreen
If I change the second LaunchScreen to Main, I do indeed get to viewDidLoad and the app's main screen, but without LaunchScreen.
Both sim and device do this. What am I missing to get to Main after LaunchScreen?

Could not load the image referenced from a nib in the bundle with identifier

I had got an iPad application.The ViewContrtoller.xib has got an UIImageView in it. The UIImage of the UIImageView is set through Interface Builder. When I run the application in simulator everything is fine. But when I am trying to run it in iPad the UIImage is not loaded. The message that I am getting is:
HexaPuzzle1.0[3259:207] Could not load the "start.png" image referenced from a nib in the bundle with identifier "com.yourcompany.HexaPuzzle1-0"
2010-12-17 10:57:27.221 HexaPuzzle1.0[3259:207] HexaPuzzle loaded
Any help would be appreciated and will be a great help for me.
The issue has been rectified.
Problem was with the image format. When the image has been edited and saved as PNG-24 everything goes fine.
The application now runs smoothly in simulator and device.
Thanks for all friends who suggested a solution and tried to helped me.
Regards,
Rupesh R Menon
I know it's very late, but this is a solution that also works in Xcode 5, and therefore likely to be useful to people who have this problem in the future.
I have seen a lot of questions like this on the web but none of them seems to have one clear answer. This is, as far as I know, the solution for this problem:
Go to the image in Xcode (no need to re-add or re-generate the
image)
click "show the file inspector"
Make sure the checkbox in the category "Target Membership" is checked. the test check box does not have to be checked to make your app load the image.
The target membership tab looks like this:
if this is already the case, you are working with a broken or damaged file. to rule this out, check if another app (like photoshop) can open your image.
This should do it, hope it helps!
When dragging your start.png file into your project, did you check this option?
I was getting this error in the simulator after upgrading to Xcode 7 / iOS 9 and opening an existing project. The image was present and named correctly, within an XCAssets package.
Turns out the problem was with a parameter within the XCAssets package.
Changing Render As from Default to Original Image solved the problem:
I've had the same problem before. The png file format is not right. Try re-generate the png image file and the problem will be solved.
None of the above worked for me, and the message I got was "could not load the "(null)" image referenced... which means I could not look for the image. Very frustrating. In the end it became a trial and error exercise of going through every xib and storyboard looking for potential conflicts. I finally found it - I had specified a "Selected Image" for a tab bar item which was not needed. As soon as I got rid of that the problem went away.
None of these things work for me. I created a new folder in the projects where I placed the pictures. That worked for me.
This problem was fixed when I changed "add folder reference..." to "add group..." when I import the images to my project. I'd prefer to have folders with live updating, but at least it works now.
Had an image on a XIB (which is replaced by the correct one in code). After finishing this XIB, I renamed the images. So XIB was now referencing a non-existent image.
There is also another potential cause of this problem: If you upgraded to XCode 5 and use both the image asset catalog and "normal" images copied to your project (like you did prior XCode 5). If you then have images with identical names (e.g. "dog.png" and a image set called "dog") it might work in your storyboard and in the simulator, but you'll get this message when run on a real device (where the image will not be shown).
Try moving the images directly to the Resources directory (not in a sub folder)
Make sure the resource isn't too big to be handle.
If you get the error message with the name of the picture, you can search it inside your project and xCode will display immediately the UIImageView with the wrong picture inside UIStoryboard:
Make sure it is included in your Target Membership
Select your "Images.xcassets" file in the file Inspector
Open File Inspector (cmd + opt + 1)
Select your target membership (Usually 1st line)
I had the same problem, but the cause was very different. I was using image sets in the Asset Catalog that varied based on the device idiom: iPad or iPhone.
The framework target they were being added to had been accidentally marked as as having a deployment device type of iPhone, so the images weren't showing up on iPads - they weren't even being copied into the .car file in the framework.
Setting the deployment device type to Universal, as it should have been, solved the problem.
For some reason I was getting error until I put the image in the Assets.xcassets

Resources