You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve static library instructions for Xcode 12 #19526
Use .txt to allow macOS to open `public-types.txt` in TextEdit with `open public-types.txt` at the command-line.
The UI for creating new projects has changed in Xcode 12, these instructions should work for both Xcode 11 and Xcode 12.
Related work items: #19601
Copy file name to clipboardExpand all lines: README.md
+21-20Lines changed: 21 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,13 +102,13 @@ Once you are comfortable using *PPiOS-Rename*, it can be easier to use if you in
102
102
6. <aname="renameInfoPlist"></a>(Optional) Duplicating the target duplicates the associated `.plist` file with a default name. Rename the `.plist` file:
103
103
104
104
1. Select Build Settings, select _All_ settings, select _Combined_ view, and search for `plist`.
105
-
2. Update the value for `Info.plist File` to be consistent with that of the original target (something like `<project-name>/Build and Analyze <original-target-name>-Info.plist`).
105
+
2. Update the value for `Info.plist File` to be consistent with that of the original target (something like `Build and Analyze <original-target-name>-Info.plist`).
106
106
3. Move/rename the duplicated `.plist` file to the new name and path (e.g. using Finder).
107
107
4. Delete the now stale reference to the default `.plist` file from the Project navigator.
108
108
109
109
7. Select Build Phases.
110
110
111
-
8. Add a script phase: select the `+` (just above the "Dependencies" phase), and then select "New Run Script Phase" (it should be the last phase, and will be by default).
111
+
8. Add a script phase: select the `+` (in the UI just above the "Dependencies" phase), and then select "New Run Script Phase" (it should be the last phase, and will be by default).
112
112
113
113
9. Rename the phase from `Run Script` to `Analyze Binary`.
114
114
@@ -187,7 +187,7 @@ To fix this, add a `.pch` file as follows:
187
187
188
188
You have tried to run analysis on a static library or framework.
189
189
190
-
If you are trying to analyze a static library, please follow the instructions in the [Obfuscating Static Libraries](#obfuscating-static-libraries) section below.
190
+
If you are trying to analyze a static library, please follow the instructions in the [Obfuscate Static Libraries](#obfuscate-static-libraries) section below.
191
191
192
192
If you are trying to analyze a framework, sometimes it will work if you `--analyze` the `AppName.framework` directory created by Xcode when archiving. Try archiving the framework from Xcode and use the `AppName.framework` folder created inside the project's derived data folder (`~Library/Developer/Xcode/DerivedData/ProjectName-.../...`).
193
193
@@ -416,12 +416,15 @@ The procedure is as follows:
416
416
1. In Xcode, go to `File` > `New` > `Workspace ...`.
417
417
2. Choose an appropriate name for the workspace (referred to here as `LibWorkspace`), and save it in the directory containing the `StaticLib` project directory. See the source tree layout shown below.
418
418
3. Go to `File` > `Add Files to "LibWorkspace"...`.
419
-
4. Add the project file `StaticLib/StaticLib.xcodeproj`.
419
+
4. Add the project file `StaticLib/StaticLib.xcodeproj` (if this project was already open, you may need to close it, and then close and re-open the workspace).
420
420
421
421
2. From within the workspace, create a new project:
422
422
1. In Xcode, go to `File` > `New` > `Project ...`.
423
-
2. Select `iOS`, then under the `Application` section select `Single View App`, and then select `Next`.
424
-
3. For the options: specify the `Product Name` as `WrappingApp` and be sure to select Objective-C as the language, then select `Next`.
423
+
2. Select `iOS`, then under the `Application` section select `App` / `Single View App`, and then select `Next`.
424
+
3. Specify these options and then select `Next`:
425
+
1. Specify `WrappingApp` as the `Product Name`
426
+
2. Select the `Storyboard` as the `Interface`
427
+
3. Select `Objective-C` as the language
425
428
4. Create the project:
426
429
1. Specify the directory to store the `WrappingApp` project as a sibling of the static library's project directory. These instructions expect a source tree layout like the following, with everything under `someParentDir` under source control:
427
430
@@ -443,7 +446,7 @@ The procedure is as follows:
443
446
1. Follow instructions [5-12 in `Project Setup` above](#configureAnalyze), but apply them to `WrappingApp`, rather than the static library, and modify the original `WrappingApp` target. Duplication of the target is unnecessary.
444
447
2. <aname="countUniqueSymbols"></a>Clean and build the `Build and Analyze WrappingApp` target.
445
448
3. Review the build log in the Report navigator and look for the number of `Generated unique symbols`. This number should include all of the public and all of the non-public symbols from `StaticLib`. This will also include a small number of symbols from classes in the app itself. Symbols from the app should be benign, but can be excluded manually if necessary.
446
-
4. Create a list of public types for the static library named `public-types.list`. Either create the list using the following procedure, or create the list manually. The procedure requires that the names of the public header files match the names of the types, or follow the `AffectedType+CategoryName.h` convention.
449
+
4. Create a list of public types for the static library named `public-types.txt`. Either create the list using the following procedure, or create the list manually. The procedure requires that the names of the public header files match the names of the types, or follow the `AffectedType+CategoryName.h` convention.
447
450
1. Get the build-output path from the last build log:
448
451
1. Go to the Report navigator, select the last build of `WrappingApp`, and select `All` and `All Messages` at the top.
449
452
2. Near the bottom of the part of the log that pertains to `StaticLib`, select one of the `Copy` tasks for the headers for `StaticLib`, right-click and select `Copy`.
@@ -452,19 +455,17 @@ The procedure is as follows:
452
455
2. Construct the list of types from a list of files in the build-output path. Run the following commands in Terminal from the `someParentDir` directory:
453
456
1. List the header files in the build-output path to verify it. Replace `<build-output>` with the path copied from TextEdit (keep the quotation marks to prevent embedded spaces from causing issues):
454
457
455
-
ls -1 "<build-output>"
458
+
ls "<build-output>"
456
459
457
-
2.If you have an umbrella header, replace `StaticLib`with the name of the umbrella header (no `.h`):
460
+
2.Create the list with the following:
458
461
459
-
ls "<build-output>" | sed 's/.*+//' | sed 's/[.]h$//' | grep -v StaticLib > public-types.list
462
+
ls "<build-output>" | sed 's/.*+//' | sed 's/[.]h$//' > public-types.txt
460
463
461
-
3.Otherwise, omit the `grep -v ...` part if you have no umbrella header:
464
+
3.Verify the contents of `public-types.txt` by opening it in TextEdit. If you have an umbrella header, you need to remove the line corresponding to this header, since it effectively defines a type that doesn't exist.
462
465
463
-
ls "<build-output>" | sed 's/.*+//' | sed 's/[.]h$//' > public-types.list
466
+
open public-types.txt
464
467
465
-
4. Verify the contents of the `public-types.list` file by opening it in TextEdit.
466
-
467
-
>Note: This is an additional point of maintenance: as types are added to or removed from the public API of the library, the `public-types.list` will need to be updated accordingly.
468
+
>Note: This is an additional point of maintenance: as types are added to or removed from the public API of the library, the `public-types.txt` file will need to be updated accordingly.
468
469
469
470
5. Replace the analyze script (`Analyze Binary` run script phase) with the following to exclude the public types from renaming:
470
471
@@ -473,27 +474,27 @@ The procedure is as follows:
473
474
test -z "$sdk" && sdk="$CORRESPONDING_SIMULATOR_SDK_DIR"
474
475
test -z "$sdk" && sdk="$CORRESPONDING_SIMULATOR_PLATFORM_DIR/Developer/SDKs/iPhoneSimulator${SDK_VERSION}.sdk"
475
476
ppios-rename --analyze --sdk-root "$sdk" \
476
-
$(for each in $(cat ../public-types.list) ; do printf -- '-F !%s ' "$each" ; done) \
477
+
$(for each in $(cat ../public-types.txt) ; do printf -- '-F !%s ' "$each" ; done) \
477
478
"$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH"
478
479
479
480
6. Repeat steps [3.ii - 3.iii](#countUniqueSymbols). The number of unique symbols should decrease, but still be significant. This should be the count of all of the non-public symbols (non-public symbols for which there are not public symbols with the same name).
480
481
7. Review the list of types that will be renamed by executing the following in Terminal, from the `someParentDir` directory. Replace `SL` with the two or three letter prefix of the types in the library:
8. Review the list of renamed types by opening `renamed-types.txt` in TextEdit.
485
-
9. Adjust `public-types.list` as necessary to ensure that all public types are not renamed.
486
+
8. Adjust `public-types.txt` as necessary to ensure that all public types are not renamed.
486
487
487
488
4. Modify the static library project to apply the renaming:
488
489
1. Follow instructions [13-16 in `Project Setup` above](#configureRenaming), applying them to the `StaticLib` target (duplicating the target this time).
489
-
2. For step 17, the call to `ppios-rename` needs to reference the `symbols.map` file from the WrappingApp project, using the `--symbols-map` option. Use this script for the new Run Script phase (adjusting the path as necessary):
490
+
2. For step 17 in `Project Setup`, the call to `ppios-rename` needs to reference the `symbols.map` file from the WrappingApp project, using the `--symbols-map` option. Use this script for the new Run Script phase (adjusting the path as necessary):
3. Follow instruction [18 in `Project Setup` above](#renameApplyRenamingScheme).
495
496
496
-
5. All of these changes (to the static library, WrappingApp, the workspace, and `public-types.list`) should be committed to source control at this point, since building the target to Apply Renaming will change the sources in ways that shouldn't generally be committed. `renamed-types.txt`should not be committed. `WrappingApp/symbols.map` should not be committed at this point (but do commit to source control or otherwise preserve this file for release builds).
497
+
5. All of these changes (to the static library, WrappingApp, the workspace, and `public-types.txt`) should be committed to source control at this point, since building the target to Apply Renaming will change the sources in ways that shouldn't generally be committed. `renamed-types.txt`may be discarded. `WrappingApp/symbols.map` should not be committed at this point (but do preserve this file as a build artifact for release builds).
497
498
498
499
The process to build the static library with renaming becomes:
499
500
1. Ensure that build environment is clean (e.g. all stale symbols files have been removed, and modifications to .xib files have been reverted).
0 commit comments