Skip to content

Commit

Permalink
Merge pull request #766 from mac-cain13/refactor
Browse files Browse the repository at this point in the history
R.swift 7 – Major version, Xcode plugin, internal refactor
  • Loading branch information
tomlokhorst authored Nov 28, 2022
2 parents 2c16de6 + 6a6b0a7 commit b88d620
Show file tree
Hide file tree
Showing 260 changed files with 10,401 additions and 7,386 deletions.
90 changes: 59 additions & 31 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
branches: '*'

env:
DEVELOPER_DIR: /Applications/Xcode_13.0.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_14.0.app/Contents/Developer

jobs:
unit-tests:
runs-on: macos-11
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -25,9 +25,9 @@ jobs:
- name: Test
run: swift test -v

test-iOS:
runs-on: macos-11
needs: build
test-iOS-ResourceApp:
runs-on: macos-12
needs: build-rswift
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -37,26 +37,27 @@ jobs:
name: rswift-dev
- name: Put build into place
run: |
mkdir -p build/Debug
mv rswift-dev/rswift build/Debug/rswift
chmod +x build/Debug/rswift
mkdir -p .build/release
mv rswift-dev/rswift .build/release/rswift
chmod +x .build/release/rswift
- name: Pull cache
uses: actions/cache@v2
id: podcache-ios
with:
path: Examples/Pods
path: Examples/ResourceApp/Pods
key: ${{ runner.os }}pods${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}pods
- name: Install pods
if: steps.podcache-ios.outputs.cache-hit != 'true'
run: pod install --project-directory=Examples
run: pod install --project-directory=Examples/ResourceApp
- name: Test
run: fastlane scan --workspace "Examples/RswiftExamples.xcworkspace" --scheme "ResourceApp"
#run: fastlane scan --workspace "Examples/ResourceApp/ResourceApp.xcworkspace" --scheme "ResourceApp"
run: xcodebuild -workspace Examples/ResourceApp/ResourceApp.xcworkspace -scheme ResourceApp -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.0' test

test-tvOS:
runs-on: macos-11
needs: build
test-iOS-StaticFrameworks:
runs-on: macos-12
needs: build-rswift
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -66,25 +67,52 @@ jobs:
name: rswift-dev
- name: Put build into place
run: |
mkdir -p build/Debug
mv rswift-dev/rswift build/Debug/rswift
chmod +x build/Debug/rswift
- name: Pull cache
uses: actions/cache@v2
id: podcache-tvos
mkdir -p .build/release
mv rswift-dev/rswift .build/release/rswift
chmod +x .build/release/rswift
- name: Test
#run: fastlane scan --project "Examples/RswiftAppWithStaticFrameworks/RswiftAppWithStaticFrameworks.xcodeproj" --scheme "App"
run: xcodebuild -project Examples/RswiftAppWithStaticFrameworks/RswiftAppWithStaticFrameworks.xcodeproj -scheme App -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.0' test

test-iOS-LocalizedStringApp:
runs-on: macos-12
needs: build-rswift
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download build
uses: actions/download-artifact@v1
with:
path: Examples/Pods
key: ${{ runner.os }}pods${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}pods
- name: Install pods
if: steps.podcache-tvos.outputs.cache-hit != 'true'
run: pod install --project-directory=Examples
name: rswift-dev
- name: Put build into place
run: |
mkdir -p .build/release
mv rswift-dev/rswift .build/release/rswift
chmod +x .build/release/rswift
- name: Test
run: xcodebuild -project Examples/LocalizedStringApp/LocalizedStringApp.xcodeproj -scheme LocalizedStringApp -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.0' test

test-tvOS:
runs-on: macos-12
needs: build-rswift
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download build
uses: actions/download-artifact@v1
with:
name: rswift-dev
- name: Put build into place
run: |
mkdir -p .build/release
mv rswift-dev/rswift .build/release/rswift
chmod +x .build/release/rswift
- name: Test
run: fastlane scan --workspace "Examples/RswiftExamples.xcworkspace" --scheme "ResourceApp-tvOS"
#run: fastlane scan --project "Examples/RtvApp/RtvApp.xcodeproj" --scheme "ResourceApp-tvOS"
run: xcodebuild -project Examples/RtvApp/RtvApp.xcodeproj -scheme ResourceApp-tvOS -destination 'platform=tvOS Simulator,name=Apple TV,OS=16.0' test

