Skip to content

Commit 1ac778f

Browse files
authored
Merge pull request #837 from xiaomakuaiz/fix/douyin-ios-resource-bundle-version
Fix/douyin ios resource bundle version
2 parents 40f62c4 + 3257d87 commit 1ac778f

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/electron-release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ jobs:
301301
fi
302302
# CFBundleShortVersionString(version) 与 CFBundleVersion(build) 都取 V → 可对应 tag / CI run。
303303
node -e "const fs=require('fs');const p='app.json';const j=JSON.parse(fs.readFileSync(p,'utf8'));j.expo.version=String(process.argv[1]);j.expo.ios=j.expo.ios||{};j.expo.ios.buildNumber=String(process.argv[1]);fs.writeFileSync(p,JSON.stringify(j,null,2)+'\n');" "$V"
304+
echo "MOBILE_RELEASE_VERSION=$V" >> "$GITHUB_ENV"
304305
305306
- name: Install mobile deps
306307
working-directory: mobile
@@ -310,6 +311,28 @@ jobs:
310311
working-directory: mobile
311312
run: npx expo prebuild -p ios --no-install
312313

314+
- name: Sync iOS Xcode version settings
315+
working-directory: mobile
316+
shell: bash
317+
run: |
318+
set -euo pipefail
319+
: "${MOBILE_RELEASE_VERSION:?Missing MOBILE_RELEASE_VERSION}"
320+
export MOBILE_RELEASE_VERSION
321+
PBX="ios/MonkeyCode.xcodeproj/project.pbxproj"
322+
PLIST="ios/MonkeyCode/Info.plist"
323+
test -f "$PBX"
324+
test -f "$PLIST"
325+
326+
perl -0pi -e 's/(MARKETING_VERSION = )[^;]+;/${1}$ENV{MOBILE_RELEASE_VERSION};/g; s/(CURRENT_PROJECT_VERSION = )[^;]+;/${1}$ENV{MOBILE_RELEASE_VERSION};/g' "$PBX"
327+
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $MOBILE_RELEASE_VERSION" "$PLIST"
328+
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $MOBILE_RELEASE_VERSION" "$PLIST"
329+
330+
SHORT_VERSION=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$PLIST")
331+
BUILD_VERSION=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$PLIST")
332+
test "$SHORT_VERSION" = "$MOBILE_RELEASE_VERSION"
333+
test "$BUILD_VERSION" = "$MOBILE_RELEASE_VERSION"
334+
grep -nE "MARKETING_VERSION = $MOBILE_RELEASE_VERSION;|CURRENT_PROJECT_VERSION = $MOBILE_RELEASE_VERSION;" "$PBX"
335+
313336
- name: Pod install
314337
working-directory: mobile/ios
315338
run: pod install

mobile/plugins/withDouyinLogin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ def patch_douyin_resource_bundles(installer)
138138
if system('/usr/libexec/PlistBuddy', '-c', 'Print :CFBundleExecutable', info_plist, out: File::NULL, err: File::NULL)
139139
system('/usr/libexec/PlistBuddy', '-c', 'Delete :CFBundleExecutable', info_plist)
140140
end
141+
['CFBundleShortVersionString', 'CFBundleVersion'].each do |key|
142+
if system('/usr/libexec/PlistBuddy', '-c', "Print :#{key}", info_plist, out: File::NULL, err: File::NULL)
143+
system('/usr/libexec/PlistBuddy', '-c', "Delete :#{key}", info_plist)
144+
end
145+
end
141146
system('/usr/libexec/PlistBuddy', '-c', 'Set :CFBundlePackageType BNDL', info_plist) ||
142147
system('/usr/libexec/PlistBuddy', '-c', 'Add :CFBundlePackageType string BNDL', info_plist)
143148
end

0 commit comments

Comments
 (0)