Skip to content

Commit

Permalink
Merge pull request #10 from xcv58/deploy-script
Browse files Browse the repository at this point in the history
Add a deploy script to update Xcode.app.
  • Loading branch information
iGhibli committed Jul 18, 2018
2 parents 0a72155 + 8b2eeae commit 5bab5ba
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -3,6 +3,28 @@ This repository holds the device support files for the iOS, and I will update it

### Usage:
See docs: [https://ighibli.github.io/2017/03/28/Could-not-locate-device-support-files/](https://ighibli.github.io/2017/03/28/Could-not-locate-device-support-files/)

Below command will try to unzip all new device support files to `/Applications/Xcode.app`.

```sh
sudo ./deploy.py
```

You can use `-t` if your Xcode is not in `/Applications/` or has different name.

```sh
sudo ./deploy.py -t /Applications/Xcode\ 9.app
```

```sh
./deploy.py -h
usage: deploy.py [-h] [-t TARGET]

optional arguments:
-h, --help show this help message and exit
-t TARGET The path for Xcode
```

### Supported versions:
1. iOS8
* 8.0 `2017/04/07`
Expand Down
35 changes: 35 additions & 0 deletions deploy.py
@@ -0,0 +1,35 @@
#!/usr/bin/env python
import argparse
import zipfile
from os import listdir, path

SRC = path.join(path.dirname(path.abspath(__file__)), 'DeviceSupport')
DEVICE_SUPPORT_PATH='Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport'

def unzip_file(name, target):
f = path.join(SRC, name + '.zip')
zip_ref = zipfile.ZipFile(f, 'r')
zip_ref.extractall(target)
zip_ref.close()

def process(xcode):
target = path.join(xcode, DEVICE_SUPPORT_PATH)
exist = listdir(target)
all_files = [i.replace('.zip', '') for i in listdir(SRC) if i.endswith('.zip')]
new_files = list(set(all_files) - set(exist))
for i in new_files:
print 'Unzip file "{}.zip" to {}'.format(i, target)
unzip_file(i, target)
print '\nUpdate successfully for {}'.format(xcode)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'-t',
type=str,
dest='target',
default='/Applications/Xcode.app',
help='The path for Xcode'
)
args = parser.parse_args()
process(args.target)

0 comments on commit 5bab5ba

Please sign in to comment.