--- ./Playunderground01.Start.swift.org 2020-07-28 18:11:03.000000000 +0900 +++ ./Playunderground01.Start.swift 2020-08-07 20:57:15.709329200 +0900 @@ -412,7 +412,11 @@ self.max = max } func random() -> Int { +#if false//!os(Linux) return Int(arc4random() % UInt32(max)) // 上限値までの乱数を返す +#else + return Int.random(in: 0...max) // 上限値までの乱数を返す +#endif } } /* 使い方 --- ./Playunderground03.Structure.swift.org 2020-08-07 16:20:09.765443000 +0900 +++ ./Playunderground03.Structure.swift 2020-08-07 16:21:39.539563200 +0900 @@ -258,6 +258,7 @@ } // グローバルスコープをもつ計算型プロパティ、List3-17(荻原P.077) +#if !os(Linux) import Cocoa // MacでAppKitフレームワークを使う var landscape : Bool { // グローバルスコープをもつ計算型プロパティの定義 //let size = NSScreen.main()!.frame.size // 定数sizeにディスプレイの大きさを得る(Swift3) @@ -265,6 +266,7 @@ return size.width > size.height } print(landscape ? "Landscape" : "Portrait") // Macではおそらく "Landscape" +#endif // プロパティオブザーバ、List3-18(荻原P.089) struct Stock { // プロパティオブザーバをもつストラクチャの定義 --- ./Playunderground06.BasicTypes.swift.org 2020-08-06 17:47:04.000000000 +0900 +++ ./Playunderground06.BasicTypes.swift 2020-08-07 16:30:39.130972200 +0900 @@ -523,7 +523,9 @@ //print(String(format: "%d, %d", 120)) // 同上 //print(String(format: "%s", "Alice")) // 同上 +#if !os(Linux) print(String(format: "%@", "蔵六")) // ○文字列の指定は「%@」 +#endif // 複雑な文字列の埋め込み(荻原P.157) let flag = true @@ -716,11 +718,13 @@ } // A.2.6 文字を表す型 let s15 = s9 + s10 + s11 + s12 + s14; +#if !os(Linux) for us15 in s15.unicodeScalars { if us15.properties.isEmoji { print(us15) // 「☀、➿、🚀、🛺、🧿、0、9」のみ表示、これらは絵文字らしい } } +#endif for us15 in s15.unicodeScalars { if us15.properties.isAlphabetic { print(us15) // ラテンアルファベット、ギリシャアルファベットに加え、平仮名、片仮名のみ表示、これらは「アルファベティック」らしい --- ./Playunderground10.Extension.swift.org 2020-08-07 16:31:29.869268200 +0900 +++ ./Playunderground10.Extension.swift 2020-08-07 16:32:18.685619700 +0900 @@ -381,6 +381,7 @@ } // import Foundation +#if !os(Linux) import CoreGraphics private extension CGRect { // 既存のCGRect型に対する拡張定義、List11-2(荻原第3版P.246) @@ -427,3 +428,4 @@ (10.0, 15.0), (10.0, 105.0), (130.0, 105.0), (130.0, 15.0) */ } +#endif --- ./Playunderground14.DataOfObjective-C.swift.org 2020-07-17 12:13:13.000000000 +0900 +++ ./Playunderground14.DataOfObjective-C.swift 2020-08-07 17:41:36.128679600 +0900 @@ -1,5 +1,7 @@ import Foundation +#if !os(Linux) import Cocoa +#endif // 変数にCの関数の結果を得る、List14-1(荻原P.380) do { var current: time_t = time(nil) // 現在時刻をtime_t型で取得 --- ./Playunderground15.OfObjective-C.dir/List15-1_6_make/makefile.org 2016-11-02 01:53:00.000000000 +0900 +++ ./Playunderground15.OfObjective-C.dir/List15-1_6_make/makefile 2020-08-07 16:59:46.531013200 +0900 @@ -4,6 +4,11 @@ CC=clang -arch x86_64 -mmacosx-version-min=$(MINVERSION) SWIFTC=swiftc -target x86_64-apple-macosx$(MINVERSION) +ifeq ($(shell uname -s),Linux) +all: + @echo Linux is not supported. +endif + ARect: MyRect.o main.o ARect.o $(SWIFTC) -o $@ main.o MyRect.o ARect.o main.o ARect.o: main.swift ARect.swift $(BRIDGE) --- ./Playunderground15.OfObjective-C.dir/List15-9/makefile.org 2016-11-04 00:47:50.000000000 +0900 +++ ./Playunderground15.OfObjective-C.dir/List15-9/makefile 2020-08-07 17:02:48.609690600 +0900 @@ -7,6 +7,11 @@ SWC = swiftc -target x86_64-apple-macosx$(MINVERSION) OBJ = main.o RowCopier.o Flipper.o +ifeq ($(shell uname -s),Linux) +all: + @echo Linux is not supported. +endif + flip: $(OBJ) $(SWC) -o $@ $(OBJ) --- ./Playunderground15.OfObjective-C.dir/makefile.org 2018-08-24 17:06:19.000000000 +0900 +++ ./Playunderground15.OfObjective-C.dir/makefile 2020-08-07 16:57:14.734795400 +0900 @@ -3,7 +3,12 @@ SWIFTCFLAGS=-O +ifeq ($(shell uname -s),Linux) +all: + @echo Linux is not supported. +else all: $(EXES) $(EXES:%=outs/%.out) +endif %: %.swift swiftc $(SWIFTCFLAGS) -o $@ $^ --- ./makefile.org 2020-07-26 17:35:59.000000000 +0900 +++ ./makefile 2020-08-07 17:30:16.097155600 +0900 @@ -1,4 +1,7 @@ SRCS=$(wildcard *.swift) +ifeq ($(shell uname -s),Linux) +SRCS=$(filter-out Playunderground14% Playunderground16%, $(wildcard *.swift)) +endif EXES=$(SRCS:%.swift=%) SWIFTCFLAGS=-O