No such module "CreateMLUI" - xcode

I am using macOS Mojave Beta (10.14 18A293u) and Xcode 10.0 Beta (10L176w). I created a Swift Playground and I am unable to import CreateMLUI framework in order to use it. I keep getting an import error.
I have tried creating both an iOS Playground and a macOS Playground
Anyone knows what I am doing wrong?
Thanks in advance.

While macOS Mojave and Xcode 10 are in beta you may experience bugs while trying to use CreateML.
#Koen from one of the comments in my question found a topic in Apple Developer Forums with some workarounds. What I did was:
Create a new single view Mac OS (NOT iOS) playground
Use a completely different name if already created a buggy playground (this is important)
Add the import CreateMLUI line
Remove all the other boilerplate code

I found the answer to this problem in the apple developers forum (Can't find the exact link to the post).
You simply have to select the macOS tab when creating a playground.

When you create the playground make sure you select "macOS" tab instead of. "iOS".

This feature is no longer supported in this environment. You can complete this task in the Create ML app. Follow these steps:
Xcode -> Toolbar -> Open Developer Tool -> Create ML -> New Document

Open Xcode menu
Choose Open Developer Tool > Create ML
Press New Document
Select Image Classification
Specify name and a place where the project will be saved

In new versions of macOS, the CreateMLUI library has been deprecated and removed. Instead, create models in CreateML, a developer application inside Xcode.

Related

How do I create a .storekit file in Xcode?

I'm currently trying to set up a local environment to test in-app purchases in a macOS application.
Apple's documentation at https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode states:
To create a StoreKit configuration file, launch Xcode, then choose File > New > File. In the sheet that appears, enter “storekit” in the Filter search field, select StoreKit Configuration File...
When I filter on "storekit", there is no "StoreKit Configuration File."
What am I doing wrong? Do I need to install some kind of SDK or similar in Xcode?
I use Xcode 12.0 beta (12A6159) on Catalina 10.15.5.
The Storekit configuration file is found and I can create and configure it.
But the Scheme -> Run -> Option does not display a selection option to perform local testing on a macOS project, but only on IOS project.
On the apple documentation StoreKit Test framework is labelled macOS 11.0+
A comment on Apple Dev Forum indicate that this menu appears on a Big Sur configuration for a macOS project, but that Xcode stills connects to Sandbox. Not tried yet on Big Sur.
One thing that can trip people up:
If you are using Swift Packages and you have any source-file or directory from a package selected in the Project Navigator, then the types available in the File->New->File sheet is more restricted.
Select the iOS project, or a Group within it, then File->New->File will contain the StoreKit Configuration File option.
This is a brand new feature, so you need the latest version of Xcode for this - Xcode 12. Please also watch the session https://developer.apple.com/videos/play/wwdc2020/10659/

Xcode- Library not found for - IGoogleUtilities

I am new to Apple and Xcode, I make an application in unity3d and I try to implement AdMob. When I Run for test in xCode I have the error: Library not found for- IGoogleUtilities.
https://imgur.com/a/RTDZPYw
Also when I select "Simulator SDK" from Build Settings/Player Settings/Other Settings the build Button is interactable
Maybe it'il help someone;
"When using Unity 5.6 and above, an xcworkspace is generated that includes the required dependency libraries. Use the generated xcworkspace instead of the standard Xcode project."
Select device SDK from Unity editor.
inside Xcode, You should download and add GoogleMobileAds.framework then rebuild.
Let me know if it helps.

New to XCode - How to create a class?

I am new to Xcode, running version 8.0.
Right now I am going trough this
tutorial. (I am programming in C++). There the author is creating a class. Since he is not using Xcode and the other answers to a similar question are dealing with an older version, I am asking myself if someone can help me out.
Thanks in advance.
How to create a new c++ file in Xcode
To be able to run c++ files in Xcode you need to create a new project first.
Then in your project you can add files using the guide below
Right click on a side menu with your project -> new file -> ios source on left panel -> swift file on a right panel. That's pretty much it.

Playground Import: No Such Module 'Foo'

I've diligently followed the Apple instructions to import a custom module into a playground, including the instructions here. And yet I get:
Playground execution failed: /var/folders/z3/kd0nj4ln1rgcpm8bdz7067wh0000gs/T/./lldb/1874/playground1.swift:7:8: error: no such module 'Foo'
import Foo
How can I recover to a working Playground import? [Edit: Note, two answers have produced detailed instructions to associate a playground with a framework; I have followed those instructions but no luck. The solution will need to involve reconfiguring something in Xcode; my installation is apparently broken]
Detailed images of the error and attempts:
Here is another attempt, based on the answer of #EricD, showing the directory structure, no dice.
For some of those that none of the above solutions work (and that Xcode build path setting was already set to Unique), I've found a solution.
The framework must be built with a scheme for an iOS simulator device (any in the list) and NOT a Generic iOS Device, as Playgrounds do not support it. This one worked for me :
Here's how I proceed for OS X with Xcode 7.1:
Create new project: OS X Cocoa Framework, Swift. For this example I named it "TestPlaygroundFMK".
Create a new Swift file.
Add a class to the file. The code has to be public. I made this for our example:
import Foundation
public class Talk {
public class func sayHello() {
print("Hello from framework!")
}
}
Build the project now.
In the menu bar, click on File > Save As Workspace.
Create a new Playground and save it inside the project folder next to the Swift files.
The Playground must not have the same name as the project.
Build the project again.
Import your framework in the Playground and use it:
import TestPlaygroundFMK
Talk.sayHello()
I had my playground working fine but found that when I quit Xcode and re-opened it, I would get an error like this:
error:
/var/folders/ft/bmk8wh6s5ms4my2pxhn3qbp40000gn/T/playground1-9216e0..swift:3:8:
error: no such module 'Playground_Sources' import Playground_Sources
... where "Playground" is the name of my playground file.
The solution to this (in Xcode 9.0) is to:
click any playground file in your workspace
show the Utilities panel (opt-cmd-0)
under "Playground Settings" change the "Platform" to anything else then set it back.
In my case, it's set to macOS. I changed it to iOS then back to macOS (no recompilation necessary) and it started to work fine... that is until I close Xcode and open it again.
This is the only solution I found to work with macOS playgrounds. This bug still exists in Xcode 9.3.
I'm not sure i had the exact problem as the original question - but given the mix and age of solutions and the lack of this one that DID work for me, i thought I'd share.
In Xcode 11+ (tested this on 12.2), i'd often have Playgrounds fail to run givn the "No Such Module" error when it included a framework that is a part of the workspace.
The solution for me was in the "File Inspector" for the Playground, and the "Build Active Scheme" option:
This ensures the project was being built appropriately for the target, and now my annoying compile issues are gone!
Create a workspace as below:
Choose File > New > Workspace
Enter the workspace name, and specify its location in your file system
Click Save
Now, Create a Cocoa framework with swift file which have your class
Choose File > New > Project
Select Cocoa framework > Next
Enter Product Name and Language > Next
Before clicking create, in 'Add to:' and 'Group' list choose 'Your workspace name' as shown
Framework is added to your workspace
Create swift file in your framework
In Xcode right click on the folder where you want to add swift file and select new file...
Select swift > Next > Name your file > Create
Select your framework in Xcode -> Build your framework
Create playground -> Playground should also be part of your workspace, if not drag it to your workspace, it'll be added automatically.
Right click in Xcode's files section > New file... > Playground
import
Call your method
Note: If you just wanted to add classes instead of framework to your playground check the link How to import my own class into an Xcode 7 playground?
Solution that worked for me:
Setup your workspace and project/framework.
Delete derived data (How to remove derived data?)
DO NOT BUILD YOUR PROJECT YET
Create playground file with different name then your project/target/framework name under folder with either Swift files or where .xcodeproj is located (does not matter which one you chose)
Build your project under required platform (if playground is for macOS, then build project with macOS target, etc.)
When build finishes try adding some code to your playground and run it.
P.S. you might need to restart Xcode before 6th step.
The solution, from Apple Support, was to adjust my Xcode Preferences. On Locations :: Advanced my configuration was 'Legacy'. By changing to 'Unique', and undoing any paths I'd attempted to insert, Playgrounds can now import frameworks.
I don't think it's a stretch to say that Xcode is somewhat of a blackbox. I make no claim that this will work for anyone else, but for me, after having the same issue after creating a new playground and a new framework target, and all the other proposed solutions, what finally worked was deleting the workspace file and (in my case) regenerating it with cocoapods.
I have no idea why this worked.
Build the framework with release ,this worked for me. (Xcode 10.1, swift 4.2)
Insert a var at the first line and re run
var str = ""

Can't open Swift Guided Tour Playground

When I try to open the Swift Guided Tour playground from Apple's e-Book, it says "the document can't be opened because it is from a newer version of Xcode. As far as I can tell, I'm using the newest non-Beta version, and I'm not working with Swift 2.0 yet, still learning the first version. Have all the playgrounds been updated to work with Xcode 7 Beta or something? I'm using Xcode 6.3.2, just in case that isn't actually the newest version.
I got the same issue with xcode 6.3.2.
I got the issue when I downloaded it via ibook link. Once I downloaded it via we, it worked.
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html#//apple_ref/doc/uid/TP40014097-CH2-ID1
My previous version was playground version='1.0' and the new one also same. But it includes lots of new libraries.
I got that problem too, and finally i open it OK, that just problem with where you download your .playground file:
#Xcelleratr Download your file here:
https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/GuidedTour.html
It will be OK my friend :)
works for Xcode version:
Version 6.3.2 (6D2105)
Version 7.0 beta (7A120f)
Im guessing it was corrupted could check it by:
Right clicking on the playground file > show package contents > open contents.xcplayground in a text editor like sublime and look for playground version='3.0' near the top
If this is any higher it will pop up with the error you seen.
Just in case someone stumbled upon this problem, here is what happened to me:
Download from guided tour page.
Save it with .zip extension instead of .playground, as seen in this picture:
Double click the downloaded file, it will unzip it and you'll get your actual GuidedTour.playground file.
So if you have a playground file and it only opens xcode and not a guided playground, right click the playground fle and show package contents, then go to contents.xcplayground and rightclick and open with text editor.
I had to change this line...
display-mode='raw'>
to ....
display-mode='rendered'>
then save and when you go back and open the playground it should be ok now.

Resources