• Lenovo Mac OS X Battery Fix

    Here is a nifty little script that I wrote a while ago that when applied to your custom extracted DSDT on the Lenovo L420, it will enable the battery percentage, not much required!

  • Samsung Galaxy S10 Nasty Surprise

    There are many reasons why everyone is excited about Samsung’s 10th-anniversary Galaxy S10. Most notably the leaked triple rear cameras, ’ultrasonic’ in-display reader, new gradient color schemes and 5G option.

  • Start using Flutter!

    Build beautiful native apps in record time Flutter is Google’s mobile app SDK for crafting high-quality native interfaces on iOS and Android in record time.

  • Android App Bundles

    What the hell is an App bundle anyway? There were a ton of exciting things announced at I/O this year — one of the things that caught my eyes the most was the new app bundle format.

  • ASUS X550LDV Mac OS X Guide

    With the purpose of running the beloved Apple Mac OS X on our Intel ASUS laptop I am writing this guide to share my experience and knowledge about this Hackintosh.

Showing posts with label apple. Show all posts
Showing posts with label apple. Show all posts

Swift 4 - The powerful easy to learn programming language

Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, Linux and z/OS. Swift is designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products. It is built with the open source LLVM compiler framework and has been included in Xcode since version 6. On Apple platforms it uses the Objective-C runtime library which allows C, Objective-C, C++ and Swift code to run within one program.



Apple intended Swift to support many core concepts associated with Objective-C, notably dynamic dispatch, widespread late binding, extensible programming and similar features, but in a "safer" way, making it easier to catch software bugs; Swift has features addressing some common programming errors like null pointer dereferencing and provides syntactic sugar to help avoid the pyramid of doom. Swift supports the concept of protocol extensibility, an extensibility system that can be applied to types, structs and classes, which Apple promotes as a real change in programming paradigms they term "protocol-oriented programming"(similar to traits).

Swift was introduced at Apple's 2014 Worldwide Developers Conference (WWDC).It underwent an upgrade to version 1.2 during 2014 and a more major upgrade to Swift 2 at WWDC 2015. Initially a proprietary language, version 2.2 was made open-source software under the Apache License 2.0 on December 3, 2015, for Apple's platforms and Linux.

Different major versions have been released annually with incompatible syntax and library invocations that require significant source code rewrites. For larger code bases this has caused many developers to dismiss Swift until a more stable version becomes available.

Swift is an alternative to the Objective-C language that employs modern programming-language theory concepts and strives to present a simpler syntax. During its introduction, it was described simply as "Objective-C without the C".
By default, Swift does not expose pointers and other unsafe accessors, in contrast to Objective-C, which uses pointers pervasively to refer to object instances. Also, Objective-C's use of a Smalltalk-like syntax for making method calls has been replaced with a dot-notation style and namespace system more familiar to programmers from other common object-oriented (OO) languages like Java or C#. Swift introduces true named parameters and retains key Objective-C concepts, including protocols, closures and categories, often replacing former syntax with cleaner versions and allowing these concepts to be applied to other language structures, like enumerated types (enums)

Syntactic sugar

Under the Cocoa and Cocoa Touch environments, many common classes were part of the Foundation Kit library. This included the NSString string library (using Unicode), the NSArray and NSDictionary collection classes, and others. Objective-C provided various bits of syntactic sugar to allow some of these objects to be created on-the-fly within the language, but once created, the objects were manipulated with object calls. For instance, in Objective-C concatenating two NSStrings required method calls similar to this:


NSString *str = @"hello,";
str = [str stringByAppendingString:@" world"];

In Swift, many of these basic types have been promoted to the language's core, and can be manipulated directly. For instance, strings are invisibly bridged to NSString (when Foundation is imported) and can now be concatenated with the + operator, allowing greatly simplified syntax; the prior example becoming:


var str = "hello,"
str += " world"

Swift supports five access control levels for symbols: open, public, internal, fileprivate, and private. Unlike many object-oriented languages, these access controls ignore inheritance hierarchies: private indicates that a symbol is accessible only in the immediate scope, fileprivate indicates it is accessible only from within the file, internal indicates it is accessible within the containing module, public indicates it is accessible from any module, and open (only for classes and their methods) indicates that the class may be subclassed outside of the module.


Comparisons to other languages


