Skip to content

Commit 20fc15a

Browse files
author
Mike Richter
committed
Merged PR 2559: Update Xcode 10 static library instructions #17388
Update Xcode 10 static library instructions #17388 Related work items: #17388
2 parents 5d61420 + a8c9dd3 commit 20fc15a

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

README.md

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Once you are comfortable using *PPiOS-Rename*, it can be easier to use if you in
113113

114114
9. Rename the phase from `Run Script` to `Analyze Binary`.
115115

116-
10. Expand the phase, and where it says `Type a script or ...`, paste the following script, adjusting for the correct path:
116+
10. Expand the phase, and replace the shell script comment that says `# Type a script or ...`, pasting the following script (adjusting for the correct path):
117117

118118
PATH="$PATH:$HOME/Downloads/PPiOS-Rename-v1.3.0"
119119
[[ "$SDKROOT" == *iPhoneSimulator*.sdk* ]] && sdk="$SDKROOT"
@@ -136,7 +136,7 @@ Once you are comfortable using *PPiOS-Rename*, it can be easier to use if you in
136136

137137
16. Add a script phase, and rename it to `Apply Renaming to Sources` (this should be the only real action for this target).
138138

139-
17. Paste the following script, again adjusting for the correct path:
139+
17. Paste the following script (adjusting for the correct path):
140140

141141
PATH="$PATH:$HOME/Downloads/PPiOS-Rename-v1.3.0"
142142
ppios-rename --obfuscate-sources
@@ -421,48 +421,50 @@ The procedure is as follows:
421421

422422
2. From within the workspace, create a new project:
423423
1. In Xcode, go to `File` > `New` > `Project ...`.
424-
2. Select `iOS`, and under the `Application` section select `Single View Application`.
425-
3. When choosing the options, specify the `Product Name` as `WrappingApp`, and be sure to select Objective-C as the language.
426-
4. 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-
428-
someParentDir/StaticLib/StaticLib.xcodeproj
429-
someParentDir/LibWorkspace.xcworkspace
430-
someParentDir/WrappingApp/WrappingApp.xcodeproj
431-
432-
5. At the bottom of this dialog, specify `Add to:` the `LibWorkspace` workspace, and select `Create`.
433-
6. Select the WrappingApp target, then clean and build the project to verify that the project builds.
434-
7. Go to the Project Navigator, select the `WrappingApp` project, and select the `WrappingApp` target.
435-
8. Select `General`, scroll to the bottom, and select the `+` to add to the list of `Linked Frameworks and Libraries`.
436-
9. Add `libStaticLib.a`. This should appear under the `Workspace` section in the dialog. You may need to close and reopen `LibWorkspace` after adding `StaticLib` in order to get it to appear correctly.
437-
10. Select `Build Settings`, search for `other linker`, and set `Other Linker Flags` to include `-ObjC`.
438-
11. Clean and build again to verify that the workspace builds correctly. It should build the static library first and then the app.
424+
2. Select `iOS`, then under the `Application` section select `Single View App`, and then select `Next`.
425+
3. For the options: specify the `Product Name` as `WrappingApp` and be sure to select Objective-C as the language, then select `Next`.
426+
4. Create the project:
427+
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:
428+
429+
someParentDir/StaticLib/StaticLib.xcodeproj
430+
someParentDir/LibWorkspace.xcworkspace
431+
someParentDir/WrappingApp/WrappingApp.xcodeproj
432+
433+
2. At the bottom of the dialog, specify `Add to:` the `LibWorkspace` workspace.
434+
3. Select `Create`.
435+
436+
5. Select the WrappingApp target, then `Product` > `Build` to verify that the project builds.
437+
6. Go to the Project Navigator, select the `WrappingApp` project, and select the `WrappingApp` target.
438+
7. Select `General`, scroll to the bottom, and select the `+` to add to the list of `Linked Frameworks and Libraries`.
439+
8. Add `libStaticLib.a`.
440+
9. Select `Build Settings`, search for `other linker`, and set `Other Linker Flags` to include `-ObjC`.
441+
10. Select `Product` > `Clean Build Folder` and build again to verify that the workspace builds correctly. It should build the static library first and then the app.
439442

440443
3. Setup *PPiOS-Rename* to analyze the app:
441444
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.
442-
2. You may need to close and re-open the workspace to get Xcode to use the correct target name in the report navigator.
443-
3. <a name="countUniqueSymbols"></a>Clean and build the `Build and Analyze WrappingApp` target.
444-
4. 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. These should be benign, but can be excluded manually if necessary.
445-
5. 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 `AffectedType+CategoryName.h` convention.
445+
2. <a name="countUniqueSymbols"></a>Clean and build the `Build and Analyze WrappingApp` target.
446+
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.
447+
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.
446448
1. Go to the Report Navigator, review the log for a build of `StaticLib`, select a copy file task for one of the header files, right-click and `Copy`.
447449
2. Paste the result in a text editor.
448450
3. Select and copy the build output path. This should have the form: `<products-directory>/include/StaticLib`, and contain the string `/DerivedData/`.
449451
4. At a command line, run the following commands, from `someParentDir`:
450452

451-
# Replace ".../include/StaticLib" with the path
453+
# Replace ".../include/StaticLib" with the build output path
452454
# Replace "StaticLib" with the name of the umbrella header
453455
ls ".../include/StaticLib" | sed 's/.*+//' | sed 's/[.]h$//' | grep -v StaticLib > public-types.list
454456
# Or omit the grep -v part if you have no umbrella header
455457
ls ".../include/StaticLib" | sed 's/.*+//' | sed 's/[.]h$//' > public-types.list
456458
# verify the contents
457-
head public-types.list
459+
less public-types.list
458460
# SLAPublicClass
459461
# SLProtocolForSomething
460462
# SLSomeCategory
461463
# ...
462464

463465
>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.
464466
465-
6. Replace the analyze script (`Analyze Binary` run script phase) with the following to exclude the public types from renaming:
467+
5. Replace the analyze script (`Analyze Binary` run script phase) with the following to exclude the public types from renaming:
466468

467469
PATH="$PATH:$HOME/Downloads/PPiOS-Rename-v1.3.0"
468470
[[ "$SDKROOT" == *iPhoneSimulator*.sdk* ]] && sdk="$SDKROOT"
@@ -472,13 +474,16 @@ The procedure is as follows:
472474
$(for each in $(cat ../public-types.list) ; do printf -- '-F !%s ' "$each" ; done) \
473475
"$BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH"
474476

475-
7. Repeat steps [3.iii - 3.iv](#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).
476-
8. Review the list of types that will be renamed by executing the following at a command line (assuming all of the type names are prefixed with the two letters `SL`):
477+
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).
478+
7. Review the list of types that will be renamed by executing the following at a command line, from `someParentDir` (assumes all of the type names are prefixed with the two letters `SL`):
477479

478480
cat WrappingApp/symbols.map | awk '{print $3}' | sed 's/[",]//g' | grep '^SL' > renamed-types.txt
481+
less renamed-types.txt
482+
483+
8. Adjust `public-types.list` as necessary to ensure that all public types are not renamed.
479484

480485
4. Modify the static library project to apply the renaming:
481-
1. Follow instructions [13-16 in `Project Setup` above](#configureRenaming), applying them to the static library target.
486+
1. Follow instructions [13-16 in `Project Setup` above](#configureRenaming), applying them to the `StaticLib` target (duplicating the target this time).
482487
2. 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):
483488

484489
PATH="$PATH:$HOME/Downloads/PPiOS-Rename-v1.3.0"

0 commit comments

Comments
 (0)