I am new to swift playgrounds and ran into some problems while making a swift playground in Xcode.
This is my main Playground page
import UIKit
import PlaygroundSupport
import SpriteKit
let secondScene = Index()
let master = FirstScene()
let root = UINavigationController(rootViewController: master)
PlaygroundPage.current.liveView = root
But when I tried adding Next Topic in both the source class in Swift and the playground page itself the link does not appear.
NOTE: I am using Swift Playgrounds in Xcode not a Playgroundbook on an iPad.
Also, inside sources folder of my main page I declared all classes as public, is that the right way to use the helper swift files in source?
I tried creating a new playground and added pages which have default links but still no output.
Looking at your screenshot, you've got the code right. The syntax to link to the next page is [Next Page!](#next). All you need to do now is:
- In the Xcode menu bar, click Editor
- Click 'Show Rendered Markup'
That's it. You can place markup wherever you like. Remember to replace spaces with %20 when linking to a playground page, e.g. [My Page #2](My%20Other%20Page)
You would benefit from reading Apple's Markup Formatting Reference.
To create a link to another page you will do the same thing that I did above to create a link to that reference in Markdown:
[Next Topic](Pretend%20Topic%20Name)
You can actually do something like this as well:
[Next Topic](#next)
Related
Im trying to localize the Summary of my new SwiftUI AppIntent on my Swift project for making new Shortcuts.
I am not able to localize the Summary.
I have created a AppShortcuts.strings with Localize of English and Spanish languages like in this page appears: click here.
AppShortcuts.string (es):
"add ${numberOne} ${numberTwo}" = "Sumar: ${numberOne} ${numberTwo}";
Shortcut:
static var parameterSummary: some ParameterSummary {
Summary("add \(\.$numberOne) \(\.$numberTwo)") {
\.$numberThree
\.$numberFour
}
}
As stated in the article you have already mentioned these directives have to go into Localizable.strings:
ParameterSummary –
This one is tricky. You'd think that because it has a variable it should be with the translations of the phrases in AppShortcuts.strings, but no, it belongs in Localizable.strings.
Don't know why but that works for me.
I am currently developing a cocoa web browser application like google chrome. I was testing it until I came across the problem that the wkwebview doesn't support full screen on videos. When I open a video, I get this message...
I thought I had to make the wkwebview a subview of the view, using this code
view.addSubview(webView)
I tried it and it still show the image above.
Can you please assist me on supporting full screen.
Open your project.
Right click on prject app grade folder from sidebar and click new file.
in choose a template click objective-C file.
name it for example WKPreferences and enter.
Now next window press create.
On next create Bridging-Header.
Now you can see two new files in your sidebar.
Paste following code in WKPreferences.m
#import <Foundation/Foundation.h>
Paste following code in Bridge-Bridging-Header.h
#import <WebKit/WebKit.h>
#interface WKPreferences ()
-(void)_setFullScreenEnabled:(BOOL)fullScreenEnabled;
#end
Now Paste following code in viewcontroller.swift
webView.configuration.preferences._setFullScreenEnabled(true)
Thats it.
You should be able to just put the following in the Swift-File where the WebView is created:
webView.configuration.preferences.setValue(true, forKey: "fullScreenEnabled")
Is there a way for me to click a button in one playground scene and then transitions to another scene? Preferably using SwiftUI
Yes, the markup formatting of Swift Playgrounds does support that. The syntax for it is
//: [Next Topic](#next)
Then you need to enable rendered markup for your playground, which you can do using Editor > Show Rendered Markup.
This is an Xcode and Swift playgrounds feature, it has nothing to do with SwiftUI or Swift itself.
For more information, see the Markup Formatting Reference Apple documentation.
In my Swift 2 project, targeting iOS 9.2 and above, in Xcode 8.2.1, I have code that shows the mail-compose screen like so:
if MFMailComposeViewController.canSendMail() {
let composeMailVC = MFMailComposeViewController()
composeMailVC.mailComposeDelegate = self
composeMailVC.setSubject("Test")
// etc
}
Originally I had a reference to the MessageUI.framework in my project properties, but after removing the framework reference and cleaning the project, it still builds fine and when I run the code on my device the mail compose window still appears and seems fully functional.
I cannot find any explicit references to MessageUI.framework in the raw text of my .xcodeproj file, nor is there anything in my Objective-C bridging header.
I know that Swift does make some implicit framework references, but I couldn't find anything that suggests MessageUI.framework is one of them.
Curiously when I jump to the definition of MFMailComposeViewController XCode shows it in the MessageUI module.
The compiler automatically added the frame work in given its previous direction - IE. Import.
I'm having problems adding documentation to my code in Xcode 8.2.1.
Here's my code:
/// Test documentation method
///
/// - Parameter string: The input string
/// - Returns: The output bool
func testMethod(string:String) -> Bool {
if string == "YES" {
return true
}
return false
}
The documentation shows as expected in the quick help window but the description doesn't show in the code autocomplete window.
Is there a way to get the description to show in the autocomplete box as in the image below:
You are right, the descriptions you added to the top of your methods and properties don't appear in the popover anymore.
As noted, you can only see the descriptions of Apple's own methods and properties.
The reason being that Xcode doesn't parse these from their classes but rather from a separate documentation set (which you can find in Xcode's Help/Documentation and API reference tab).
So unless Apple decides to change this, I'm afraid it won't be possible to see your own in the popover.
You could keep an eye on existing doc set generators (AppleDoc, Jazzy), maybe they'll offer a way to link their documentation to Xcode's popover.
Keep in mind that you do see your own comments when opening the quick help popover with alt + click on a method or property.
For me the best way to resolve this is by cleaning the project Shift+Command+K, and if that is not working, it is a god idea to remove Derived Data folder.
To remove this folder go to Xcode preferences, Locations tab
and click on the small arrow to open a finder, and remove manually the folder.
Restart Xcode, and check if now is working
https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/MarkupFunctionality.html#//apple_ref/doc/uid/TP40016497-CH54-SW1
please refer the official documentation