This section is in a list format that may be better presented using prose. You can help by converting this section to prose, if appropriate. Editing help is available. (February 2017)
Swift is similar to C in various ways:


  • Most C operators are used in Swift, but there are some new operators.
  • Curly braces are used to group statements.
  • Variables are assigned using an equals sign, but compared using two consecutive equals signs. A new identity operator, ===, is provided to check if two data elements refer to the same object.
  • Control statements while, if, and switch are similar, but have extended functions, e.g., a switch that takes non-integer cases, while and if supporting pattern matching and conditionally unwrapping optionals, etc.
  • Square brackets are used with arrays, both to declare them and to get a value at a given index in one of them.
  • It also has similarities to Objective-C:
  • Basic numeric types (Int, UInt, Float, Double)
  • Class methods are inherited, like instance methods; self in class methods is the class the method was called on.
  • Similar for...in enumeration syntax.
  • Differences from Objective-C include:
  • Statements do not need to end with semicolons (;), though these must be used to allow more than one statement on a line.
  • No header files.
  • Uses type inference.
  • Generic programming.
  • Functions are first-class objects.
  • Enumeration cases can have associated data (algebraic data types).
  • Operators can be redefined for classes (operator overloading), and new operators can be defined.
  • Strings fully support Unicode. Most Unicode characters can be used in either identifiers or operators.
  • No exception handling. Swift 2 introduces a different and incompatible error-handling model.
  • Several notoriously error-prone behaviors of earlier C-family languages have been changed:
  • Pointers are not exposed by default. There is no need for the programmer to keep track of and mark names for referencing or dereferencing.
  • Assignments return no value. This prevents the common error of writing i = 0 instead of i == 0 by throwing a compile-time error.
  • No need to use break statements in switch blocks. Individual cases do not fall through to the next case unless the fallthrough statement is used.
  • Variables and constants are always initialized and array bounds are always checked.
  • Integer overflows, which result in undefined behavior for signed integers in C, are trapped as a run-time error in Swift. Programmers can choose to allow overflows by using the special arithmetical operators &+, &-, &*, &/ and &%. The properties min and max are defined in Swift for all integer types and can be used to safely check for potential overflows, versus relying on constants defined for each type in external libraries.
  • The one-statement form of if and while, which allows for the omission of braces around the statement, is unsupported.
  • C-style enumeration for (int i = 0; i < c; i++), which is prone to off-by-one errors, is unsupported (from Swift 3 onward).
  • The pre- and post- increment and decrement operators (i++, --i ...) are unsupported (from Swift 3 onward), more so since C-style for statements are also unsupported from Swift 3 onward.




Development and other implementations

Since the language is open-source, there are prospects of it being ported to the web.Some web frameworks have already been developed, such as IBM's Kitura, Perfect and Vapor.

An official "Server APIs" work group has also been started by Apple,with members of the Swift developer community playing a central role.

A second free implementation of Swift that targets Cocoa, Microsoft's Common Language Infrastructure (.NET), and the Java and Android platform exists as part of the Elements Compiler from RemObjects Software.
Share:

ASUS X550LDV Mac OS X Guide (UEFI-Clover)

With the purpose of running the beloved Apple Mac OS X on our Intel ASUS laptop I am writing this guide to share my experience and knowledge about this Hackintosh. This tutorial applies to running versions between 10.9 and 10.11.6, focusing specially in El Capitan. This method applies also for Sierra but at the moment my WiFi Card doesn't work well with 10.12 so I chose to remain in a stable Mac OS X.



I have 99% functionality:
What Works:


  • WiFi, Bluetooth, Airdrop, HandOff, FindMyMac (WiFi card has to be replaced, I put a BCM94352HMB)
  • Full QE/CI acceleration with integrated HD4400 graphics
  • Trackpad with 1finger, 2finger, 3finger and 4finger gestures
  • Keyboard (Perfect with Volume, Brightness, Play/Pause, Numpad working)
  • Battery Percentage
  • Sleep, Shutdown and Reboot
  • Internal Speakers, Internal Microphone, Headphone Jack, HDMI audio
  • DVD Drive
  • HDMI audio and video
  • VGA out
  • iMessage and FaceTime
  • Recovery Partition

When you install Clover Bootloader to your USB media or HDD you should select the following options:

  • Install for UEFI booting only
  • Install Clover in the ESP
  • Drivers64UEFI (Fat-64, OSxAptioFix2Drv)


After installation is complete, the EFI partition we want to configure will already be mounted, so we proceed to open it and do the following Install HFSPlus.efi and NTFS.efi in drivers64UEFI folder and remove VboxHFS.efi Open the folder /EFI/Clover/kexts and delete all the folders starting by 10 and leave only the “other” folder In the above mentioned “other” folder place the kexts that I will quote next:


  • ACPIBatteryManager.kext
  • AppleALC.kext
  • ApplePS2SmartTouchpad.kext
  • BrcmFirmwareRepo.kext
  • BrcmPatchRAM (Mavericks) or BrcmPatchRAM2 (Yosemite or later)
  • CodecCommander.kext
  • DisableTurboBoostBattery.kext
  • FakePCIID_XHCIMux.kext (Only for El Capitan)
  • FakePCIID_IntelHDMIaudio.kext
  • FakePCIID_BroadcomWiFI.kext  (makes my BCM94352HMB work)
  • FakePCIID_IntelHDGraphics.kext
  • FakePCIID.kext
  • FakeSMC, HWInfo, IntelCPUMonitor (HwSensors3 from Slice)
  • IntelBacklight.kext
  • RealtekRTL8111.kext
  • USBInjectAll.kext (Only for El Capitan)


After all the kexts necessary are in the correct folder, proceed to mimic my config.plist Note that the Kext patches included only work for El Capitan.

