-
Notifications
You must be signed in to change notification settings - Fork 21
/
217 Creating Extensions for iOS and OS X, Part 2.srt
3530 lines (2759 loc) · 64 KB
/
217 Creating Extensions for iOS and OS X, Part 2.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:12,009 --> 00:00:15,052
morning everybody thanks for coming
welcome to
2
00:00:16,033 --> 00:00:16,128
creating X
3
00:00:17,028 --> 00:00:20,106
shins for I O S and 80 S 10 part 2 I'm
damian
4
00:00:21,006 --> 00:00:26,073
I'm from core OS and we apparently have
a user facing feature this year
5
00:00:26,073 --> 00:00:33,073
so glad to see everybody is excited
about extensions let's dive right in
6
00:00:36,096 --> 00:00:41,195
so before we talk about one extension as
7
00:00:42,059 --> 00:00:45,670
let's talk a little bit about what in
out years and why
8
00:00:45,067 --> 00:00:48,103
extensions are different so for now
9
00:00:49,003 --> 00:00:52,562
it's still in iowa say even with
extensions
10
00:00:52,589 --> 00:00:56,614
is the most important experience for the
user on I less the app
11
00:00:56,839 --> 00:01:00,050
owns the entire screen on last 10 the
12
00:01:00,005 --> 00:01:03,794
cursor focus goes the front most up this
is still
13
00:01:03,839 --> 00:01:08,110
the number one priority for users and on
iowa's
14
00:01:08,011 --> 00:01:11,043
aP's are completely managed by the user
via the App Store
15
00:01:11,043 --> 00:01:14,087
and on the west and the user can drag
into the trash move them around
16
00:01:14,087 --> 00:01:19,102
outs are entirely managed by the user so
about extensions
17
00:01:20,002 --> 00:01:24,068
so extensions are important to the user
18
00:01:24,068 --> 00:01:27,077
but they're not more important than the
current ap
19
00:01:27,077 --> 00:01:31,149
they are there to augment the app's
experience and rather than directly
20
00:01:32,049 --> 00:01:33,108
managing them
21
00:01:33,549 --> 00:01:38,780
extensions common go with maps so the
user isn't going to be purchasing
22
00:01:38,078 --> 00:01:41,139
or installing individual extensions
they're going to be
23
00:01:42,039 --> 00:01:46,046
getting those extensions with the app's
that they download from the store
24
00:01:46,046 --> 00:01:51,063
so extensions are built separately
25
00:01:51,063 --> 00:01:56,482
they are separate target in Xcode so
what we have this new section
26
00:01:57,049 --> 00:02:01,120
in Xcode for app extension template
targets so when you want to create an
27
00:02:01,759 --> 00:02:01,827
extension
28
00:02:02,439 --> 00:02:05,710
you're getting a new piece of code in
your app
29
00:02:05,071 --> 00:02:08,620
that is actually a separate bond all and
admits
30
00:02:09,259 --> 00:02:14,740
a separate execute a ble and with that
execute a ball
31
00:02:14,074 --> 00:02:17,133
comes UConn a distinct set of
entitlements and we have
32
00:02:18,033 --> 00:02:21,035
a separate excusable with its distinct
that entitlement Saunders
33
00:02:21,053 --> 00:02:25,056
that allows the operating system to know
these two things
34
00:02:25,083 --> 00:02:28,118
the app in the extension are different
entities
35
00:02:29,018 --> 00:02:32,022
be and with that
36
00:02:32,022 --> 00:02:36,048
weird get your getting a different
process so an extension
37
00:02:36,048 --> 00:02:39,062
is running and isolated address space
from your route
38
00:02:39,062 --> 00:02:44,041
and it executes completely independently
so this means that
39
00:02:44,599 --> 00:02:47,930
the cistern even if your app is not
running
40
00:02:47,093 --> 00:02:51,182
can still fire up your extension even if
you're up is suspended that doesn't
41
00:02:52,019 --> 00:02:52,540
affect
42
00:02:52,054 --> 00:02:55,069
and you have your extensions running for
the user
43
00:02:55,069 --> 00:02:59,073
and because of this the system can
optimize each experience
44
00:02:59,073 --> 00:03:02,073
separately so we can schedule them
45
00:03:02,073 --> 00:03:05,139
and even if the app goes away your
extension
46
00:03:06,039 --> 00:03:09,072
still sticks around so here's an example
47
00:03:09,072 --> 00:03:12,154
love an extension and what the user
might do you
48
00:03:13,054 --> 00:03:16,140
to invoke your extension and its you why
here we just have
49
00:03:17,004 --> 00:03:20,623
a little a networks thing so it's and
50
00:03:21,019 --> 00:03:25,030
new social networking app and its
bundling a social sharing extension
51
00:03:25,003 --> 00:03:28,079
so we see it in the in the far right
there
52
00:03:28,079 --> 00:03:31,131
with the purple icon and I go to the
site
53
00:03:32,031 --> 00:03:36,240
and I want to share this with my friends
on my new social network
54
00:03:36,519 --> 00:03:40,750
so the user we'll see and icon
representing my app
55
00:03:40,075 --> 00:03:44,079
but what that means is that I'm going to
be using that the extension for social
56
00:03:45,015 --> 00:03:46,098
sharing banded by that up
57
00:03:46,098 --> 00:03:49,117
so in previous releases a iowa's
58
00:03:50,017 --> 00:03:55,059
we've been we've been able to do this
but the Facebook and Twitter experiences
59
00:03:55,059 --> 00:03:59,148
et cetera have all been provided by
Apple now we're letting
60
00:04:00,048 --> 00:04:04,064
anyone who wants provide a social
sharing session not only provided but to
61
00:04:04,064 --> 00:04:05,553
find their own experience
62
00:04:06,129 --> 00:04:11,173
so in this case when user elects to
share
63
00:04:11,569 --> 00:04:15,500
they're getting a window that is
designed by the
64
00:04:15,005 --> 00:04:18,053
developer I love this social networking
app with
65
00:04:18,098 --> 00:04:21,121
whatever experience you whatever
experience
66
00:04:22,021 --> 00:04:26,069
that app developer wants to provide so
that's a high-level
67
00:04:26,069 --> 00:04:30,148
love how a extensions are architected on
our system
68
00:04:31,048 --> 00:04:34,085
let's talk a little bit about how we
actually
69
00:04:34,085 --> 00:04:37,108
extend the experience %uh viewer app and
projected
70
00:04:38,008 --> 00:04:41,107
into other parts of the system so as we
saw
71
00:04:42,007 --> 00:04:45,091
yesterday in part 1 extensions are a
very focused
72
00:04:45,091 --> 00:04:49,100
experience and the operating system
takes care of seamlessly merging the
73
00:04:50,081 --> 00:04:52,083
experience that you provide
74
00:04:52,083 --> 00:04:56,127
in your extension with the current ap or
just whatever the current
75
00:04:57,027 --> 00:05:00,236
I system you why is
76
00:05:00,479 --> 00:05:03,500
so you guys are gonna provide code
77
00:05:03,005 --> 00:05:06,021
to make the experience your own and
thats
78
00:05:06,066 --> 00:05:09,153
going almost certainly mean that you're
gonna want to reuse at least some love
79
00:05:10,053 --> 00:05:14,059
the code for your app
80
00:05:14,059 --> 00:05:17,093
so we hope you've been using the
model-view-controller paradigm
81
00:05:17,093 --> 00:05:21,082
a features like extensions are exactly
why we
82
00:05:21,919 --> 00:05:25,940
so desperately encourage you guys to
adopt this design pattern year after
83
00:05:25,094 --> 00:05:25,943
year
84
00:05:26,789 --> 00:05:30,880
because chances are with your extension
you're gonna wanna share
85
00:05:30,088 --> 00:05:36,090
least the data model and probably some
%uh view controller layers to
86
00:05:37,008 --> 00:05:40,013
you probably don't wanna share the view
if you're out because your app is
87
00:05:40,058 --> 00:05:41,060
designed around
88
00:05:41,006 --> 00:05:44,029
taking up the whole screen where is your
extension will not
89
00:05:44,083 --> 00:05:47,088
but that's only one-third of your code
you don't want to have to rewrite
90
00:05:48,033 --> 00:05:53,122
the entire two-thirds of it you wanna be
able to share code between the two
91
00:05:54,022 --> 00:05:57,341
and if only computer science
92
00:05:57,539 --> 00:06:02,460
head come up with a way to allow the
same code do exist
93
00:06:02,046 --> 00:06:07,565
into processes without having to
duplicate those code pages
94
00:06:07,979 --> 00:06:11,110
I think we might have a solution to this
95
00:06:11,011 --> 00:06:14,087
and I think that solutions called
frameworks so
96
00:06:14,087 --> 00:06:17,316
on iowa's im Iowa State
97
00:06:18,099 --> 00:06:25,099
were now allowing you to ship frameworks
within your app on
98
00:06:28,539 --> 00:06:32,530
don't get too excited so this is
99
00:06:32,053 --> 00:06:36,592
obviously knew I owe us but we you've
been able to do this on OS 10 since the
100
00:06:37,069 --> 00:06:37,163
dawn of time
101
00:06:38,009 --> 00:06:41,093
on but it's a brand new capability the
102
00:06:41,849 --> 00:06:44,896
tie less and what we're doing with that
is work also
103
00:06:45,319 --> 00:06:48,388
encrypting the frameworks that you ship
in your app on bull
104
00:06:49,009 --> 00:06:52,690
with the same I have encryption that
your caps
105
00:06:52,069 --> 00:06:57,138
are are gifted with to give you that
same level of protection against piracy
106
00:06:58,038 --> 00:07:01,447
and up well piracy
107
00:07:01,789 --> 00:07:05,430
heard on so
108
00:07:05,043 --> 00:07:08,462
its critical to note that these
frameworks are not
109
00:07:08,849 --> 00:07:12,650
general share code sharing mechanism so
you're not going to have
110
00:07:12,065 --> 00:07:15,136
many ups on the system referencing the
same popular framework
111
00:07:16,036 --> 00:07:19,047
these frameworks are here to see
facilitate
112
00:07:19,047 --> 00:07:22,216
sharing between ap and all its
extensions
113
00:07:22,639 --> 00:07:25,726
so the code that that frame live code
that former contains
114
00:07:26,509 --> 00:07:30,780
can be used by the app or any the
extensions upon dole's
115
00:07:30,078 --> 00:07:35,807
but nothing else on the system so when
you use
116
00:07:36,509 --> 00:07:40,553
of when you bundle a framework with your
app there are some implications for your
117
00:07:40,949 --> 00:07:42,240
minimum deployment target
118
00:07:42,024 --> 00:07:45,043
if you're ap links the framework
119
00:07:45,259 --> 00:07:48,620
we're going to change its minimum
employment targets Iowa State because as
120
00:07:48,062 --> 00:07:49,101
I said before
121
00:07:49,659 --> 00:07:52,440
were in cryptic these frameworks in
previous versions of the operating
122
00:07:52,044 --> 00:07:53,013
system
123
00:07:53,409 --> 00:07:56,440
don't know about how did deak rip them
when you use them
124
00:07:56,044 --> 00:07:59,061
however if you're just chipping your app
125
00:07:59,061 --> 00:08:02,860
and then there's a few extensions you
have the all link in a framework
126
00:08:03,409 --> 00:08:06,690
your aP's minimum deployment target
doesn't change at all
127
00:08:06,069 --> 00:08:10,155
your extension functionality obviously
won't be available to previous versions
128
00:08:11,055 --> 00:08:15,674
%uh I O S but the Apple still be able to
run without any problems
129
00:08:16,169 --> 00:08:19,430
so that's a very brief
130
00:08:19,043 --> 00:08:22,050
overview love embedded remarks on iowa's
131
00:08:23,013 --> 00:08:26,015
to learn more I encourage you to go to
132
00:08:26,033 --> 00:08:29,462
the session tomorrow at 3:15 in person
do.
133
00:08:29,759 --> 00:08:33,110
building modern frameworks be where
134
00:08:33,011 --> 00:08:36,570
will cover API usage how did
135
00:08:36,669 --> 00:08:39,672
write a good framework how to bundle it
all that good stuff
136
00:08:39,699 --> 00:08:44,940
but for now you got frameworks and it
seems like you guys are excited about
137
00:08:44,094 --> 00:08:47,099
so
138
00:08:47,099 --> 00:08:51,104
another cup topic for code sharing is
API availability
139
00:08:52,004 --> 00:08:54,010
if you're writing one of these
frameworks sorry for bowling or these
140
00:08:54,064 --> 00:08:54,127
frameworks
141
00:08:55,027 --> 00:08:59,076
what code are you going to be are using
between your app
142
00:08:59,076 --> 00:09:03,081
and your extension so
143
00:09:04,026 --> 00:09:08,087
the vast majority of our API is going to
be available for extensions to use
144
00:09:08,087 --> 00:09:11,118
but there are going to be some
exceptions and these exceptions are
145
00:09:12,018 --> 00:09:12,087
going to be marked
146
00:09:12,087 --> 00:09:15,676
explicitly with a new kinda
unavailability macro
147
00:09:16,459 --> 00:09:19,640
and here's an example what that looks
like
148
00:09:19,064 --> 00:09:22,065
so UI application
149
00:09:22,074 --> 00:09:26,080
very with your application the shared
application method has been explicitly
150
00:09:26,008 --> 00:09:27,055
marked as unavailable
151
00:09:28,027 --> 00:09:31,081
I and you like it folks have helpfully
provided
152
00:09:31,081 --> 00:09:34,084
and error message that says use a view
controller based solution where
153
00:09:35,011 --> 00:09:36,740
appropriate I'm Inc or less
154
00:09:36,839 --> 00:09:42,260
no idea what that means but I'm sure you
guys have an idea now if you're
155
00:09:42,026 --> 00:09:46,035
dropping down to Super League API that
has underscores
156
00:09:46,035 --> 00:09:49,088
there's going to be a corresponding X
availability macro there that is
157
00:09:49,088 --> 00:09:50,787
evaluated the same way
158
00:09:51,579 --> 00:09:55,680
by the tools and will generate the same
errors at build time
159
00:09:55,068 --> 00:09:58,167
so that's are unavailability
160
00:09:59,067 --> 00:10:02,154
like a certain vast majority of cases
you probably won't need to worry about
161
00:10:03,054 --> 00:10:03,105
it
162
00:10:04,005 --> 00:10:07,067
but if you if you do trip across an API
use
163
00:10:07,067 --> 00:10:10,112
in your extension that is not allowed
you'll know as soon as possible
164
00:10:11,012 --> 00:10:16,081
at build time before you can even run
the extension so I'll tell you share
165
00:10:16,081 --> 00:10:17,081
code
166
00:10:17,081 --> 00:10:20,152
with your extension and your app but at
runtime
167
00:10:21,052 --> 00:10:24,057
you're gonna wanna create a consistent
experience to
168
00:10:25,002 --> 00:10:28,131
and a consistent experience
169
00:10:28,149 --> 00:10:32,192
often means sharing the same set
resources
170
00:10:32,579 --> 00:10:35,617
and making sure that changes the user
has made to their data
171
00:10:35,959 --> 00:10:39,410
in your extension are reflected in the
app the next time they see it
172
00:10:39,041 --> 00:10:46,041
or vice versa so we have a few data
sharing solutions for you for extensions
173
00:10:48,063 --> 00:10:51,882
so the first thing I understand is that
an extension
174
00:10:52,449 --> 00:10:55,600
has a separate container from its ap by
default
175
00:10:55,006 --> 00:10:59,024
on it's just like how to APs are
segregated from each other they don't
176
00:10:59,078 --> 00:11:01,105
have access to each other's data
177
00:11:02,005 --> 00:11:06,012
but for any extension you bundle you can
up to share specific bits of data
178
00:11:06,075 --> 00:11:09,081
that will help you provoke provide a
consistent experience that
179
00:11:09,081 --> 00:11:13,090
all of our users expect
180
00:11:13,009 --> 00:11:16,568
and you can do this with what's called a
shared container
181
00:11:17,459 --> 00:11:20,920
so this is based on a new a
182
00:11:20,092 --> 00:11:23,138
a new concept called in ap group and
183
00:11:24,038 --> 00:11:28,056
this provides a shared storage area for
kind of just general
184
00:11:28,056 --> 00:11:32,101
datum sharing between your app in your
extension so if you have some custom
185
00:11:33,001 --> 00:11:37,030
data models are custom databases that
you're wrapping extension need to use
186
00:11:37,003 --> 00:11:41,029
this is a good place to put those files
and access them
187
00:11:41,056 --> 00:11:44,140
however you have to remember that
there's nothing stopping
188
00:11:45,004 --> 00:11:48,092
I your extension and your ap from
running at the same time
189
00:11:49,028 --> 00:11:52,697
you're out maybe in a long-running
background task it may not have been
190
00:11:52,949 --> 00:11:54,250
suspended yet
191
00:11:54,025 --> 00:11:58,104
and it might be you writing some a some
data to that shared container
192
00:11:59,004 --> 00:12:02,011
and then user might bring up your
extension so what this means is that you
193
00:12:02,011 --> 00:12:04,030
have to make sure to safely coordinate
194
00:12:04,003 --> 00:12:07,025
all the reads and writes those files you
have to make sure that you only write to
195
00:12:07,052 --> 00:12:08,063
the file
196
00:12:08,063 --> 00:12:11,071
when there are no readers contending for
it and that you're only reading when
197
00:12:12,043 --> 00:12:18,055
the files in a consistent state
198
00:12:18,055 --> 00:12:21,062
otherwise you're going to blow up your
file sports is gonna get corrupted
199
00:12:22,025 --> 00:12:26,073
so we introduce some sort of
synchronization scheme here
200
00:12:26,073 --> 00:12:30,118
so that if the extension rights hold of
the APN if the uprights hold of the
201
00:12:31,018 --> 00:12:31,797
extension
202
00:12:31,959 --> 00:12:35,360
and they're all both dealing with a
consistent view of the universe
203
00:12:35,036 --> 00:12:39,038
in here a few those technologies
204
00:12:39,038 --> 00:12:41,126
the first one is an ass file
coordination which kinda provides a
205
00:12:42,026 --> 00:12:42,089
general
206
00:12:42,089 --> 00:12:45,091
inner process synchronization strategy
207
00:12:45,091 --> 00:12:48,120
four-year extension and
208
00:12:48,939 --> 00:12:52,990
free extension and your app on if you're
using Core Data
209
00:12:52,099 --> 00:12:55,177
you could get a lot of this for free
there'd certain core data dot
210
00:12:56,077 --> 00:12:59,112
backing stores that are documented as
being called as being usable for
211
00:13:00,012 --> 00:13:02,030
multiple processes at the same time
212
00:13:02,003 --> 00:13:05,022
and sequel light also make some of these
guarantees
213
00:13:05,049 --> 00:13:08,101
so if you're using on those who
technologies chances are you're already
214