build:
runs-on: macos-11
build-rswift:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -97,7 +125,7 @@ jobs:
${{ runner.os }}spm
- name: Set version
run: |
sed -i "" "s/\(static let version = \"\)Unknown\(\"\)/\1Development build: ${GITHUB_SHA}\2/" Sources/rswift/Rswift.swift
sed -i "" "s/\(static let version = \"\)Unknown\(\"\)/\1Development build: ${GITHUB_SHA}\2/" Sources/rswift/Config.swift
- name: Build
run: swift build -v -c release
- name: Store artifact
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ on:
types: created

env:
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_14.0.app/Contents/Developer

jobs:
release-build:
runs-on: macos-11
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set version
run: |
sed -i "" "s/\(static let version = \"\).*\(\"\)/\1${TAG}\2/" Sources/rswift/Rswift.swift
sed -i "" "s/\(static let version = \"\).*\(\"\)/\1${TAG}\2/" Sources/rswift/Config.swift
env:
TAG: ${{ github.event.release.tag_name }}
- name: Tarball source
Expand Down Expand Up @@ -52,7 +52,9 @@ jobs:
path: .build/apple/Products/Release/rswift

- name: Archive ZIP
run: zip --junk-paths ${{ runner.temp }}/rswift-${{ github.event.release.tag_name }}.zip .build/apple/Products/Release/rswift License
run: zip --junk-paths $FILENAME .build/apple/Products/Release/rswift License && zip --recurse-paths $FILENAME Sources/RswiftResources
env:
FILENAME: ${{ runner.temp }}/rswift-${{ github.event.release.tag_name }}.zip
- name: Notarize ZIP
run: |
sh notarize.sh
Expand All @@ -74,7 +76,7 @@ jobs:

- name: Publish to Cocoapods
run: |
export POD_VERSION=$(echo $TAG_NAME | cut -c2-)
export POD_VERSION=$TAG_NAME
pod trunk push
env:
TAG_NAME: ${{ github.event.release.tag_name }}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation/Images/RunXcodeModifyPackages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions Documentation/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

Pointers for migration between major versions.

## Upgrading to 7.0

[Demo video: Updating from R.swift 6 to Rswift 7](https://www.youtube.com/watch?v=icihJ_hin3I)

#### Running the executable

If you're using Swift Package Manager:
- Separate R.swift.Library is no longer needed, remove dependency on that package
- Add SPM dependency on `github.com/mac-cain13/R.swift.git` package
- Add `RswiftLibrary` to your targets
- Remove custom Run Script Build Phase that invokes `rswift` binary
- Under "Run Build Tool Plug-ins" Build Phase, add `RswiftGenerateInternalResources` or `RswiftGeneratePublicResources` ([Screenshot](Images/RunBuildToolPluginsRswift.png))
- Right-click on your project, and run `RswiftXcodeModifyPackages` to modify your Xcode project so that the build tool plug-in will actually run during builds (this seems to fix a bug in Xcode?) ([Screenshot](Images/RunXcodeModifyPackages.png))

If you're using Mint or manual call `rswift` executable:
- Separate R.swift.Library is no longer needed, remove dependency on that package
- Add SPM dependency on `github.com/mac-cain13/R.swift.git` package
- Add `RswiftLibrary` to your targets

Changes to the commandline tool `rswift` (not relevant when using SPM):
- Argument `accessLevel` renamed to `access-level`
- Argument `generateUITestFile` removed, if you need a separate file with just ids, call rswift a second time with `--generators id`
- Argument `hostingBundle` removed, bundle can be specified in code: `_R(bundle: someBundle)`
- Arguments removed: `bundleIdentifier`, `productModuleName`, `infoPlistFile`, `codeSignEntitlements`, `builtProductsDir`, `developerDir`, `platformDir`, `sdkRoot`, `sourceRoot`. Use environment variables instead.

#### Library changes

Internal changes in the Rswift support library:
- Renamed internal module, update `import Rswift` to `import RswiftResources`
- Removed protocols: `ColorResourceType`, `FileResourceType`, `FontResourceType`, `IdentifierType`, `ImageResourceType`, `StoryboardViewControllerResourceType`, `StringResourceType`, `Validatable`
- Added `StringResource1` up to `StringResource9`, for strings with parameters
- Renamed types:
* `ReuseIdentifierType` to `ReuseIdentifierContainer`
* `NibResourceType` to `NibReferenceContainer`
* `StoryboardResourceType` to `StoryboardReference`
* `StoryboardResourceWithInitialControllerType` to `InitialControllerContainer`
* `TypedStoryboardSegueInfo` to `TypedSegue`
* `StoryboardSegueIdentifier` to `SegueIdentifier`


## Upgrading to 6.0

- In the Build Phase, some changes are needed, [see an example screenshot](Images/BuildPhaseExample.png):
Expand Down
Loading

0 comments on commit b88d620

Please sign in to comment.