0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Xcodeでプリプロセッサによるソースコードの切り替え方法を行う方法。

Posted at

Configurationを作成する。

今回はDebugをコピーします。

OtherViews_と_Sample_—_Sample_xcodeproj.png

Sample_—_Sample_xcodeproj.png

スキームを作成する。

先ほど作ったConfigurationを使うためにスキームを追加します。

Sample_—_Sample_xcodeproj_と_メモ.png

OtherViews_と_Sample_—_Sample_xcodeproj.png

スクリーンショット_2022_08_25_9_35.png

Menubar_と_Sample_—Sample_xcodeproj_と_作業の開始—_SchemeSwitch_xcodeproj.png

TARGETS のBuild Settingから、Active Compilation Conditionsを設定する

Sample_—_Sample_xcodeproj.png

Sample_—_Sample_xcodeproj.png

スキームを切り替えて確認


struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .padding()
            .onAppear {
                #if STUB_SERVER
                    print("STUB_SERVER")
                #endif

                #if STUB_BLE
                    print("STUB_BLE")
                #endif
            }
    }
}


0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?