By Gouge Gerard / Platform Handler
Receive to the low in a serial of hands-on blog posts for the Windows Bridgework for iOS. The Windows Nosepiece for iOS is an open-source task that allows you to produce General Windows Program (UWP) apps that can run on Windows 10 devices exploitation iOS APIs and Objective-C encrypt.
Nowadays, we’re loss to habitus a elementary flutter tilt app in Xcode and use the Windows Span for iOS to fetch it terminated to Windows 10, guardianship all of the cipher in a individual codebase so the undertaking is all portable betwixt platforms. If you neediness to survey the concluded, throughout journeying, you’ll motivation:
- A PC track Windows 10, with Optical Studio 2015 and the Windows Bridgework for iOS installed. You can download Ocular Studio from the Windows Dev Core and receive the modish dismission of the span on GitHub hither.
- A Mac working Mac OS X 10.11 with Xcode 7 installed. If you wishing to run the iOS externalize on an genuine iOS gimmick, you’ll too motive a paying Apple Developer report.
If you don’t sustain a PC, you can download one of our pre-built rating practical machines from the Windows Bridgework for iOS site. Download the packet for your preferable virtualization surround and you’ll be up and functional in no metre – the parcel already includes Windows 10, Optic Studio 2015 and the iOS nosepiece.
If you don’t sustain a Mac but are rum astir development in Objective-C on Windows 10, you’ll hush be able-bodied to download the beginning cipher, consume the transition appendage and delete the encipher in Optic Studio.
Edifice a disruption lean app in Xcode
Low, download the initial hoo-hah tilt externalize, which can be plant hither. Pioneer the ToDo.xcodeproj charge and let’s analyze the task construction.
In the Storyboard editor, we sustain a unity UINavigationController as our theme survey comptroller and a UITableViewController that volition be our briny cover. Since the unscathed app is a one aspect, a piloting accountant isn’t rigorously requisite, but it leaves board for extensibility if you would alike to experimentation with winning the projection farther.
We’ve reinforced well-nigh of the app programmatically, so the lone otc point of annotation is the “Clear” UIBarButtonItem, which has an IBAction exit in the clearAllTodos: method in TDTableViewController.
Now let’s proceeds a deal the classes in the leftover sidebar in Xcode:
- TDItem – this is our barebones information construction for belongings disruption lean items.
- TDTableViewController – this is where almost of the logic of our app lies. This course inherits from UITableViewController and manages creating new commotion items and displaying in-progress and accomplished to dos.
- TDTableViewCell – this form inherits from UITableViewCell and provides the layout for both in-progress and archived to dos. It uses a pan gesticulate recognizer to add the swiping functionality and keeps a address to its presently displayed TDItem. Its depute is its nurture postpone scene control, which is notified when a cellphone is swiped leftfield (to cancel a to do) or compensate (to archive a to do).
- TDInputTableViewCell – this course too inherits from UITableViewCell and is ill-used to showing the stimulus bailiwick for adding new to dos. Comparable TDTableViewCell, its assign is its rear board sight control which is notified when a new to do is added.
- TDLabel – ultimately, TDLabel inherits from UILabel and but provides a mechanics for having a blockheaded strikethrough done its textbook.
Go onward and run the app in the iOS simulator in Xcode, and you’ll see our app starts up and runs nicely:
Try adding a few disturbance items and swiping compensate to archive an detail and leftover to blue-pencil it. If you relinquish the simulator and relaunch, you’ll poster your name disappears; we’ll study methods of dogging information crossways sessions erstwhile we institute the app o’er to Windows.
Now simulate the externalise directory onto a flick thrust and surface it on your Windows motorcar. (If you’re exploitation a Mac with a practical automobile, you can likewise equitable simulate the undertaking to a divided directory that is approachable from both the Mac and Windows sides.)
Future, let’s act our Xcode labor into a Optical Studio result.
On your Windows auto, open the winobjcdirectory and sail to winobjc/bin. Within, you’ll discovery a lodge called vsimporter. Vsimporter is a command-line instrument that turns an Xcode propose charge into a Optical Studio root. It mechanically handles Storyboards and Xibs, although Optical Studio does not presently sustain a Storyboard editor, so any changes to our Storyboard sustain to be made on the Mac english. (This is why we reinforced nigh of the layout programmatically.)
In a ramify windowpane, spread your kerfuffle lean externalize directory in charge adventurer. Prime Register Surface instruction contrast instigate and you’ll see a statement demarcation windowpane look. Cart the vsimporter register set in winobjc/binon top of the dictation pipeline windowpane and you should see its wide-cut itinerary seem. With the mastery job windowpane in focusing, hit Insert, then restoration to your hoo-ha name projection directory, which should now control a blade new Ocular Studio result lodge.
Victimisation Optic Studio and the iOS bridgework
Doubling pawl the new Ocular Studio resolution register that was barely created and Ocular Studio 2015 bequeath found. In the Ocular Studio Root Adventurer sidebar, you’ll see the top-level resolution charge, which you can boom to see the comrade form construction we had in Xcode. Heading files are stored in their own directory in Ocular Studio, but differently the construction should feel the like.
Hit F5 to run the app, expect for it to compose, and voila!
Our iOS app is linear natively on Windows 10 victimisation Objective-C.
The get-go matter you’ll observation is the app doesn’t shell decently. Windows 10 runs on a blanket diversity of configuration factors with dissimilar cover sizes, so to ascertain a near exploiter feel, your app should be cognizant of, and reply to, the contour it’s existence run on. To achieve this, we’re sledding to produce a Class for our app in our app assign called UIApplicationInitialStartupMode.
In the Root Adventurer, two-bagger detent AppDelegate.m. Below the real offset #consequence. add the chase encipher:
Hither, were victimisation the #ifdef and #endif preprocessor directives to curb to see if the WINOBJC symbolisation is outlined, bounteous us the power to admit Windows-specific inscribe. This keeps the codebase portable, since the Windows-specific codification volition just be neglected if we recur to Xcode and run the app on iOS.
For a wax description of the properties of the WOCDisplayMode aim ( autoMagnification. sizeUIWindowToFit. fixedWidth. etcetera), see the Victimisation the SDK subdivision of our projection wiki on GitHub.
Now hit F5 again to run the app and you should see the disruption leaning app decent and responsively deliver. Go forwards and add a few to dos and–
Uh oh! Looks same we base a bug:
What to do when you uncovering unsupported iOS API calls
With a lilliputian excavation, we chop-chop receive that we hit bugs when adding new to dos and archiving them. In both cases, we’re victimization UITableView’s beginUpdates and endUpdates illustration method calls, which let us to redact the fundamental information construction and enclose and travel rows in our postpone sight and guarantees the hardiness of the unharmed dealing. A spry deal the runtime log shows that these methods aren’t supported in the iOS bridgework:
Commencement, brand surely you register a bug on GitHub. GitHub is the scoop way to connect with our squad to let us live what tools you demand. If you uncovering unimplemented APIs, features you’d same to see, or bugs anyplace in the bridgework, delight let us recognise.
Following, we can use the like preprocessor directives we victimized to fix the app interpretation problems to make workarounds specifically for this use suit. Open TDTableViewController.m in Optical Studio and let’s pluck the toDoItemDeleted. toDoItemCompleted. and toDoItemAdded: methods:
This method lets us well percentage codification ‘tween an Xcode undertaking and a Optical Studio root. When run the app on iOS, we keep to use beginUpdates and endUpdates to care inserting and moving cells, but on Windows we plainly update the fundamental information construction and birdsong reloadData which forces the total postpone purview to rerender.
Hit F5 and your commotion leaning app should run without errors.
Now, a disruption number app isn’t all that lots use if it can’t think your to dos, and presently our app keeps everything in retentiveness, so every clock you plunge it you sustain to jump from scrawl. We can do improve.
Since we deliver such a uncomplicated use pillowcase, we can use dimension listing serialisation to storehouse our to dos in a.plist charge. This way, we can cut the register every metre a to do is added, deleted or archived, and but study the charge on app shipment. (A more rich execution would solitary cut the relevant modify every meter one is made, kinda than the discharge inclination of to dos, but for the interest of restraint we’ll good pen everything out aft every variety.)
Mind cover terminated to TDTableViewController.m and add the next methods at the backside:
In decree to depot our impost TDItem aim in a belongings number, we’ll pauperism to convince it into an NSDictionary. Fortunately, our TDItem effectuation has a serialise method that does precisely that and returns an NSDictionary. What a co-occurrence!
Now, we merely pauperism to update our toDoItemDeleted. toDoItemCompleted. toDoItemAdded. and clearAllTodos: methods to vociferation [ego writeToDosToDisk] correct earlier reverting and add a birdsong to [ego readToDosFromDisk] at the end of viewDidLoad.
Pressure F5 again to run your app and your to dos volition now be remembered crosswise launches, so you’ll ne’er leave anything at the grocery again. The new app is totally portable crossways Windows 10 and iOS, so you can outdoors your old Xcode externalize register abreast your Mac and the app volition retain to purpose incisively as expected.
Make to try your own app? Brain concluded to GitHub to download the nosepiece.
Thanks for chase on! You can download the ended disruption leaning Xcode externalize from our GitHub wiki, and be certainly to cheque the former posts in our serial:
Updated February 18, 2016 4:25 pm
Give the page a name and start editing it by slecting https://phonetrackingapps.com/samsung-galaxy-tab-3-parental-controls it from the sidebar