If you want older version support, post here and I can help. I recommend using Clover Configurator.

For your SMBIOS choose MacbookPro11,2 and shake those serial numbers to really get a genuine one. In order to get everything working properly , follow these guidelines for ACPI tables patching. Firstly, press F4 at Clover GUI in order to dump the native ACPI tables. You will most probably get a crash, a red screen full of weird black numbers and strange symbols, do not worry, just force shutdown. At the next boot if you look in /EFI/Clover/ACPI/origin in your USB you should have a bunch of files. After getting MaciASL and acpica tools from RehabMan (always updated) and installing them, and adding rehabman’s laptop dsdt patch repository.


I recommend patching these tables before installing Mac OS X in order to have a better user experience and better functionality as well as a cleaner and smoother install. Your computer may not even reach the installer since we have no way of disabling our discrete NVIDIA Geforce 820m without getting our hands dirty in DSDT patches. Delete all files that don’t start with DSDT or SSDT- If you have an SSDT with an x just delete it because it is dynamically loaded and so does not need our attention. Place the files in our interest in a folder and:

cd /path/to/a/folder

iasl -da -dl *.aml

After obtaining the .dsl files you should open them and check for errors.

In the latest BIOS we have the following errors:

DSDT- We will find 4 errors



The parse op Zero errors can be fixed by deleting all the “Zero” you find in the conflicting place.
The remaining two errors are fixed by applying the ADBG fix from RehabMan repo.






Perform the following fixes:
  • SSDT-1- We find many errors and all can be fixed by applying the patch “Remove _PSS placeholders”.
  • SSDT-12- We find an error related to a specific sector of a cryptic DOS device, we can safely delete these following lines from the SSDT.
Now that all our ACPI tables are nice and clean we can proceed to patching
First of all, open all the tables at the same time and hit Command + F to bring up the Find Replace dialog box and

  • Find:GFX0 and Replace it with: IGPU
  • Find:B0D3 and Replace it with HDAU

Do this in all the tables, so the renames are the same in all your tables
When that is done, apply the following patches to the DSDT:

  • Use the patch "DTGP" (you can easily find it with our friend Google )
  • Use the patch "Fix _WAK Arg0 v2"
  • Use the patch "HPET Fix"
  • Use the patch "SMBUS Fix"
  • Use the patch "IRQ Fix"
  • Use the patch "RTC Fix"
  • Use the patch "OS Check Fix Windows 8”
  • Use the patch "Add IMEI" 
  • Use the patch “7-8 Series USB”
  • Use the patch "USB PRW 0x0D"
  • Use the patch "Igpu Brightness Fix"
  • Use the patch "Audio Layout id 3"

When you have applied the Audio Layout Patch just
Find: layout and it should show the only result, then make that part look like mine, so that you can use AppleALC for native on the fly audio.
If you want HDMI audio you should open SSDT-10 and find layout again and make it look like the one you just edited in DSDT, we do this because we want layout-id 29 instead of layout-id 3.
For battery percentage you should use the ASUS N55SL/Vivobook patch.

Finally when you did all that you should follow RehabMan’s tutorial for Disabling Discrete Graphics Cards, on a web which I am not allowed to mention. This will give you much more battery life and a lot less heat. You should read it properly and you will notice there is close to no difference between his example and our laptop so it will be easier than it looks like. Make sure you also use the patch he posts to fix shutdown and sleep when our NVIDIA is disabled.
After all the ACPI tables are properly patched save them all and:

cd /path/to/where/your/patched/tables/are

Then delete all the original aml files and then:

iasl *.dsl 

After getting the resulting patched aml files, place them in /EFI/Clover/ACPI/patched for Clover to load it.

Place them all together in /EFI/Clover/ACPI/patched and in the ACPI section of your config.plist make sure to "Drop OEM" tables and set the "Sorted Order" as I did in the attached config.plist.

Before installing Mac OS X make sure in your BIOS you have legacy mode disabled and you have secure boot and fast boot also disabled, so that Clover works well. Also make sure the controller is set to AHCI mode.

Remember to use a GUID partition table on your Hard Drive and if you plan to dual boot just create two Mac OS Extended Journaled partitions, don't create any Fat partition using Disk Utility cause that will leave you unable to install Windows in UEFI mode.

Post-Install 

Finally you will need to generate an SSDT using ssdtPRGen.sh (this can only be done when you have installed Mac OS X), add it to the Sorted Order and you are done. Make sure to set the hibernate mode to either 0 or 2.
​You can copy the colour profiles from ASUS Splendid Utility and use them in Mac OS X, but for my eyes, I prefer the default LCD one

This is the first fully functional Hackintosh I ever accomplished and it took me a few months of learning… I am using Mac OS X for about two or more years in this Hack and I am still in love like the very first boot hihihi 

This is almost the perfect HackBook and has worked since Mountain Lion until now
Hope you enjoyed!  
Share:

Popular Posts

Labels

Followers

Recent Posts

Back to Top