I am new to swift.
I recently downloaded some examples of swift playgrounds by apple such as Newtonscradle and Balloons, but I am unable to view them using the assistant editor of X code(I have version 8.2.1). I was wondering how I can solve this problem.
Initially, I searched for how I can download Scenekit, Cocoa, and XCPlayground because I thought my mac does not have them. However, I couldn't find out how to download them, and I am uncertain about whether this is the real problem.
I also looked at this question which was on stackoverflow, and tried out the code. However, this didn't work out either. When I put it in, it only says "Running (document name)" and stays like that forever.
Does anyone know how I can view these codes on the assistant editor? Also, I am currently learning swift through the iBook, "The Swift Programming Language Swift 3.1 edition," but are there any other ways to learn swift with an Mac computer? I want to finish making something in two weeks for the WWDC17.
Regards,
RK2
If you clone the project you linked to, and then update the submodules (the playgrounds appear to be linked to as submodules from other GitHub projects) you should have one or more .playground files under each subfolder under the playgrounds folder. Simply open the playground file you want in Xcode by double-clicking it in Finder.
Related
I am an iOS developer and trying to learn tensorflow
for my Xcode 11.2.1. I tried installing tensorflow using this link
I got the package in Xcode toolchain.
But after installation when I verified installation, it failed. Swift playground is giving error
No such module 'TensorFlow'
I created a new SwiftPlayground for macOS, still, no avail.
Later I again installed tensorflow through command-line from here and it too was successful.
This time I had created a normal swift file to verify installation, but this too failed.
There is an existing old question on same issue, but that has not been helpful to me. Can anyone help me knows solution to this?
Answers to your queries:
Swift Playgrounds are not yet supported (available in future) by S4TF toolchains.
You can only build app for macOS right now but support for other OSs will be available in future.
Before you run your Swift file via CMD you need to export PATH=/Library/Developer/Toolchains/{swift-toolchain}/usr/bin/"${PATH}" where you should replace {swift-toolchain} with your S4TF toolchain name (clicking tab will suggest you available toolchains on your system). Then running swift test.swift will be (hopefully) successful.
Note: S4TF is still in early stage of development & is ready for beginners and researchers to work with it. But I personally feel that if you're developing an app for iOS it's a little early. I hope Apple with announce this feature in WWDC either in 2020 or 2021.
I hope this was helpful!
-- Rahul Bhalley
Also, if you, as an iOS developer, want to deploy a model into an iOS app without "leaving Xcode (almost)", you may be able to replicate what this developer did here. The author of that PDF presented at a S4TF design meeting not long ago. You may have seen this in the Google Groups discussion.
A workaround for model saving for you could be: use Python interop > import Keras > ... > Save model as .h5. Then, perhaps, you could use Apple's Python-based coremltools for Keras to integrate the model—now in the .mlmodel format— into your iOS app. I haven't tested this yet.
I recently checked out the Swift Playgrounds App available inside the App Store where I stumbled across this interactive coordinate system view similar to the one that can be found inside of Xcode playgrounds on the Mac.
My question is if this framework is accessible for developers or if it's something Apple developed internally for the playground?
Thanks in advance.
It seems like apple is using it internally. But you can build it yourself see this blogpost for inspiration. However it's written in Swift 3 but it should be easily transferable to Swift 4.
Currently we can access a particular module in Swift by command + clicking a particular Swift type. Is there a way to easily access all Swift modules / standard libraries from within Xcode?
Is there a way to debug into Swift source code like one can in Android?
Is there a way to debug into Swift source code like one can in Android?
The answer depends on what you mean by "all Swift modules / standard libraries".
If you are interested in the Swift's standard libraries (i.e. clases like String or Array), then Swift was open-sourced by Apple and you can find sources on github following links from https://swift.org/source-code/. Still there seems to be no way to "attach" those sources to navigate there from your XCode project.
However, if you are interested in most of the MacOS or iOS frameworks such as UIKit and many others, then I believe the answer is NO.
Unlike Android, iOS is a proprietary closed source OS and in most of the areas Apple has no intentions to share its code with everyone.
Side Note: Once it was claimed that one of major reasons for Apple to switch its tools from GCC stack to Clang/LLVM stack was that GCC is licensed under "copyleft" GPL and thus Apple couldn't integrate parts of GCC Obj-C backend (such as code analysis or stuff useful for refactoring) into XCode even if those parts were developed by Apple itself without making whole XCode open source. Clang/LLVM on the other hand uses more permissive open-source license that allows such 3rd-party usages.
Moreover much of the Apple's internal code still must be in Objective-C or even plain C rather than Swift. It is relatively easy to convert "headers" i.e. interfaces specification from Obj-C to Swift automatically but it is very hard for real implementation especially given difference between Obj-C and Swift. So even if it was an open-source, there would be no debugging in Swift.
On a positive side: some code gets executed and Apple can't hide it and thus you can debug it. The only problem is that the code is in machine language helpfully decoded into Assembly (x86 or ARM) by XCode. However, it obviously requires some skill and time to understand any non-trivial logic from that. And beware that you probably can't copy logic found that way without violating some copyright laws.
Swift is open source. So you can get its code and modules here.
However, you can't do it with command + clicking in Xcode from your own project. In fact, the code you got from command + clicking was not Swift source. They were headers that were generated by the compiler automatically. Those headers may be generated from Swift source code, or even Objective-C code.
Also, even though you can get source code and edit it, you can't use it on your app that you want to be published to App Store. You can only use the Swift comes with Xcode to published to App Store, or your app will be rejected.
I am new to iOS Development and am now venturing into adding different features into my Apps and now would like to be able to implement Push Notifications into iOS5 apps with Xcode 4.2.
I have tried my hardest to understand the iPhone Developer instructions regarding Push Notifications, but found that the easiest method (according to many sources around the internet) would be to use Urban Airship!
I have gone over this for quite a number of days now and tried and tried my hardest to be able to complete the steps required in the Set Up A New Application part of the document.
It states:
The core library requires your application to link against the following Frameworks (sample UIs have additional linking requirements):
libUAirship-.a
CFNetwork.framework
CoreGraphics.framework
etc, etc, etc
http://www.youtube.com/watch?v=EwqM4wfaYNU
The link just above is a YouTube video of what steps I took to follow these instructions and it's really starting to get to me. I would like someone to be able to provide me with some assistance and explain what I am doing wrong, and how to better understand the way you link against the following Frameworks because I have tried my hardest, and never managed to understand it.
Any help would be GREATLY appreciated from anyone.
You are trying to #import a static library in your code. The .a file is a library, not an include file. You just need to add them to your project and then include the .h file in your project.
Search Google for adding static library to xcode, or similar. For example, A quick Google search found this
Is it possible to mix iOS code and interface elements with Unity generated iOS code?
For example if I am working with a game developer who is developing a game in Unity, could I take his xCode project (generated by Unity), and add interface elements which I code myself using Objective-C & Interface Builder etc?
From what I can see this isn't possible as everything is created via Unity.... but hopefully I am wrong...
Thanks!
You can even use 3rd party libraries in XCode and integrate them in the build process. After fiddling around with the right settings I wrote a blog entry about this:
iPhone & Unity3D: Integrating 3rd Party Static Libraries in Unity3D Generated XCode Projects
You should be able to generate Native plug ins to interact with the Unity code. You would need to write a wrapper though. Read more at: http://unity3d.com/support/documentation/Manual/Plugins.html
Read the part at iOS :)
I came across this general guide to working with Unity native plugins in OSX which was useful and is probably where you need to be looking for your answer, as Zophiel said
https://blog.reigndesign.com/blog/unity-native-plugins-os-x
You can just design a view and button to trigger the unity to run or stop, but models in unity can't be controlled using Obj-C, although unity has import to Xcode, it only import the start code, game scripts depending on the link libraries which couldn't be modified.
I think you can do it as the same way I probably has been working with Objective-C without any changes. For Unity's code generator preserves the native codes under Classes.
And furthermore there is an another way to do this which is called "Plug-in".
But I hope the developers in Unity find a better way seamlessly combined with Xcode as staffs in Apple usually does.
Combining IB and Unity's integrated editor would be better and more welcomed in future.
Possible yes. Advisable for beginner or intermediate level Devs? Probably not. The Unity project is generated and regenerated every time you push a build. Now I believe that if you use Append when you do builds that it should keep existing changes to the Xcode project... but 'should' is the operative word there. You may need to implement some sort of build system like Jeeves to keep the headaches to a minimum if you are trying to do this on a large project in which you for see a constant stream of updates from both the Unity side and the Xcode side.
Now if you're integrating code that is in it's own files and doesn't overlap or rewrite the code Unity has generated, then the Append feature is really going to work for you, but if you're deleting, altering, or adding code to any of the files that Unity generated then definitely use SVN or some other form of source control and snap shot before and after every new Unity recompile / Xcode generation.
Also, take a look in the Unity Asset store. Whatever functionality you are trying to home brew in Xcode can definitely be written in C# on Unity. Someone else may have already conquered the problem you're trying to solve and placed it in the asset store for $5.
Hope that helps.